Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2009-08-06 13:56:14 +0400
committerJoseph Eagar <joeedh@gmail.com>2009-08-06 13:56:14 +0400
commit38de6d14e4e7a55a4109313942df3ae9211b1aeb (patch)
tree83288d248bc7a4794b8b34e607f3e319e905b381 /source/blender/editors/space_buttons
parent416a3bf4a14a951642cace5ee8033c4c20dd9f66 (diff)
parent1e4fb484001994f4e164aab7b44c9578df59f67d (diff)
merge with 2.5 (not trunk, last merge message said that on accident) at r22252
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c122
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c100
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h6
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c105
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c42
5 files changed, 234 insertions, 141 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 9048565b01f..614017cc4c6 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
+#include "DNA_brush_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
@@ -45,6 +46,7 @@
#include "BLI_listbase.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
@@ -65,7 +67,7 @@
typedef struct ButsContextPath {
PointerRNA ptr[8];
int len;
- int worldtex;
+ int flag;
} ButsContextPath;
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
@@ -302,10 +304,48 @@ static int buttons_context_path_particle(ButsContextPath *path)
return 0;
}
+static int buttons_context_path_brush(ButsContextPath *path)
+{
+ Scene *scene;
+ ToolSettings *ts;
+ Brush *br= NULL;
+ PointerRNA *ptr= &path->ptr[path->len-1];
+
+ /* if we already have a (pinned) brush, we're done */
+ if(RNA_struct_is_a(ptr->type, &RNA_Brush)) {
+ return 1;
+ }
+ /* if we have a scene, use the toolsettings brushes */
+ else if(buttons_context_path_scene(path)) {
+ scene= path->ptr[path->len-1].data;
+ ts= scene->toolsettings;
+
+ if(G.f & G_SCULPTMODE)
+ br= ts->sculpt->brush;
+ else if(G.f & G_VERTEXPAINT)
+ br= ts->vpaint->brush;
+ else if(G.f & G_WEIGHTPAINT)
+ br= ts->wpaint->brush;
+ else if(G.f & G_TEXTUREPAINT)
+ br= ts->imapaint.brush;
+
+ if(br) {
+ RNA_id_pointer_create(&br->id, &path->ptr[path->len]);
+ path->len++;
+
+ return 1;
+ }
+ }
+
+ /* no path to a world possible */
+ return 0;
+}
+
static int buttons_context_path_texture(ButsContextPath *path)
{
Material *ma;
Lamp *la;
+ Brush *br;
World *wo;
MTex *mtex;
Tex *tex;
@@ -315,8 +355,21 @@ static int buttons_context_path_texture(ButsContextPath *path)
if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
return 1;
}
+ /* try brush */
+ else if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) {
+ br= path->ptr[path->len-1].data;
+
+ if(br) {
+ mtex= br->mtex[(int)br->texact];
+ tex= (mtex)? mtex->tex: NULL;
+
+ RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
+ path->len++;
+ return 1;
+ }
+ }
/* try world */
- else if(path->worldtex && buttons_context_path_world(path)) {
+ else if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) {
wo= path->ptr[path->len-1].data;
if(wo) {
@@ -354,46 +407,21 @@ static int buttons_context_path_texture(ButsContextPath *path)
return 1;
}
}
- /* TODO: material nodes, brush */
+ /* TODO: material nodes */
- /* no path to a particle system possible */
+ /* no path to a texture possible */
return 0;
}
-static int buttons_context_path_game(ButsContextPath *path)
-{
- /* XXX temporary context. Using material slot instead of ob->game_data */
- Object *ob;
- PointerRNA *ptr= &path->ptr[path->len-1];
- Material *ma;
-
- /* if we already have a (pinned) material, we're done */
- if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
- return 1;
- }
- /* if we have an object, use the object material slot */
- else if(buttons_context_path_object(path)) {
- ob= path->ptr[path->len-1].data;
- if(ob && ob->type && (ob->type<OB_LAMP)) {
- ma= give_current_material(ob, ob->actcol);
- RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
-
- /* no path to a material possible */
- return 0;
-}
-static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int worldtex)
+static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
ID *id;
int found;
memset(path, 0, sizeof(*path));
- path->worldtex= worldtex;
+ path->flag= flag;
/* if some ID datablock is pinned, set the root pointer */
if(sbuts->pinid) {
@@ -430,9 +458,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
case BCONTEXT_DATA:
found= buttons_context_path_data(path, -1);
break;
- case BCONTEXT_GAME:
- found= buttons_context_path_game(path);
- break;
case BCONTEXT_PARTICLE:
found= buttons_context_path_particle(path);
break;
@@ -459,18 +484,18 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
{
ButsContextPath *path;
PointerRNA *ptr;
- int a, worldtex, flag= 0;
+ int a, pflag, flag= 0;
if(!sbuts->path)
sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
path= sbuts->path;
- worldtex= (sbuts->flag & SB_WORLD_TEX);
+ pflag= (sbuts->flag & (SB_WORLD_TEX|SB_BRUSH_TEX));
/* for each context, see if we can compute a valid path to it, if
* this is the case, we know we have to display the button */
for(a=0; a<BCONTEXT_TOT; a++) {
- if(buttons_context_path(C, path, a, worldtex)) {
+ if(buttons_context_path(C, path, a, pflag)) {
flag |= (1<<a);
/* setting icon for data context */
@@ -485,6 +510,11 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
}
}
+ /* always try to use the tab that was explicitly
+ * set to the user, so that once that context comes
+ * back, the tab is activated again */
+ sbuts->mainb= sbuts->mainbuser;
+
/* in case something becomes invalid, change */
if((flag & (1 << sbuts->mainb)) == 0) {
if(flag & BCONTEXT_OBJECT) {
@@ -500,7 +530,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
}
}
- buttons_context_path(C, path, sbuts->mainb, worldtex);
+ buttons_context_path(C, path, sbuts->mainb, pflag);
if(!(flag & (1 << sbuts->mainb))) {
if(flag & (1 << BCONTEXT_OBJECT))
@@ -516,7 +546,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
ButsContextPath *path= sbuts?sbuts->path:NULL;
if(!path)
@@ -526,9 +556,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if(CTX_data_dir(member)) {
static const char *dir[] = {
"world", "object", "mesh", "armature", "lattice", "curve",
- "meta_ball", "lamp", "camera", "material", "material_slot", "game",
+ "meta_ball", "lamp", "camera", "material", "material_slot",
"texture", "texture_slot", "bone", "edit_bone", "particle_system",
- "cloth", "soft_body", "fluid", "collision", NULL};
+ "cloth", "soft_body", "fluid", "collision", "brush", NULL};
CTX_data_dir_set(result, dir);
return 1;
@@ -671,6 +701,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
+ else if(CTX_data_equals(member, "brush")) {
+ set_pointer_type(path, result, &RNA_Brush);
+ return 1;
+ }
return 0;
}
@@ -679,7 +713,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
static void pin_cb(bContext *C, void *arg1, void *arg2)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
ButsContextPath *path= sbuts->path;
PointerRNA *ptr;
int a;
@@ -704,7 +738,7 @@ static void pin_cb(bContext *C, void *arg1, void *arg2)
void buttons_context_draw(const bContext *C, uiLayout *layout)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
ButsContextPath *path= sbuts->path;
uiLayout *row;
uiBlock *block;
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index e569ed324cd..a1041bc5106 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -60,66 +60,17 @@
#include "buttons_intern.h"
-/* ************************ header area region *********************** */
-
-static void do_viewmenu(bContext *C, void *arg, int event)
-{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
- ScrArea *sa= CTX_wm_area(C);
-
- switch(event) {
- case 1:
- case 2:
- sbuts->align= event;
- sbuts->re_align= 1;
- break;
- }
-
- ED_area_tag_redraw(sa);
-}
-
-static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
- ScrArea *sa= CTX_wm_area(C);
- uiBlock *block;
- short yco= 0, menuwidth=120;
-
- block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP);
- uiBlockSetButmFunc(block, do_viewmenu, NULL);
-
- 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(sa->headertype==HEADERTOP) {
- 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)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
+
+ if(!sbuts) /* window type switch */
+ return;
switch(event) {
- case B_NEWFRAME:
- WM_event_add_notifier(C, NC_SCENE|ND_FRAME, NULL);
- break;
case B_CONTEXT_SWITCH:
case B_BUTSPREVIEW:
ED_area_tag_redraw(CTX_wm_area(C));
@@ -133,12 +84,13 @@ static void do_buttons_buttons(bContext *C, void *arg, int event)
sbuts->preview= 1;
break;
}
+
+ sbuts->mainbuser= sbuts->mainb;
}
void buttons_header_buttons(const bContext *C, ARegion *ar)
{
- ScrArea *sa= CTX_wm_area(C);
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
uiBlock *block;
int xco, yco= 3;
@@ -147,17 +99,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
uiBlockSetHandleFunc(block, do_buttons_buttons, NULL);
- xco= ED_area_header_standardbuttons(C, block, yco);
-
- if((sa->flag & HEADER_NO_PULLDOWN)==0) {
- int xmax;
-
- xmax= GetButStringLength("View");
- uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C),
- "View", xco, yco, xmax-3, 20, "");
-
- xco+=xmax;
- }
+ xco= ED_area_header_switchbutton(C, block, yco);
uiBlockSetEmboss(block, UI_EMBOSS);
@@ -166,30 +108,28 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
// Default panels
uiBlockBeginAlign(block);
if(sbuts->pathflag & (1<<BCONTEXT_SCENE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
if(sbuts->pathflag & (1<<BCONTEXT_WORLD))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Constraint");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Constraint");
if(sbuts->pathflag & (1<<BCONTEXT_DATA))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier");
if(sbuts->pathflag & (1<<BCONTEXT_BONE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE))
- uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
+ uiDefIconButS(block, ROW, B_BUTSPREVIEW, ICON_TEXTURE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
if(sbuts->pathflag & (1<<BCONTEXT_PARTICLE))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PARTICLES, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PARTICLES, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
if(sbuts->pathflag & (1<<BCONTEXT_PHYSICS))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PHYSICS, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
- if(sbuts->pathflag & (1<<BCONTEXT_GAME))
- uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_GAME, xco+=XIC, yco, XIC, YIC, &(sbuts->mainb), 0.0, (float)BCONTEXT_GAME, 0, 0, "Game");
- xco+= XIC;
+ uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_PHYSICS, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
+ xco+= BUTS_UI_UNIT;
uiBlockEndAlign(block);
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index adae52c1ce7..8ed17ab1fa8 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -49,6 +49,9 @@ struct wmOperatorType;
#define BUTS_SENS_STATE 512
#define BUTS_ACT_STATE 1024
+#define BUTS_HEADERY (HEADERY*1.2)
+#define BUTS_UI_UNIT (UI_UNIT_Y*1.2)
+
/* internal exports only */
/* buttons_header.c */
@@ -86,5 +89,8 @@ void PARTICLE_OT_target_move_down(struct wmOperatorType *ot);
void SCENE_OT_render_layer_add(struct wmOperatorType *ot);
void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);
+void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
+void BUTTONS_OT_toolbox(struct wmOperatorType *ot);
+
#endif /* ED_BUTTONS_INTERN_H */
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index b4348c2db9a..4e9715538a0 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -38,6 +38,8 @@
#include "DNA_node_types.h"
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
#include "DNA_world_types.h"
#include "BKE_context.h"
@@ -70,6 +72,9 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "UI_interface.h"
+#include "UI_resources.h"
+
#include "buttons_intern.h" // own include
@@ -905,3 +910,103 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/********************** toolbox operator *********************/
+
+static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ bScreen *sc= CTX_wm_screen(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
+ PointerRNA ptr;
+ uiPopupMenu *pup;
+ uiLayout *layout;
+
+ RNA_pointer_create(&sc->id, &RNA_SpaceButtonsWindow, sbuts, &ptr);
+
+ pup= uiPupMenuBegin(C, "Align", 0);
+ layout= uiPupMenuLayout(pup);
+ uiItemsEnumR(layout, &ptr, "align");
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
+void BUTTONS_OT_toolbox(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Toolbox";
+ ot->idname= "BUTTONS_OT_toolbox";
+
+ /* api callbacks */
+ ot->invoke= toolbox_invoke;
+}
+
+/********************** filebrowse operator *********************/
+
+typedef struct FileBrowseOp {
+ PointerRNA ptr;
+ PropertyRNA *prop;
+} FileBrowseOp;
+
+static int file_browse_exec(bContext *C, wmOperator *op)
+{
+ FileBrowseOp *fbo= op->customdata;
+ char *str;
+
+ str= RNA_string_get_alloc(op->ptr, "filename", 0, 0);
+ RNA_property_string_set(&fbo->ptr, fbo->prop, str);
+ RNA_property_update(C, &fbo->ptr, fbo->prop);
+ MEM_freeN(str);
+
+ MEM_freeN(op->customdata);
+ return OPERATOR_FINISHED;
+}
+
+static int file_browse_cancel(bContext *C, wmOperator *op)
+{
+ MEM_freeN(op->customdata);
+ op->customdata= NULL;
+
+ return OPERATOR_CANCELLED;
+}
+
+static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+ FileBrowseOp *fbo;
+ char *str;
+
+ uiFileBrowseContextProperty(C, &ptr, &prop);
+
+ if(!prop)
+ return OPERATOR_CANCELLED;
+
+ fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
+ fbo->ptr= ptr;
+ fbo->prop= prop;
+ op->customdata= fbo;
+
+ str= RNA_property_string_get_alloc(&ptr, prop, 0, 0);
+ RNA_string_set(op->ptr, "filename", str);
+ MEM_freeN(str);
+
+ WM_event_add_fileselect(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void BUTTONS_OT_file_browse(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "File Browse";
+ ot->idname= "BUTTONS_OT_file_browse";
+
+ /* api callbacks */
+ ot->invoke= file_browse_invoke;
+ ot->exec= file_browse_exec;
+ ot->cancel= file_browse_cancel;
+
+ /* properties */
+ WM_operator_properties_filesel(ot, 0);
+}
+
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 72c479b2877..71f8642afd4 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -70,7 +70,6 @@ static SpaceLink *buttons_new(const bContext *C)
sbuts= MEM_callocN(sizeof(SpaceButs), "initbuts");
sbuts->spacetype= SPACE_BUTS;
- sbuts->scaflag= BUTS_SENS_LINK|BUTS_SENS_ACT|BUTS_CONT_ACT|BUTS_ACT_ACT|BUTS_ACT_LINK;
sbuts->align= BUT_AUTO;
/* header */
@@ -139,41 +138,44 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl)
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar)
{
+ ListBase *keymap;
+
ED_region_panels_init(wm, ar);
+
+ keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0);
+ WM_event_add_keymap_handler(&ar->handlers, keymap);
}
static void buttons_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
int vertical= (sbuts->align == BUT_VERTICAL);
buttons_context_compute(C, sbuts);
if(sbuts->mainb == BCONTEXT_SCENE)
- ED_region_panels(C, ar, vertical, "scene");
+ ED_region_panels(C, ar, vertical, "scene", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_WORLD)
- ED_region_panels(C, ar, vertical, "world");
+ ED_region_panels(C, ar, vertical, "world", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_OBJECT)
- ED_region_panels(C, ar, vertical, "object");
+ ED_region_panels(C, ar, vertical, "object", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_DATA)
- ED_region_panels(C, ar, vertical, "data");
+ ED_region_panels(C, ar, vertical, "data", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_MATERIAL)
- ED_region_panels(C, ar, vertical, "material");
+ ED_region_panels(C, ar, vertical, "material", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_TEXTURE)
- ED_region_panels(C, ar, vertical, "texture");
+ ED_region_panels(C, ar, vertical, "texture", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_PARTICLE)
- ED_region_panels(C, ar, vertical, "particle");
+ ED_region_panels(C, ar, vertical, "particle", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_PHYSICS)
- ED_region_panels(C, ar, vertical, "physics");
+ ED_region_panels(C, ar, vertical, "physics", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_BONE)
- ED_region_panels(C, ar, vertical, "bone");
+ ED_region_panels(C, ar, vertical, "bone", sbuts->mainb);
else if(sbuts->mainb == BCONTEXT_MODIFIER)
- ED_region_panels(C, ar, vertical, "modifier");
+ ED_region_panels(C, ar, vertical, "modifier", sbuts->mainb);
else if (sbuts->mainb == BCONTEXT_CONSTRAINT)
- ED_region_panels(C, ar, vertical, "constraint");
- else if (sbuts->mainb == BCONTEXT_GAME)
- ED_region_panels(C, ar, vertical, "game");
+ ED_region_panels(C, ar, vertical, "constraint", sbuts->mainb);
sbuts->re_align= 0;
sbuts->mainbo= sbuts->mainb;
@@ -205,11 +207,16 @@ void buttons_operatortypes(void)
WM_operatortype_append(SCENE_OT_render_layer_add);
WM_operatortype_append(SCENE_OT_render_layer_remove);
+
+ WM_operatortype_append(BUTTONS_OT_toolbox);
+ WM_operatortype_append(BUTTONS_OT_file_browse);
}
void buttons_keymap(struct wmWindowManager *wm)
{
+ ListBase *keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0);
+ WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
}
//#define PY_HEADER
@@ -261,7 +268,7 @@ static void buttons_context_area_init(wmWindowManager *wm, ARegion *ar)
static void buttons_context_area_draw(const bContext *C, ARegion *ar)
{
- SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
+ SpaceButs *sbuts= CTX_wm_space_buts(C);
uiStyle *style= U.uistyles.first;
uiBlock *block;
uiLayout *layout;
@@ -313,6 +320,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
switch(wmn->data) {
case ND_FRAME:
case ND_MODE:
+ case ND_RENDER_OPTIONS:
ED_area_tag_redraw(sa);
break;
@@ -394,7 +402,7 @@ void ED_spacetype_buttons(void)
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art->regionid = RGN_TYPE_HEADER;
- art->minsizey= HEADERY;
+ art->minsizey= BUTS_HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
art->init= buttons_header_area_init;