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:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_interface.h5
-rw-r--r--source/blender/editors/interface/interface_panel.c30
-rw-r--r--source/blender/editors/interface/interface_templates.c30
-rw-r--r--source/blender/editors/screen/area.c6
4 files changed, 35 insertions, 36 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 4fc537ca5c2..01e3dd22648 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1698,6 +1698,8 @@ void UI_panel_category_draw_all(struct ARegion *region, const char *category_id_
struct PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname);
+/* Panel custom data. */
+struct PointerRNA *UI_panel_custom_data_get(const struct Panel *panel);
struct PointerRNA *UI_region_panel_custom_data_under_cursor(const struct bContext *C,
const struct wmEvent *event);
void UI_panel_custom_data_set(struct Panel *panel, struct PointerRNA *custom_data);
@@ -1706,11 +1708,10 @@ void UI_panel_custom_data_set(struct Panel *panel, struct PointerRNA *custom_dat
struct Panel *UI_panel_add_instanced(struct ARegion *region,
struct ListBase *panels,
char *panel_idname,
- int list_index,
struct PointerRNA *custom_data);
void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region);
-#define LIST_PANEL_UNIQUE_STR_LEN 4
+#define INSTANCED_PANEL_UNIQUE_STR_LEN 4
void UI_list_panel_unique_str(struct Panel *panel, char *r_name);
void UI_panel_set_expand_from_list_data(const struct bContext *C, struct Panel *panel);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index bc38e177cea..cf0bb8d4e8c 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -223,21 +223,19 @@ static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_panel_
static Panel *UI_panel_add_instanced_ex(ARegion *region,
ListBase *panels,
PanelType *panel_type,
- int list_index,
PointerRNA *custom_data)
{
Panel *panel = MEM_callocN(sizeof(Panel), "instanced panel");
panel->type = panel_type;
BLI_strncpy(panel->panelname, panel_type->idname, sizeof(panel->panelname));
- panel->runtime.list_index = list_index;
panel->runtime.custom_data_ptr = custom_data;
/* Add the panel's children too. Although they aren't instanced panels, we can still use this
* function to create them, as UI_panel_begin does other things we don't need to do. */
LISTBASE_FOREACH (LinkData *, child, &panel_type->children) {
PanelType *child_type = child->data;
- UI_panel_add_instanced_ex(region, &panel->children, child_type, list_index, custom_data);
+ UI_panel_add_instanced_ex(region, &panel->children, child_type, custom_data);
}
/* Make sure the panel is added to the end of the display-order as well. This is needed for
@@ -262,8 +260,10 @@ static Panel *UI_panel_add_instanced_ex(ARegion *region,
* Called in situations where panels need to be added dynamically rather than having only one panel
* corresponding to each #PanelType.
*/
-Panel *UI_panel_add_instanced(
- ARegion *region, ListBase *panels, char *panel_idname, int list_index, PointerRNA *custom_data)
+Panel *UI_panel_add_instanced(ARegion *region,
+ ListBase *panels,
+ char *panel_idname,
+ PointerRNA *custom_data)
{
ARegionType *region_type = region->type;
@@ -275,7 +275,7 @@ Panel *UI_panel_add_instanced(
return NULL;
}
- return UI_panel_add_instanced_ex(region, panels, panel_type, list_index, custom_data);
+ return UI_panel_add_instanced_ex(region, panels, panel_type, custom_data);
}
/**
@@ -284,7 +284,9 @@ Panel *UI_panel_add_instanced(
*/
void UI_list_panel_unique_str(Panel *panel, char *r_name)
{
- snprintf(r_name, LIST_PANEL_UNIQUE_STR_LEN, "%d", panel->runtime.list_index);
+ /* The panel sortorder will be unique for a specific panel type because the instanced
+ * panel list is regenerated for every change in the data order / length. */
+ snprintf(r_name, INSTANCED_PANEL_UNIQUE_STR_LEN, "%d", panel->sortorder);
}
/**
@@ -453,11 +455,6 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
}
MEM_freeN(panel_sort);
- /* Don't reorder the panel didn't change order after being dropped. */
- if (move_to_index == drag_panel->runtime.list_index) {
- return;
- }
-
/* Set the bit to tell the interface to instanced the list. */
drag_panel->flag |= PNL_INSTANCED_LIST_ORDER_CHANGED;
@@ -2482,6 +2479,11 @@ void UI_panel_custom_data_set(Panel *panel, PointerRNA *custom_data)
ui_panel_custom_data_set_recursive(panel, custom_data);
}
+PointerRNA *UI_panel_custom_data_get(const Panel *panel)
+{
+ return panel->runtime.custom_data_ptr;
+}
+
PointerRNA *UI_region_panel_custom_data_under_cursor(const bContext *C, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
@@ -2506,9 +2508,7 @@ PointerRNA *UI_region_panel_custom_data_under_cursor(const bContext *C, const wm
return NULL;
}
- PointerRNA *customdata = panel->runtime.custom_data_ptr;
-
- return customdata;
+ return UI_panel_custom_data_get(panel);
}
/** \} */
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8962755ea90..c27279ab744 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1882,7 +1882,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr);
- Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, i, md_ptr);
+ Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, md_ptr);
if (new_panel != NULL) {
UI_panel_set_expand_from_list_data(C, new_panel);
@@ -1967,10 +1967,11 @@ static ListBase *get_constraints(const bContext *C, bool use_bone_constraints)
*/
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
{
- const bool constraint_from_bone = constraint_panel_is_bone(panel);
- ListBase *lb = get_constraints(C, constraint_from_bone);
+ bool constraint_from_bone = constraint_panel_is_bone(panel);
+
+ PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
+ bConstraint *con = (bConstraint *)con_ptr->data;
- bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
PointerRNA props_ptr;
wmOperatorType *ot = WM_operatortype_find("CONSTRAINT_OT_move_to_index", false);
WM_operator_properties_create_ptr(&props_ptr, ot);
@@ -1985,24 +1986,21 @@ static void constraint_reorder(bContext *C, Panel *panel, int new_index)
/**
* Get the expand flag from the active constraint to use for the panel.
*/
-static short get_constraint_expand_flag(const bContext *C, Panel *panel)
+static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel)
{
- const bool constraint_from_bone = constraint_panel_is_bone(panel);
- ListBase *lb = get_constraints(C, constraint_from_bone);
+ PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
+ bConstraint *con = (bConstraint *)con_ptr->data;
- bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
return con->ui_expand_flag;
}
/**
* Save the expand flag for the panel and sub-panels to the constraint.
*/
-static void set_constraint_expand_flag(const bContext *C, Panel *panel, short expand_flag)
+static void set_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag)
{
- const bool constraint_from_bone = constraint_panel_is_bone(panel);
- ListBase *lb = get_constraints(C, constraint_from_bone);
-
- bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
+ PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
+ bConstraint *con = (bConstraint *)con_ptr->data;
con->ui_expand_flag = expand_flag;
}
@@ -2057,7 +2055,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr);
- Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, i, con_ptr);
+ Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, con_ptr);
if (new_panel) {
/* Set the list panel functionality function pointers since we don't do it with python. */
@@ -2138,7 +2136,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr);
- Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, i, md_ptr);
+ Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, md_ptr);
if (new_panel != NULL) {
UI_panel_set_expand_from_list_data(C, new_panel);
@@ -2220,7 +2218,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr);
- Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, i, fx_ptr);
+ Panel *new_panel = UI_panel_add_instanced(region, &region->panels, panel_idname, fx_ptr);
if (new_panel != NULL) {
UI_panel_set_expand_from_list_data(C, new_panel);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 921cc92299e..8ec58b4c75e 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2564,11 +2564,11 @@ static void ed_panel_draw(const bContext *C,
/* Draw panel. */
- char block_name[BKE_ST_MAXNAME + LIST_PANEL_UNIQUE_STR_LEN];
+ char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_LEN];
strncpy(block_name, pt->idname, BKE_ST_MAXNAME);
if (unique_panel_str != NULL) {
/* Instanced panels should have already been added at this point. */
- strncat(block_name, unique_panel_str, LIST_PANEL_UNIQUE_STR_LEN);
+ strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN);
}
uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS);
@@ -2837,7 +2837,7 @@ void ED_region_panels_layout_ex(const bContext *C,
/* Use a unique identifier for instanced panels, otherwise an old block for a different
* panel of the same type might be found. */
- char unique_panel_str[8];
+ char unique_panel_str[INSTANCED_PANEL_UNIQUE_STR_LEN];
UI_list_panel_unique_str(panel, unique_panel_str);
ed_panel_draw(C,
region,