diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 132 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 44 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 99 |
3 files changed, 187 insertions, 88 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 16256f6c97e..5885d3dcbb0 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -101,7 +101,7 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) /************************* Creating the Path ************************/ -static int buttons_context_path_scene(ButsContextPath *path) +static bool buttons_context_path_scene(ButsContextPath *path) { PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -162,14 +162,14 @@ static int buttons_context_path_world(ButsContextPath *path) return 0; } -static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window) +static bool buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window) { FreestyleLineStyle *linestyle; PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) linestyle, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_FreestyleLineStyle)) { - return 1; + return true; } /* if we have a view layer, use the lineset's linestyle */ if (buttons_context_path_view_layer(path, window)) { @@ -178,24 +178,24 @@ static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow *windo if (linestyle) { RNA_id_pointer_create(&linestyle->id, &path->ptr[path->len]); path->len++; - return 1; + return true; } } /* no path to a linestyle possible */ - return 0; + return false; } -static int buttons_context_path_object(ButsContextPath *path) +static bool buttons_context_path_object(ButsContextPath *path) { PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) object, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Object)) { - return 1; + return true; } if (!RNA_struct_is_a(ptr->type, &RNA_ViewLayer)) { - return 0; + return false; } ViewLayer *view_layer = ptr->data; @@ -205,58 +205,58 @@ static int buttons_context_path_object(ButsContextPath *path) RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); path->len++; - return 1; + return true; } /* no path to a object possible */ - return 0; + return false; } -static int buttons_context_path_data(ButsContextPath *path, int type) +static bool buttons_context_path_data(ButsContextPath *path, int type) { Object *ob; PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Hair) && (type == -1 || type == OB_HAIR)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_PointCloud) && (type == -1 || type == OB_POINTCLOUD)) { - return 1; + return true; } if (RNA_struct_is_a(ptr->type, &RNA_Volume) && (type == -1 || type == OB_VOLUME)) { - return 1; + return true; } /* try to get an object in the path, no pinning supported here */ if (buttons_context_path_object(path)) { @@ -266,15 +266,15 @@ static int buttons_context_path_data(ButsContextPath *path, int type) RNA_id_pointer_create(ob->data, &path->ptr[path->len]); path->len++; - return 1; + return true; } } /* no path to data possible */ - return 0; + return false; } -static int buttons_context_path_modifier(ButsContextPath *path) +static bool buttons_context_path_modifier(ButsContextPath *path) { Object *ob; @@ -291,14 +291,14 @@ static int buttons_context_path_modifier(ButsContextPath *path) OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) { - return 1; + return true; } } - return 0; + return false; } -static int buttons_context_path_shaderfx(ButsContextPath *path) +static bool buttons_context_path_shaderfx(ButsContextPath *path) { Object *ob; @@ -306,14 +306,14 @@ static int buttons_context_path_shaderfx(ButsContextPath *path) ob = path->ptr[path->len - 1].data; if (ob && ELEM(ob->type, OB_GPENCIL)) { - return 1; + return true; } } - return 0; + return false; } -static int buttons_context_path_material(ButsContextPath *path) +static bool buttons_context_path_material(ButsContextPath *path) { Object *ob; PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -321,7 +321,7 @@ static int buttons_context_path_material(ButsContextPath *path) /* if we already have a (pinned) material, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Material)) { - return 1; + return true; } /* if we have an object, use the object material slot */ if (buttons_context_path_object(path)) { @@ -331,15 +331,15 @@ static int buttons_context_path_material(ButsContextPath *path) ma = BKE_object_material_get(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; - return 1; + return true; } } /* no path to a material possible */ - return 0; + return false; } -static int buttons_context_path_bone(ButsContextPath *path) +static bool buttons_context_path_bone(ButsContextPath *path) { bArmature *arm; EditBone *edbo; @@ -353,29 +353,29 @@ static int buttons_context_path_bone(ButsContextPath *path) edbo = arm->act_edbone; RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); path->len++; - return 1; + return true; } } else { if (arm->act_bone) { RNA_pointer_create(&arm->id, &RNA_Bone, arm->act_bone, &path->ptr[path->len]); path->len++; - return 1; + return true; } } } /* no path to a bone possible */ - return 0; + return false; } -static int buttons_context_path_pose_bone(ButsContextPath *path) +static bool buttons_context_path_pose_bone(ButsContextPath *path) { PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) PoseBone, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { - return 1; + return true; } /* if we have an armature, get the active bone */ @@ -384,7 +384,7 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) bArmature *arm = ob->data; /* path->ptr[path->len-1].data - works too */ if (ob->type != OB_ARMATURE || arm->edbo) { - return 0; + return false; } if (arm->act_bone) { @@ -392,16 +392,16 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; - return 1; + return true; } } } /* no path to a bone possible */ - return 0; + return false; } -static int buttons_context_path_particle(ButsContextPath *path) +static bool buttons_context_path_particle(ButsContextPath *path) { Object *ob; ParticleSystem *psys; @@ -409,7 +409,7 @@ static int buttons_context_path_particle(ButsContextPath *path) /* if we already have (pinned) particle settings, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { - return 1; + return true; } /* if we have an object, get the active particle system */ if (buttons_context_path_object(path)) { @@ -420,15 +420,15 @@ static int buttons_context_path_particle(ButsContextPath *path) RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); path->len++; - return 1; + return true; } } /* no path to a particle system possible */ - return 0; + return false; } -static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) +static bool buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; Brush *br = NULL; @@ -436,7 +436,7 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) /* if we already have a (pinned) brush, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { - return 1; + return true; } /* if we have a scene, use the toolsettings brushes */ if (buttons_context_path_scene(path)) { @@ -452,32 +452,32 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); path->len++; - return 1; + return true; } } /* no path to a brush possible */ - return 0; + return false; } -static int buttons_context_path_texture(const bContext *C, - ButsContextPath *path, - ButsContextTexture *ct) +static bool buttons_context_path_texture(const bContext *C, + ButsContextPath *path, + ButsContextTexture *ct) { PointerRNA *ptr = &path->ptr[path->len - 1]; ID *id; if (!ct) { - return 0; + return false; } /* if we already have a (pinned) texture, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Texture)) { - return 1; + return true; } if (!ct->user) { - return 0; + return false; } id = ct->user->id; @@ -502,7 +502,7 @@ static int buttons_context_path_texture(const bContext *C, path->len++; } - return 1; + return true; } #ifdef WITH_FREESTYLE @@ -531,7 +531,7 @@ static bool buttons_context_linestyle_pinnable(const bContext *C, ViewLayer *vie } #endif -static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) +static bool buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { /* Note we don't use CTX_data here, instead we get it from the window. * Otherwise there is a loop reading the context that we are setting. */ @@ -626,27 +626,27 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_pose_bone(path); break; default: - found = 0; + found = false; break; } return found; } -static int buttons_shading_context(const bContext *C, int mainb) +static bool buttons_shading_context(const bContext *C, int mainb) { wmWindow *window = CTX_wm_window(C); ViewLayer *view_layer = WM_window_get_active_view_layer(window); Object *ob = OBACT(view_layer); if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) { - return 1; + return true; } if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) { - return 1; + return true; } - return 0; + return false; } static int buttons_shading_new_context(const bContext *C, int flag) diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 733f344fbc6..a062b178fc8 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -52,7 +52,9 @@ #include "buttons_intern.h" /* own include */ -/********************** context_menu operator *********************/ +/* -------------------------------------------------------------------- */ +/** \name Context Menu Operator + * \{ */ static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { @@ -67,17 +69,21 @@ static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven void BUTTONS_OT_context_menu(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Context Menu"; ot->description = "Display properties editor context_menu"; ot->idname = "BUTTONS_OT_context_menu"; - /* api callbacks */ + /* Callbacks. */ ot->invoke = context_menu_invoke; ot->poll = ED_operator_buttons_active; } -/********************** filebrowse operator *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name File Browse Operator + * \{ */ typedef struct FileBrowseOp { PointerRNA ptr; @@ -101,7 +107,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); - /* add slash for directories, important for some properties */ + /* Add slash for directories, important for some properties. */ if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { const bool is_relative = RNA_boolean_get(op->ptr, "relative_path"); id = fbo->ptr.owner_id; @@ -110,7 +116,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) BLI_path_abs(path, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain)); if (BLI_is_dir(path)) { - /* do this first so '//' isnt converted to '//\' on windows */ + /* Do this first so '//' isnt converted to '//\' on windows. */ BLI_path_slash_ensure(path); if (is_relative) { BLI_strncpy(path, str, FILE_MAX); @@ -139,7 +145,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) ED_undo_push(C, undostr); } - /* special, annoying exception, filesel on redo panel [#26618] */ + /* Special annoying exception, filesel on redo panel [#26618]. */ { wmOperator *redo_op = WM_operator_last_redo(C); if (redo_op) { @@ -187,8 +193,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); - /* useful yet irritating feature, Shift+Click to open the file - * Alt+Click to browse a folder in the OS's browser */ + /* Useful yet irritating feature, Shift+Click to open the file + * Alt+Click to browse a folder in the OS's browser. */ if (event->shift || event->alt) { wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); PointerRNA props_ptr; @@ -219,13 +225,13 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) fbo->is_userdef = is_userdef; op->customdata = fbo; - /* normally ED_fileselect_get_params would handle this but we need to because of stupid - * user-prefs exception - campbell */ + /* Normally ED_fileselect_get_params would handle this but we need to because of stupid + * user-prefs exception. - campbell */ if ((prop_relpath = RNA_struct_find_property(op->ptr, "relative_path"))) { if (!RNA_property_is_set(op->ptr, prop_relpath)) { bool is_relative = (U.flag & USER_RELPATHS) != 0; - /* while we want to follow the defaults, + /* While we want to follow the defaults, * we better not switch existing paths relative/absolute state. */ if (str[0]) { is_relative = BLI_path_is_rel(str); @@ -235,7 +241,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) is_relative = false; } - /* annoying exception!, if we're dealing with the user prefs, default relative to be off */ + /* Annoying exception!, if we're dealing with the user prefs, default relative to be off. */ RNA_property_boolean_set(op->ptr, prop_relpath, is_relative); } } @@ -250,21 +256,21 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) void BUTTONS_OT_file_browse(wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Accept"; ot->description = "Open a file browser, Hold Shift to open the file, Alt to browse containing directory"; ot->idname = "BUTTONS_OT_file_browse"; - /* api callbacks */ + /* Callbacks. */ ot->invoke = file_browse_invoke; ot->exec = file_browse_exec; ot->cancel = file_browse_cancel; - /* conditional undo based on button flag */ + /* Conditional undo based on button flag. */ ot->flag = 0; - /* properties */ + /* Properties. */ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, @@ -274,7 +280,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) FILE_SORT_ALPHA); } -/* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ +/* Second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY. */ void BUTTONS_OT_directory_browse(wmOperatorType *ot) { /* identifiers */ @@ -300,3 +306,5 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); } + +/** \} */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index ac59bb245f3..dc34e56dc92 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -35,6 +35,7 @@ #include "BKE_screen.h" #include "BKE_shader_fx.h" +#include "ED_buttons.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" /* To draw toolbar UI. */ @@ -49,13 +50,11 @@ #include "UI_resources.h" -#include "GPU_glew.h" - #include "buttons_intern.h" /* own include */ /* ******************** default callbacks for buttons space ***************** */ -static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) +static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { ARegion *region; SpaceProperties *sbuts; @@ -139,6 +138,98 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region) WM_event_add_keymap_handler(®ion->handlers, keymap); } +/** + * Fills an array with the tab context values for the properties editor. -1 signals a separator. + * + * \return The total number of items in the array returned. + */ +int ED_buttons_tabs_list(SpaceProperties *sbuts, int *context_tabs_array) +{ + int length = 0; + if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) { + context_tabs_array[length] = BCONTEXT_TOOL; + length++; + } + if (length != 0) { + context_tabs_array[length] = -1; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) { + context_tabs_array[length] = BCONTEXT_RENDER; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_OUTPUT)) { + context_tabs_array[length] = BCONTEXT_OUTPUT; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_VIEW_LAYER)) { + context_tabs_array[length] = BCONTEXT_VIEW_LAYER; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_SCENE)) { + context_tabs_array[length] = BCONTEXT_SCENE; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { + context_tabs_array[length] = BCONTEXT_WORLD; + length++; + } + if (length != 0) { + context_tabs_array[length] = -1; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { + context_tabs_array[length] = BCONTEXT_OBJECT; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_MODIFIER)) { + context_tabs_array[length] = BCONTEXT_MODIFIER; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_SHADERFX)) { + context_tabs_array[length] = BCONTEXT_SHADERFX; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_PARTICLE)) { + context_tabs_array[length] = BCONTEXT_PARTICLE; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_PHYSICS)) { + context_tabs_array[length] = BCONTEXT_PHYSICS; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_CONSTRAINT)) { + context_tabs_array[length] = BCONTEXT_CONSTRAINT; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_DATA)) { + context_tabs_array[length] = BCONTEXT_DATA; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_BONE)) { + context_tabs_array[length] = BCONTEXT_BONE; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_BONE_CONSTRAINT)) { + context_tabs_array[length] = BCONTEXT_BONE_CONSTRAINT; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_MATERIAL)) { + context_tabs_array[length] = BCONTEXT_MATERIAL; + length++; + } + if (length != 0) { + context_tabs_array[length] = -1; + length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_TEXTURE)) { + context_tabs_array[length] = BCONTEXT_TEXTURE; + length++; + } + + return length; +} + static void buttons_main_region_layout_properties(const bContext *C, SpaceProperties *sbuts, ARegion *region) @@ -618,7 +709,7 @@ void ED_spacetype_buttons(void) st->spaceid = SPACE_PROPERTIES; strncpy(st->name, "Buttons", BKE_ST_MAXNAME); - st->new = buttons_new; + st->create = buttons_create; st->free = buttons_free; st->init = buttons_init; st->duplicate = buttons_duplicate; |