From 5f6c45498c92b91a710a1317f6d41f73fbe83477 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 20 Apr 2018 17:14:03 +0200 Subject: UI: New Global Top-Bar (WIP) == Main Features/Changes for Users * Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars. * Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector. * Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here. * Individual sections of the topbar are individually scrollable. * Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting. * Top-bar should scale nicely with DPI. * The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes). * Info editors at the top of the window and using the full window width with be replaced by the top-bar. * In fullscreen modes, no more info editor is added on top, the top-bar replaces it. == Technical Features/Changes * Adds initial support for global areas A global area is part of the window, not part of the regular screen-layout. I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas. * Adds a TOPBAR editor type The editor type is hidden in the UI editor type menu. * Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY) * Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar. * Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds. The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved. * Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code. Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being. NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility. == ToDo's It's a bit hard to predict all the ToDo's here are the known main ones: * Add options for the new active-tool system and for operator redo to the topbar. * Automatically hide the top-bar in fullscreen modes. * General visual polish. * Top-bar drag & drop support (WIP in temp-tab_drag_drop). * Improve dynamic regions (should also fix some layout glitches). * Make internal terminology consistent. * Enable topbar file writing once design is more advanced. * Address TODO's and XXX's in code :) Thanks @brecht for the review! And @sergey for the complaining ;) Differential Revision: D2758 --- source/blender/makesdna/DNA_screen_types.h | 60 +++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) (limited to 'source/blender/makesdna/DNA_screen_types.h') diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 46eb0cbade3..6d4494ca2d2 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -48,12 +48,19 @@ struct wmTimer; struct wmTooltipState; +/* TODO Doing this is quite ugly :) + * Once the top-bar is merged bScreen should be refactored to use ScrAreaMap. */ +#define AREAMAP_FROM_SCREEN(screen) ((ScrAreaMap *)&(screen)->vertbase) + typedef struct bScreen { ID id; - + + /* TODO Should become ScrAreaMap now. + * ** NOTE: KEEP ORDER IN SYNC WITH ScrAreaMap! (see AREAMAP_FROM_SCREEN macro above) ** */ ListBase vertbase; /* screens have vertices/edges to define areas */ ListBase edgebase; ListBase areabase; + ListBase regionbase; /* screen level regions (menus), runtime only */ struct Scene *scene DNA_DEPRECATED; @@ -98,6 +105,14 @@ typedef struct ScrEdge { int pad; } ScrEdge; +typedef struct ScrAreaMap { + /* ** NOTE: KEEP ORDER IN SYNC WITH LISTBASES IN bScreen! ** */ + + ListBase vertbase; /* ScrVert - screens have vertices/edges to define areas */ + ListBase edgebase; /* ScrEdge */ + ListBase areabase; /* ScrArea */ +} ScrAreaMap; + typedef struct Panel { /* the part from uiBlock that needs saved in file */ struct Panel *next, *prev; @@ -211,6 +226,23 @@ typedef struct uiPreview { /* some preview UI data need to be saved in short pad1[3]; } uiPreview; +/* These two lines with # tell makesdna this struct can be excluded. + * Should be: #ifndef WITH_TOPBAR_WRITING */ +# +# +typedef struct ScrGlobalAreaData { + /* Global areas have a non-dynamic size. That means, changing the window + * size doesn't affect their size at all. However, they can still be + * 'collapsed', by changing this value. Ignores DPI (ED_area_global_size_y + * and winx/winy don't) */ + short cur_fixed_height; + /* For global areas, this is the min and max size they can use depending on + * if they are 'collapsed' or not. Value is set on area creation and not + * touched afterwards. */ + short size_min, size_max; + short pad; +} ScrGlobalAreaData; + typedef struct ScrArea { struct ScrArea *next, *prev; @@ -221,7 +253,7 @@ typedef struct ScrArea { char spacetype, butspacetype; /* SPACE_..., butspacetype is button arg */ short winx, winy; /* size */ - + short headertype; /* OLD! 0=no header, 1= down, 2= up */ short do_refresh; /* private, for spacetype refresh callback */ short flag; @@ -231,6 +263,9 @@ typedef struct ScrArea { struct SpaceType *type; /* callbacks for this space type */ + /* Non-NULL if this area is global. */ + ScrGlobalAreaData *global; + /* A list of space links (editors) that were open in this area before. When * changing the editor type, we try to reuse old editor data from this list. * The first item is the active/visible one. @@ -295,7 +330,11 @@ enum { HEADER_NO_PULLDOWN = (1 << 0), // AREA_FLAG_DEPRECATED_1 = (1 << 1), // AREA_FLAG_DEPRECATED_2 = (1 << 2), - AREA_TEMP_INFO = (1 << 3), +#ifdef DNA_DEPRECATED_ALLOW + AREA_TEMP_INFO = (1 << 3), /* versioned to make slot reusable */ +#endif + /* update size of regions within the area */ + AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3), // AREA_FLAG_DEPRECATED_4 = (1 << 4), // AREA_FLAG_DEPRECATED_5 = (1 << 5), /* used to check if we should switch back to prevspace (of a different type) */ @@ -413,8 +452,19 @@ enum { #define RGN_SPLIT_PREV 32 /* region flag */ -#define RGN_FLAG_HIDDEN 1 -#define RGN_FLAG_TOO_SMALL 2 +enum { + RGN_FLAG_HIDDEN = (1 << 0), + RGN_FLAG_TOO_SMALL = (1 << 1), + /* Force delayed reinit of region size data, so that region size is calculated + * just big enough to show all its content (if enough space is available). + * Note that only ED_region_header supports this right now. */ + RGN_FLAG_DYNAMIC_SIZE = (1 << 2), + /* The region width stored in ARegion.sizex already has the DPI + * factor applied, skip applying it again (in region_rect_recursive). + * XXX Not nice at all. Leaving for now as temporary solution, but + * it might cause issues if we change how ARegion.sizex is used... */ + RGN_SIZEX_DPI_APPLIED = (1 << 3), +}; /* region do_draw */ #define RGN_DRAW 1 -- cgit v1.2.3