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:
authorHans Goudey <h.goudey@me.com>2020-07-03 18:58:43 +0300
committerHans Goudey <h.goudey@me.com>2020-07-03 18:58:43 +0300
commita21cb22f8b12ea73937e7e6eda8465f1cba02b6e (patch)
tree17fa94d2e1a22f8c0ece10b4a680a39784aae981 /source/blender/gpencil_modifiers
parent33a74941c5fd4efb6eefcaace3315d3e2b65681f (diff)
Cleanup: Deduplicate code for finding context object
Instead of manually checking the pinned object, use the existing ED_object_active_context function. This requires adding const to the context in that function.
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
index c15bef1f748..a9afbc4b6ae 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
@@ -34,7 +34,6 @@
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
#include "ED_object.h"
@@ -50,23 +49,12 @@
#include "MOD_gpencil_ui_common.h" /* Self include */
-static Object *get_gpencilmodifier_object(const bContext *C)
-{
- SpaceProperties *sbuts = CTX_wm_space_properties(C);
- if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) {
- return (Object *)sbuts->pinid;
- }
- else {
- return CTX_data_active_object(C);
- }
-}
-
/**
* Poll function so these modifier panels only show for grease pencil objects.
*/
static bool gpencil_modifier_ui_poll(const bContext *C, PanelType *UNUSED(pt))
{
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
return (ob != NULL) && (ob->type == OB_GPENCIL);
}
@@ -80,7 +68,7 @@ static bool gpencil_modifier_ui_poll(const bContext *C, PanelType *UNUSED(pt))
*/
static void gpencil_modifier_reorder(bContext *C, Panel *panel, int new_index)
{
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
PointerRNA props_ptr;
@@ -94,7 +82,7 @@ static void gpencil_modifier_reorder(bContext *C, Panel *panel, int new_index)
static short get_gpencil_modifier_expand_flag(const bContext *C, Panel *panel)
{
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
return md->ui_expand_flag;
return 0;
@@ -102,7 +90,7 @@ static short get_gpencil_modifier_expand_flag(const bContext *C, Panel *panel)
static void set_gpencil_modifier_expand_flag(const bContext *C, Panel *panel, short expand_flag)
{
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
md->ui_expand_flag = expand_flag;
}
@@ -245,7 +233,7 @@ void gpencil_modifier_panel_get_property_pointers(const bContext *C,
PointerRNA *r_ob_ptr,
PointerRNA *r_md_ptr)
{
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, r_md_ptr);
@@ -269,7 +257,7 @@ static void gpencil_modifier_ops_extra_draw(bContext *C, uiLayout *layout, void
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
PointerRNA ptr;
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
uiLayoutSetContextPointer(layout, "modifier", &ptr);
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
@@ -328,7 +316,7 @@ static void gpencil_modifier_panel_header(const bContext *C, Panel *panel)
uiLayout *row, *sub;
uiLayout *layout = panel->layout;
- Object *ob = get_gpencilmodifier_object(C);
+ Object *ob = ED_object_active_context(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
PointerRNA ptr;
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);