diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-09 21:39:19 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-09 21:39:19 +0400 |
commit | 9e7c4ce806b8d6dc532c40d5aeaa15dc708e2a10 (patch) | |
tree | c5f5e535222b2b5dd25e62dc5cbbc94be1052396 /source | |
parent | d4a69283a60ae8f9e834f48ef7c2f3f68b51b73d (diff) |
2.5: Layer Buttons
* Added RNA subtype for layers.
* Shift-click works again.
* uiItemR can now also handle armature/bone layers.
* Also makes Move to Layer popup work as expected.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 60 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_define.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 28 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_group.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 4 |
12 files changed, 93 insertions, 36 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a52afcb1a92..04d575d96d4 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -310,6 +310,30 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a return sub; } +static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) +{ + wmWindow *win= CTX_wm_window(C); + uiBut *but= arg_but, *cbut; + PointerRNA *ptr= &but->rnapoin; + PropertyRNA *prop= but->rnaprop; + int i, index= GET_INT_FROM_POINTER(arg_index); + int shift= win->eventstate->shift; + int len= RNA_property_array_length(ptr, prop); + + if(!shift) { + RNA_property_boolean_set_index(ptr, prop, index, 1); + + for(i=0; i<len; i++) + if(i != index) + RNA_property_boolean_set_index(ptr, prop, i, 0); + + RNA_property_update(C, ptr, prop); + + for(cbut=but->block->buttons.first; cbut; cbut=cbut->next) + ui_check_but(cbut); + } +} + /* create buttons for an item with an RNA array */ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider) { @@ -318,7 +342,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon PropertyType type; PropertySubType subtype; uiLayout *sub; - int a; + int a, b; /* retrieve type and subtype */ type= RNA_property_type(prop); @@ -332,9 +356,11 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); /* create buttons */ - if(type == PROP_BOOLEAN && len == 20) { + if(type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { /* special check for layer layout */ int butw, buth, unit; + int cols= (len >= 20)? 2: 1; + int colbuts= len/(2*cols); uiBlockSetCurLayout(block, uiLayoutFree(layout, 0)); @@ -342,21 +368,23 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon butw= unit; buth= unit; - uiBlockBeginAlign(block); - for(a=0; a<5; a++) - uiDefAutoButR(block, ptr, prop, a, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth); - for(a=0; a<5; a++) - uiDefAutoButR(block, ptr, prop, a+10, "", ICON_BLANK1, x + butw*a, y, butw, buth); - uiBlockEndAlign(block); + for(b=0; b<cols; b++) { + uiBlockBeginAlign(block); - x += 5*butw + style->buttonspacex; + for(a=0; a<colbuts; a++) { + but= uiDefAutoButR(block, ptr, prop, a+b*colbuts, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth); + if(subtype == PROP_LAYER_MEMBER) + uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+b*colbuts)); + } + for(a=0; a<colbuts; a++) { + but= uiDefAutoButR(block, ptr, prop, a+len/2+b*colbuts, "", ICON_BLANK1, x + butw*a, y, butw, buth); + if(subtype == PROP_LAYER_MEMBER) + uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+len/2+b*colbuts)); + } + uiBlockEndAlign(block); - uiBlockBeginAlign(block); - for(a=0; a<5; a++) - uiDefAutoButR(block, ptr, prop, a+5, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth); - for(a=0; a<5; a++) - uiDefAutoButR(block, ptr, prop, a+15, "", ICON_BLANK1, x + butw*a, y, butw, buth); - uiBlockEndAlign(block); + x += colbuts*butw + style->buttonspacex; + } } else if(subtype == PROP_MATRIX) { /* matrix layout */ @@ -784,7 +812,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA if(!name[0] && icon == 0) h= 0; - if(type == PROP_BOOLEAN && len == 20) + if(ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) h += 2*UI_UNIT_Y; else if(subtype == PROP_MATRIX) h += ceil(sqrt(len))*UI_UNIT_Y; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 6fe01cced74..12cb2b95e06 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1037,8 +1037,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_boolean_array(ot->srna, "layer", 20, NULL, "Layer", ""); - /* XXX boolean layer subtype, behavior */ + RNA_def_boolean_layer_member(ot->srna, "layer", 20, NULL, "Layer", ""); } /************************** Link to Scene Operator *****************************/ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 1c6837bbcc8..03b12da1629 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -72,6 +72,8 @@ typedef void StructOrFunctionRNA; PropertyRNA *RNA_def_boolean(StructOrFunctionRNA *cont, const char *identifier, int default_value, const char *ui_name, const char *ui_description); PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); +PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); +PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description); PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index b57cbc3aa2c..c6fed5cd8e6 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -111,6 +111,10 @@ typedef enum PropertySubType { /* pointers */ PROP_NEVER_NULL = 30, + + /* booleans */ + PROP_LAYER = 40, + PROP_LAYER_MEMBER = 41 } PropertySubType; typedef enum PropertyFlag { diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 907eba4018f..cbfd7d326de 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1394,6 +1394,8 @@ static const char *rna_property_subtypename(PropertyType type) case PROP_XYZ: return "PROP_XYZ"; case PROP_RGB: return "PROP_RGB"; case PROP_NEVER_NULL: return "PROP_NEVER_NULL"; + case PROP_LAYER: return "PROP_LAYER"; + case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER"; default: { /* incase we dont have a type preset that includes the subtype */ if(RNA_SUBTYPE_UNIT(type)) { diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 3f4b75508fe..57eb3c1de4a 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -325,7 +325,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); /* flags */ - prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); RNA_def_property_array(prop, 16); if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_layer_get", "rna_EditBone_layer_set"); @@ -569,7 +569,7 @@ void rna_def_armature(BlenderRNA *brna) /* Boolean values */ /* layer */ - prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); RNA_def_property_array(prop, 16); RNA_def_property_ui_text(prop, "Visible Layers", "Armature layer visibility."); @@ -578,7 +578,7 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* layer protection */ - prop= RNA_def_property(srna, "layer_protection", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "layer_protection", PROP_BOOLEAN, PROP_LAYER); RNA_def_property_boolean_sdna(prop, NULL, "layer_protected", 1); RNA_def_property_array(prop, 16); RNA_def_property_ui_text(prop, "Layer Proxy Protection", "Protected layers in Proxy Instances are restored to Proxy settings on file reload and undo."); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index e415304ab6c..00cfb17dc84 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1953,6 +1953,34 @@ PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont_, const char *ident return prop; } +PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value, + const char *ui_name, const char *ui_description) +{ + ContainerRNA *cont= cont_; + PropertyRNA *prop; + + prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER); + if(len != 0) RNA_def_property_array(prop, len); + if(default_value) RNA_def_property_boolean_array_default(prop, default_value); + RNA_def_property_ui_text(prop, ui_name, ui_description); + + return prop; +} + +PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value, + const char *ui_name, const char *ui_description) +{ + ContainerRNA *cont= cont_; + PropertyRNA *prop; + + prop= RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER_MEMBER); + if(len != 0) RNA_def_property_array(prop, len); + if(default_value) RNA_def_property_boolean_array_default(prop, default_value); + RNA_def_property_ui_text(prop, ui_name, ui_description); + + return prop; +} + PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, int *default_value, const char *ui_name, const char *ui_description) { diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 18c04fbfb50..31bc6ccc74b 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -63,7 +63,7 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects."); RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, 0, 0); - prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER); RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli."); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f81b314de6f..ce65ef4d450 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1073,7 +1073,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mode", "Object interaction mode."); - prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Layers", "Layers the object is on."); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 57ed5ccef39..b1644405ff3 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -798,6 +798,8 @@ static void rna_def_property(BlenderRNA *brna) {PROP_XYZ, "XYZ", 0, "XYZ", ""}, {PROP_RGB, "RGB", 0, "RGB", ""}, {PROP_NEVER_NULL, "NEVER_NULL", 0, "Never Null", ""}, + {PROP_LAYER, "LAYER", 0, "Layer", ""}, + {PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem unit_items[] = { {PROP_UNIT_NONE, "NONE", 0, "None", ""}, diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f196001cc9d..965796c6d5b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -363,12 +363,6 @@ static void rna_SceneRenderLayer_layer_set(PointerRNA *ptr, const int *values) rl->lay= layer_set(rl->lay, values); } -static void rna_SceneRenderLayer_zmask_layer_set(PointerRNA *ptr, const int *values) -{ - SceneRenderLayer *rl= (SceneRenderLayer*)ptr->data; - rl->lay_zmask= layer_set(rl->lay_zmask, values); -} - static void rna_SceneRenderLayer_pass_update(bContext *C, PointerRNA *ptr) { Scene *scene= (Scene*)ptr->id.data; @@ -597,7 +591,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) else RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* layers */ - prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Visible Layers", "Scene layers included in this render layer."); @@ -606,12 +600,10 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop= RNA_def_property(srna, "zmask_layers", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "zmask_layers", PROP_BOOLEAN, PROP_LAYER); RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers."); - if(scene) RNA_def_property_boolean_funcs(prop, NULL, "rna_SceneRenderLayer_zmask_layer_set"); - else RNA_def_property_boolean_funcs(prop, NULL, "rna_RenderLayer_zmask_layer_set"); if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1940,7 +1932,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0); /* Layers */ - prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible when rendering the scene."); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8cf47f0c682..7152d5bcfa2 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -531,7 +531,7 @@ int WM_operator_winactive(bContext *C) } /* op->invoke */ -static void redo_cb(bContext *C, void *arg_op, void *arg2) +static void redo_cb(bContext *C, void *arg_op, int event) { wmOperator *lastop= arg_op; @@ -553,7 +553,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); - uiBlockSetFunc(block, redo_cb, arg_op, NULL); + uiBlockSetHandleFunc(block, redo_cb, arg_op); if(!op->properties) { IDPropertyTemplate val = {0}; |