diff options
Diffstat (limited to 'source/blender/shader_fx/intern/FX_ui_common.c')
-rw-r--r-- | source/blender/shader_fx/intern/FX_ui_common.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/source/blender/shader_fx/intern/FX_ui_common.c b/source/blender/shader_fx/intern/FX_ui_common.c index 952a6df560b..a76f97d7baa 100644 --- a/source/blender/shader_fx/intern/FX_ui_common.c +++ b/source/blender/shader_fx/intern/FX_ui_common.c @@ -56,9 +56,9 @@ */ static void shaderfx_reorder(bContext *C, Panel *panel, int new_index) { - Object *ob = ED_object_active_context(C); + PointerRNA *fx_ptr = UI_panel_custom_data_get(panel); + ShaderFxData *fx = (ShaderFxData *)fx_ptr->data; - ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); PointerRNA props_ptr; wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_shaderfx_move_to_index", false); WM_operator_properties_create_ptr(&props_ptr, ot); @@ -71,20 +71,20 @@ static void shaderfx_reorder(bContext *C, Panel *panel, int new_index) /** * Get the expand flag from the active effect to use for the panel. */ -static short get_shaderfx_expand_flag(const bContext *C, Panel *panel) +static short get_shaderfx_expand_flag(const bContext *UNUSED(C), Panel *panel) { - Object *ob = ED_object_active_context(C); - ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); + PointerRNA *fx_ptr = UI_panel_custom_data_get(panel); + ShaderFxData *fx = (ShaderFxData *)fx_ptr->data; return fx->ui_expand_flag; } /** * Save the expand flag for the panel and sub-panels to the effect. */ -static void set_shaderfx_expand_flag(const bContext *C, Panel *panel, short expand_flag) +static void set_shaderfx_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) { - Object *ob = ED_object_active_context(C); - ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); + PointerRNA *fx_ptr = UI_panel_custom_data_get(panel); + ShaderFxData *fx = (ShaderFxData *)fx_ptr->data; fx->ui_expand_flag = expand_flag; } @@ -109,34 +109,30 @@ void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr) /** * Gets RNA pointers for the active object and the panel's shaderfx data. */ -void shaderfx_panel_get_property_pointers(const bContext *C, - Panel *panel, - PointerRNA *r_ob_ptr, - PointerRNA *r_md_ptr) +PointerRNA *shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr) { - Object *ob = ED_object_active_context(C); - ShaderFxData *md = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); - - RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, r_md_ptr); + PointerRNA *ptr = UI_panel_custom_data_get(panel); + BLI_assert(RNA_struct_is_a(ptr->type, &RNA_ShaderFx)); if (r_ob_ptr != NULL) { - RNA_pointer_create(&ob->id, &RNA_Object, ob, r_ob_ptr); + RNA_pointer_create(ptr->owner_id, &RNA_Object, ptr->owner_id, r_ob_ptr); } - uiLayoutSetContextPointer(panel->layout, "shaderfx", r_md_ptr); + uiLayoutSetContextPointer(panel->layout, "shaderfx", ptr); + + return ptr; } #define ERROR_LIBDATA_MESSAGE TIP_("External library data") -static void shaderfx_panel_header(const bContext *C, Panel *panel) +static void shaderfx_panel_header(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; bool narrow_panel = (panel->sizex < UI_UNIT_X * 7 && panel->sizex != 0); - PointerRNA ptr; - shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); - Object *ob = ED_object_active_context(C); - ShaderFxData *fx = (ShaderFxData *)ptr.data; + PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, NULL); + Object *ob = (Object *)ptr->owner_id; + ShaderFxData *fx = (ShaderFxData *)ptr->data; const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(fx->type); @@ -147,22 +143,22 @@ static void shaderfx_panel_header(const bContext *C, Panel *panel) if (fxti->isDisabled && fxti->isDisabled(fx, 0)) { uiLayoutSetRedAlert(row, true); } - uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); + uiItemL(row, "", RNA_struct_ui_icon(ptr->type)); /* Effect name. */ row = uiLayoutRow(layout, true); if (!narrow_panel) { - uiItemR(row, &ptr, "name", 0, "", ICON_NONE); + uiItemR(row, ptr, "name", 0, "", ICON_NONE); } /* Mode enabling buttons. */ if (fxti->flags & eShaderFxTypeFlag_SupportsEditmode) { uiLayout *sub = uiLayoutRow(row, true); uiLayoutSetActive(sub, false); - uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE); + uiItemR(sub, ptr, "show_in_editmode", 0, "", ICON_NONE); } - uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); - uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); + uiItemR(row, ptr, "show_viewport", 0, "", ICON_NONE); + uiItemR(row, ptr, "show_render", 0, "", ICON_NONE); row = uiLayoutRow(row, false); uiLayoutSetEmboss(row, UI_EMBOSS_NONE); |