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/makesdna/DNA_screen_types.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/makesdna/DNA_screen_types.h')
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 8497d363179..07cba2bad1c 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -132,7 +132,9 @@ typedef struct ScrAreaMap { typedef struct Panel_Runtime { /* Applied to Panel.ofsx, but saved separately so we can track changes between redraws. */ int region_ofsx; - char _pad[4]; + + /* For instanced panels: Index of the list item the panel corresponds to. */ + int list_index; } Panel_Runtime; /** The part from uiBlock that needs saved in file. */ @@ -531,6 +533,8 @@ enum { PNL_OVERLAP = (1 << 4), PNL_PIN = (1 << 5), PNL_POPOVER = (1 << 6), + /** The panel has been drag-drop reordered and the instanced panel list needs to be rebuilt. */ + PNL_INSTANCED_LIST_ORDER_CHANGED = (1 << 7), }; /** #Panel.snap - for snapping to screen edges */ @@ -543,9 +547,17 @@ enum { /* #define PNL_SNAP_DIST 9.0 */ /* paneltype flag */ -#define PNL_DEFAULT_CLOSED 1 -#define PNL_NO_HEADER 2 -#define PNL_LAYOUT_VERT_BAR 4 +enum { + PNL_DEFAULT_CLOSED = (1 << 0), + PNL_NO_HEADER = (1 << 1), + /** Makes buttons in the header shrink/stretch to fill full layout width. */ + PNL_LAYOUT_HEADER_EXPAND = (1 << 2), + PNL_LAYOUT_VERT_BAR = (1 << 3), + /** This panel type represents data external to the UI. */ + PNL_INSTANCED = (1 << 4), + /** Draw panel like a box widget. */ + PNL_DRAW_BOX = (1 << 6), +}; /* Fallback panel category (only for old scripts which need updating) */ #define PNL_CATEGORY_FALLBACK "Misc" |