2011-02-23 10:52:22 +00:00
|
|
|
/*
|
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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-13 19:00:54 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_buttons/buttons_header.c
|
|
|
|
* \ingroup spbuttons
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-13 19:00:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-13 19:00:54 +00:00
|
|
|
|
|
|
|
#include "ED_screen.h"
|
2008-12-19 12:48:30 +00:00
|
|
|
#include "ED_types.h"
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2011-02-09 11:03:11 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-13 19:00:54 +00:00
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "buttons_intern.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define B_CONTEXT_SWITCH 101
|
|
|
|
#define B_BUTSPREVIEW 102
|
|
|
|
|
2011-02-09 11:03:11 +00:00
|
|
|
static void set_texture_context(bContext *C, SpaceButs *sbuts)
|
|
|
|
{
|
|
|
|
switch(sbuts->mainb) {
|
|
|
|
case BCONTEXT_MATERIAL:
|
|
|
|
sbuts->texture_context = SB_TEXC_MAT_OR_LAMP;
|
|
|
|
break;
|
|
|
|
case BCONTEXT_DATA:
|
|
|
|
{
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
if(ob && ob->type==OB_LAMP)
|
|
|
|
sbuts->texture_context = SB_TEXC_MAT_OR_LAMP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BCONTEXT_WORLD:
|
|
|
|
sbuts->texture_context = SB_TEXC_WORLD;
|
|
|
|
break;
|
2011-02-12 14:38:34 +00:00
|
|
|
case BCONTEXT_PARTICLE:
|
|
|
|
sbuts->texture_context = SB_TEXC_PARTICLES;
|
|
|
|
break;
|
2011-02-09 11:03:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 08:03:28 +00:00
|
|
|
static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event)
|
2008-12-13 19:00:54 +00:00
|
|
|
{
|
2009-07-28 16:33:02 +00:00
|
|
|
SpaceButs *sbuts= CTX_wm_space_buts(C);
|
|
|
|
|
2010-01-05 00:45:05 +00:00
|
|
|
if(!sbuts) /* editor type switch */
|
2009-07-28 16:33:02 +00:00
|
|
|
return;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2008-12-13 19:00:54 +00:00
|
|
|
switch(event) {
|
2008-12-26 13:11:04 +00:00
|
|
|
case B_CONTEXT_SWITCH:
|
2009-04-21 15:30:54 +00:00
|
|
|
case B_BUTSPREVIEW:
|
2008-12-26 13:11:04 +00:00
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2011-02-09 11:03:11 +00:00
|
|
|
set_texture_context(C, sbuts);
|
|
|
|
|
2009-06-08 16:24:37 +00:00
|
|
|
sbuts->preview= 1;
|
2008-12-26 13:11:04 +00:00
|
|
|
break;
|
2008-12-21 23:39:52 +00:00
|
|
|
}
|
2009-07-24 16:41:12 +00:00
|
|
|
|
|
|
|
sbuts->mainbuser= sbuts->mainb;
|
2008-12-13 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2011-05-19 11:45:06 +00:00
|
|
|
#define BUT_UNIT_X (UI_UNIT_X+2)
|
|
|
|
|
2008-12-13 19:00:54 +00:00
|
|
|
void buttons_header_buttons(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2009-07-28 16:33:02 +00:00
|
|
|
SpaceButs *sbuts= CTX_wm_space_buts(C);
|
2008-12-13 19:00:54 +00:00
|
|
|
uiBlock *block;
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
int xco, yco= 2;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
buttons_context_compute(C, sbuts);
|
2008-12-13 19:00:54 +00:00
|
|
|
|
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);
|
|
|
|
|
2009-07-23 20:40:51 +00:00
|
|
|
xco= ED_area_header_switchbutton(C, block, yco);
|
2008-12-13 19:00:54 +00:00
|
|
|
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSS);
|
|
|
|
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
xco -= UI_UNIT_X;
|
2009-05-19 15:38:36 +00:00
|
|
|
|
2009-05-20 15:33:28 +00:00
|
|
|
// Default panels
|
2008-12-13 19:00:54 +00:00
|
|
|
uiBlockBeginAlign(block);
|
2009-10-14 14:07:32 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_RENDER))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_SCENE))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_WORLD))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints");
|
2009-06-27 14:35:24 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers");
|
2009-10-20 10:41:44 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_DATA))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_BONE))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
|
2009-09-19 19:40:38 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_BONE_CONSTRAINT))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT_BONE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_PARTICLE))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PARTICLES, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
|
2009-06-07 13:36:12 +00:00
|
|
|
if(sbuts->pathflag & (1<<BCONTEXT_PHYSICS))
|
2011-05-19 11:45:06 +00:00
|
|
|
uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PHYSICS, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
|
|
|
|
xco+= BUT_UNIT_X;
|
2008-12-13 19:00:54 +00:00
|
|
|
|
|
|
|
uiBlockEndAlign(block);
|
|
|
|
|
|
|
|
/* always as last */
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
UI_view2d_totRect_set(&ar->v2d, xco+(UI_UNIT_X/2), 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
|
|
|
}
|
|
|
|
|
|
|
|
|