2008-12-13 19:00:54 +00:00
/**
* $ Id $
*
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* The Original Code is Copyright ( C ) 2008 Blender Foundation .
* All rights reserved .
*
*
* Contributor ( s ) : Blender Foundation
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
# include <string.h>
# include <stdio.h>
# include "DNA_space_types.h"
# include "DNA_scene_types.h"
# include "DNA_screen_types.h"
# include "DNA_windowmanager_types.h"
# include "MEM_guardedalloc.h"
# include "BLI_blenlib.h"
2008-12-18 02:56:48 +00:00
# include "BKE_context.h"
2008-12-13 19:00:54 +00:00
# include "BKE_screen.h"
# include "ED_screen.h"
2008-12-19 12:48:30 +00:00
# include "ED_types.h"
2008-12-13 19:00:54 +00:00
# include "ED_util.h"
# include "WM_api.h"
# include "WM_types.h"
# include "BIF_gl.h"
# include "BIF_glutil.h"
# include "UI_interface.h"
# include "UI_resources.h"
# include "UI_view2d.h"
# include "buttons_intern.h"
/* ************************ header area region *********************** */
static void do_viewmenu ( bContext * C , void * arg , int event )
{
2009-03-13 13:38:41 +00:00
SpaceButs * sbuts = ( SpaceButs * ) CTX_wm_space_data ( C ) ;
ScrArea * sa = CTX_wm_area ( C ) ;
switch ( event ) {
case 0 : /* panel alignment */
case 1 :
case 2 :
sbuts - > align = event ;
2009-04-02 01:39:33 +00:00
if ( sbuts - > align )
2009-03-13 13:38:41 +00:00
sbuts - > re_align = 1 ;
break ;
}
ED_area_tag_redraw ( sa ) ;
2008-12-13 19:00:54 +00:00
}
2.5: UI & Menus
* Cleaned up UI_interface.h a bit, and added some comments to
organize things a bit and indicate what should be used when.
* uiMenu* functions can now be used to create menus for headers
too, this is done with a uiDefMenuBut, which takes a pointer
to a uiMenuCreateFunc, that will then call uiMenu* functions.
* Renamed uiMenuBegin/End to uiPupMenuBegin/End, as these are
specific to making popup menus. Will convert the other
conformation popup menu functions to use this too so we can
remove some code.
* Extended uiMenu functions, now there is is also:
BooleanO, FloatO, BooleanR, EnumR, LevelEnumR, Separator.
* Converted image window headers to use uiMenu functions, simplifies
menu code further here. Did not remove the uiDefMenu functions as
they are used in sequencer/view3d in some places now (will fix).
* Also tried to simplify and fix bounds computation a bit better
for popup menus. It tried to find out in advance what the size
of the menu was but this is difficult with keymap strings in
there, now uiPopupBoundsBlock can figure this out afterwards and
ensure the popup is within the window bounds. Will convert some
other functions to use this too.
2009-01-30 12:18:08 +00:00
static uiBlock * dummy_viewmenu ( bContext * C , ARegion * ar , void * arg_unused )
2008-12-13 19:00:54 +00:00
{
2009-03-13 13:38:41 +00:00
SpaceButs * sbuts = ( SpaceButs * ) CTX_wm_space_data ( C ) ;
ScrArea * sa = CTX_wm_area ( C ) ;
2008-12-13 19:00:54 +00:00
uiBlock * block ;
short yco = 0 , menuwidth = 120 ;
2.5
More cleanup!
- removed old UI font completely, including from uiBeginBlock
- emboss hints for uiBlock only have three types now;
Regular, Pulldown, or "Nothing" (only icon/text)
- removed old font path from Userdef
- removed all old button theme hinting
- removed old "auto block" to merge buttons in groups
(was only in use for radiosity buttons)
And went over all warnings. One hooray for make giving clean output :)
Well, we need uniform definitions for warnings, so people at least fix
them... here's the real bad bugs I found:
- in mesh code, a call to editmesh mixed *em and *me
- in armature, ED_util.h was not included, so no warnings for wrong call
to ED_undo_push()
- The extern Py api .h was not included in the bpy_interface.c, showing
a several calls using different args.
Further just added the missing includes, and removed unused vars.
2009-04-14 15:59:52 +00:00
block = uiBeginBlock ( C , ar , " dummy_viewmenu " , UI_EMBOSSP ) ;
2008-12-13 19:00:54 +00:00
uiBlockSetButmFunc ( block , do_viewmenu , NULL ) ;
2009-03-13 13:38:41 +00:00
if ( sbuts - > align = = 1 ) uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_HLT , " Horizontal " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
else uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_DEHLT , " Horizontal " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
if ( sbuts - > align = = 2 ) uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_HLT , " Vertical " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
else uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_DEHLT , " Vertical " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
if ( sbuts - > align = = 0 ) uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_HLT , " Free " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
else uiDefIconTextBut ( block , BUTM , 1 , ICON_CHECKBOX_DEHLT , " Free " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 0 , " " ) ;
if ( sa - > headertype = = HEADERTOP ) {
2008-12-13 19:00:54 +00:00
uiBlockSetDirection ( block , UI_DOWN ) ;
}
else {
uiBlockSetDirection ( block , UI_TOP ) ;
uiBlockFlipOrder ( block ) ;
}
uiTextBoundsBlock ( block , 50 ) ;
uiEndBlock ( C , block ) ;
return block ;
}
# define B_CONTEXT_SWITCH 101
# define B_BUTSPREVIEW 102
# define B_NEWFRAME 103
static void do_buttons_buttons ( bContext * C , void * arg , int event )
{
switch ( event ) {
case B_NEWFRAME :
2008-12-27 16:09:56 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_FRAME , NULL ) ;
2008-12-13 19:00:54 +00:00
break ;
2008-12-26 13:11:04 +00:00
case B_CONTEXT_SWITCH :
ED_area_tag_redraw ( CTX_wm_area ( C ) ) ;
break ;
2008-12-21 23:39:52 +00:00
}
2008-12-13 19:00:54 +00:00
}
void buttons_header_buttons ( const bContext * C , ARegion * ar )
{
2008-12-18 02:56:48 +00:00
ScrArea * sa = CTX_wm_area ( C ) ;
SpaceButs * sbuts = ( SpaceButs * ) CTX_wm_space_data ( C ) ;
2008-12-13 19:00:54 +00:00
uiBlock * block ;
int xco , yco = 3 ;
2.5
More cleanup!
- removed old UI font completely, including from uiBeginBlock
- emboss hints for uiBlock only have three types now;
Regular, Pulldown, or "Nothing" (only icon/text)
- removed old font path from Userdef
- removed all old button theme hinting
- removed old "auto block" to merge buttons in groups
(was only in use for radiosity buttons)
And went over all warnings. One hooray for make giving clean output :)
Well, we need uniform definitions for warnings, so people at least fix
them... here's the real bad bugs I found:
- in mesh code, a call to editmesh mixed *em and *me
- in armature, ED_util.h was not included, so no warnings for wrong call
to ED_undo_push()
- The extern Py api .h was not included in the bpy_interface.c, showing
a several calls using different args.
Further just added the missing includes, and removed unused vars.
2009-04-14 15:59:52 +00:00
block = uiBeginBlock ( C , ar , " header buttons " , UI_EMBOSS ) ;
2008-12-13 19:00:54 +00:00
uiBlockSetHandleFunc ( block , do_buttons_buttons , NULL ) ;
2008-12-14 12:16:55 +00:00
xco = ED_area_header_standardbuttons ( C , block , yco ) ;
2008-12-13 19:00:54 +00:00
if ( ( sa - > flag & HEADER_NO_PULLDOWN ) = = 0 ) {
int xmax ;
xmax = GetButStringLength ( " View " ) ;
2008-12-18 02:56:48 +00:00
uiDefPulldownBut ( block , dummy_viewmenu , CTX_wm_area ( C ) ,
2009-04-12 13:40:29 +00:00
" View " , xco , yco , xmax - 3 , 20 , " " ) ;
2008-12-13 19:00:54 +00:00
xco + = XIC + xmax ;
}
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
uiBlockBeginAlign ( block ) ;
uiDefIconButS ( block , ROW , B_CONTEXT_SWITCH , ICON_GAME , xco , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_LOGIC , 0 , 0 , " Logic (F4) " ) ;
uiDefIconButS ( block , ROW , B_CONTEXT_SWITCH , ICON_SCRIPT , xco + = XIC , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_SCRIPT , 0 , 0 , " Script " ) ;
2009-02-18 05:54:37 +00:00
uiDefIconButS ( block , ROW , B_BUTSPREVIEW , ICON_MATERIAL_DATA , xco + = XIC , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_SHADING , 0 , 0 , " Shading (F5) " ) ;
uiDefIconButS ( block , ROW , B_CONTEXT_SWITCH , ICON_OBJECT_DATA , xco + = XIC , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_OBJECT , 0 , 0 , " Object (F7) " ) ;
2008-12-13 19:00:54 +00:00
uiDefIconButS ( block , ROW , B_CONTEXT_SWITCH , ICON_EDIT , xco + = XIC , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_EDITING , 0 , 0 , " Editing (F9) " ) ;
2009-02-18 05:54:37 +00:00
uiDefIconButS ( block , ROW , B_CONTEXT_SWITCH , ICON_SCENE_DATA , xco + = XIC , yco , XIC , YIC , & ( sbuts - > mainb ) , 0.0 , ( float ) CONTEXT_SCENE , 0 , 0 , " Scene (F10) " ) ;
2008-12-13 19:00:54 +00:00
xco + = XIC ;
/* select the context to be drawn, per contex/tab the actual context is tested */
uiBlockSetEmboss ( block , UI_EMBOSS ) ; // normal
switch ( sbuts - > mainb ) {
case CONTEXT_SCENE :
uiBlockBeginAlign ( block ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_SCENE , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SCENE ] ) , 1.0 , ( float ) TAB_SCENE_RENDER , 0 , 0 , " Render buttons " ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_SEQUENCE , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SCENE ] ) , 1.0 , ( float ) TAB_SCENE_SEQUENCER , 0 , 0 , " Sequencer buttons " ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_ANIM , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SCENE ] ) , 1.0 , ( float ) TAB_SCENE_ANIM , 0 , 0 , " Anim/playback buttons " ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_SOUND , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SCENE ] ) , 1.0 , ( float ) TAB_SCENE_SOUND , 0 , 0 , " Sound block buttons " ) ;
break ;
case CONTEXT_OBJECT :
uiBlockBeginAlign ( block ) ;
2009-02-18 05:54:37 +00:00
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_OBJECT_DATA , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_OBJECT ] ) , 1.0 , ( float ) TAB_OBJECT_OBJECT , 0 , 0 , " Object buttons " ) ;
2008-12-13 19:00:54 +00:00
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_PHYSICS , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_OBJECT ] ) , 1.0 , ( float ) TAB_OBJECT_PHYSICS , 0 , 0 , " Physics buttons " ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_PARTICLES , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_OBJECT ] ) , 1.0 , ( float ) TAB_OBJECT_PARTICLE , 0 , 0 , " Particle buttons " ) ;
break ;
case CONTEXT_SHADING :
uiBlockBeginAlign ( block ) ;
uiDefIconButC ( block , ROW , B_BUTSPREVIEW , ICON_LAMP , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SHADING ] ) , 1.0 , ( float ) TAB_SHADING_LAMP , 0 , 0 , " Lamp buttons " ) ;
uiDefIconButC ( block , ROW , B_BUTSPREVIEW , ICON_MATERIAL , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SHADING ] ) , 1.0 , ( float ) TAB_SHADING_MAT , 0 , 0 , " Material buttons " ) ;
uiDefIconButC ( block , ROW , B_BUTSPREVIEW , ICON_TEXTURE , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SHADING ] ) , 1.0 , ( float ) TAB_SHADING_TEX , 0 , 0 , " Texture buttons(F6) " ) ;
uiDefIconButC ( block , ROW , B_CONTEXT_SWITCH , ICON_RADIO , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SHADING ] ) , 1.0 , ( float ) TAB_SHADING_RAD , 0 , 0 , " Radiosity buttons " ) ;
uiDefIconButC ( block , ROW , B_BUTSPREVIEW , ICON_WORLD , xco + = XIC , yco , XIC , YIC , & ( sbuts - > tab [ CONTEXT_SHADING ] ) , 1.0 , ( float ) TAB_SHADING_WORLD , 0 , 0 , " World buttons " ) ;
break ;
case CONTEXT_EDITING :
break ;
case CONTEXT_SCRIPT :
break ;
case CONTEXT_LOGIC :
break ;
}
uiBlockEndAlign ( block ) ;
xco + = XIC ;
2008-12-18 02:56:48 +00:00
uiDefButI ( block , NUM , B_NEWFRAME , " " , ( xco + 20 ) , yco , 60 , YIC , & ( CTX_data_scene ( C ) - > r . cfra ) , 1.0 , MAXFRAMEF , 0 , 0 , " Displays Current Frame of animation. Click to change. " ) ;
2008-12-13 19:00:54 +00:00
xco + = 80 ;
// XXX buttons_active_id(&id, &idfrom);
// sbuts->lockpoin= id;
/* always as last */
2008-12-15 13:23:55 +00:00
UI_view2d_totRect_set ( & ar - > v2d , xco + XIC + 80 , ar - > v2d . tot . ymax - ar - > v2d . tot . ymin ) ;
2008-12-13 19:00:54 +00:00
uiEndBlock ( C , block ) ;
2008-12-26 13:11:04 +00:00
uiDrawBlock ( C , block ) ;
2008-12-13 19:00:54 +00:00
}