diff options
author | Hans Goudey <h.goudey@me.com> | 2020-05-26 22:39:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-05-26 22:39:49 +0300 |
commit | 5171d86806a338aa885cdddf3ad83dfcf15c40aa (patch) | |
tree | 00fd7c3fc9c245485f742c73a175cf6c9a0adb30 /source/blender/editors/include/UI_interface.h | |
parent | de257b6366455ba6a3604c0830a92245df11f7bc (diff) |
UI: List Panel System
This implements a general system to implement drag and drop, subpanels,
and UI animation for the stack UIs in Blender. There are NO functional
changes in this patch, but it makes it relatively trivial to implement
these features for stacks.
The biggest complication to using panels to implement the UI for lists
is that there can be multiple modifiers of the same type. Currently there
is an assumed 1 to 1 relationship between every panel and its type, but
there can be multiple list items of the same type, so we have to break
this relationship. The mapping between panels and their data is stored
with an index in the panel's runtime struct.
To make use the system for a list like modifiers, four components
must be added:
1. A panel type defined and registered for each list data type, with a
known mapping between list data types and panel idnames.
1. A function called by interface code to build the add the panel
layouts with the provided helper functions.
- UI_panel_list_matches_data will check if the panel list needs to
be rebuilt.
- UI_panels_free_instanced will remove the existing list panels
- UI_panel_add_instanced adds a list panel of a given type.
3. An expand flag for the list data and implementations of
get_list_data_expand_flag and set_list_data_expand_flag.
4. For reordering, the panel type's reorder callback. This is called
when the instanced panels are drag-dropped. This requires
implementing a "move to index" operator for the list data.
Reviewed By: Severin, brecht
Differential Revision: https://developer.blender.org/D7490
Diffstat (limited to 'source/blender/editors/include/UI_interface.h')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 3ad1608b47b..c95f517b155 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -239,6 +239,8 @@ enum { #define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f) +#define UI_PANEL_BOX_STYLE_MARGIN (U.widget_unit * 0.2f) + /* but->drawflag - these flags should only affect how the button is drawn. */ /* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions * (except for the 'align' ones)! @@ -1679,6 +1681,7 @@ void UI_panel_end(const struct ScrArea *area, int width, int height, bool open); + void UI_panels_scale(struct ARegion *region, float new_width); void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); int UI_panel_size_y(const struct Panel *panel); @@ -1702,6 +1705,24 @@ 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); +/* Polyinstantiated panels for representing a list of data. */ +struct Panel *UI_panel_add_instanced(struct ScrArea *area, + struct ARegion *region, + struct ListBase *panels, + char *panel_idname, + int list_index); +void UI_panels_free_instanced(struct bContext *C, struct ARegion *region); + +#define LIST_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); + +typedef void (*uiListPanelIDFromDataFunc)(void *data_link, char *r_idname); +bool UI_panel_list_matches_data(struct ARegion *region, + struct ListBase *data, + uiListPanelIDFromDataFunc panel_idname_func); + /* Handlers * * Handlers that can be registered in regions, areas and windows for |