tornavis/source/blender/makesdna/DNA_screen_types.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

872 lines
25 KiB
C
Raw Normal View History

/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later */
2002-10-12 13:37:38 +02:00
/** \file
* \ingroup DNA
*/
#pragma once
2011-12-30 08:25:49 +01:00
#include "BLI_utildefines.h"
#include "DNA_asset_types.h"
Main Workspace Integration This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup) Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know! (Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.) == Main Changes/Features * Introduces the new Workspaces as data-blocks. * Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces. * Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces). * Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead. * Store screen-layouts (`bScreen`) per workspace. * Store an active screen-layout per workspace. Changing the workspace will enable this layout. * Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.) * Store an active render layer per workspace. * Moved mode switch from 3D View header to Info Editor header. * Store active scene in window (not directly workspace related, but overlaps quite a bit). * Removed 'Use Global Scene' User Preference option. * Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well. * Default .blend only contains one workspace ("General"). * Support appending workspaces. Opening files without UI and commandline rendering should work fine. Note that the UI is temporary! We plan to introduce a new global topbar that contains the workspace options and tabs for switching workspaces. == Technical Notes * Workspaces are data-blocks. * Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now. * A workspace can be active in multiple windows at the same time. * The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned). * The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that). * Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs. * `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those. * Added scene operators `SCENE_OT_`. Was previously done through screen operators. == BPY API Changes * Removed `Screen.scene`, added `Window.scene` * Removed `UserPreferencesView.use_global_scene` * Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces` * Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer` * Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name) == What's left? * There are a few open design questions (T50521). We should find the needed answers and implement them. * Allow adding and removing individual workspaces from workspace configuration (needs UI design). * Get the override system ready and support overrides per workspace. * Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc). * Allow enabling add-ons per workspace. * Support custom workspace keymaps. * Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later. * Get the topbar done. * Workspaces need a proper icon, current one is just a placeholder :) Reviewed By: campbellbarton, mont29 Tags: #user_interface, #bf_blender_2.8 Maniphest Tasks: T50521 Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
#include "DNA_defs.h"
2002-10-12 13:37:38 +02:00
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
#include "DNA_view2d_types.h"
2002-10-12 13:37:38 +02:00
2008-11-29 14:57:19 +01:00
#include "DNA_ID.h"
2002-10-12 13:37:38 +02:00
struct ARegion;
struct ARegionType;
struct PanelType;
2020-09-30 03:51:13 +02:00
struct PointerRNA;
2008-11-29 14:57:19 +01:00
struct Scene;
struct SpaceLink;
struct SpaceType;
struct uiBlock;
2020-11-06 00:29:00 +01:00
struct uiLayout;
struct uiList;
struct uiListType;
struct wmDrawBuffer;
struct wmTimer;
struct wmTooltipState;
struct Panel_Runtime;
#ifdef __cplusplus
namespace blender::bke {
struct FileHandlerType;
}
using FileHandlerTypeHandle = blender::bke::FileHandlerType;
#else
typedef struct FileHandlerTypeHandle FileHandlerTypeHandle;
#endif
2002-10-12 13:37:38 +02:00
/* TODO: Doing this is quite ugly :)
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
2018-04-20 17:14:03 +02:00
* Once the top-bar is merged bScreen should be refactored to use ScrAreaMap. */
#define AREAMAP_FROM_SCREEN(screen) ((ScrAreaMap *)&(screen)->vertbase)
2002-10-12 13:37:38 +02:00
typedef struct bScreen {
ID id;
/* TODO: Should become ScrAreaMap now.
* NOTE: KEEP ORDER IN SYNC WITH #ScrAreaMap! (see AREAMAP_FROM_SCREEN macro above). */
/** Screens have vertices/edges to define areas. */
ListBase vertbase;
ListBase edgebase;
Various changes made in the process of working on the UI code: * Added functions to generate Timer events. There was some unfinished code to create one timer per window, this replaces that with a way to let operators or other handlers add/remove their own timers as needed. This is currently delivered as an event with the timer handle, perhaps this should be a notifier instead? Also includes some fixes in ghost for timer events that were not delivered in time, due to passing negative timeout. * Added a Message event, which is a generic event that can be added by any operator. This is used in the UI code to communicate the results of opened blocks. Again, this may be better as a notifier. * These two events should not be blocked as they are intended for a specific operator or handler, so there were exceptions added for this, which is one of the reasons they might work better as notifiers, but currently these things can't listen to notifier yet. * Added an option to events to indicate if the customdata should be freed or not. * Added a free() callback for area regions, and added a free function for area regions in blenkernel since it was already there for screens and areas. * Added ED_screen/area/region_exit functions to clean up things like operators and handlers when they are closed. * Added screen level regions, these will draw over areas boundaries, with the last created region on top. These are useful for tooltips, menus, etc, and are not saved to file. It's using the same ARegion struct as areas to avoid code duplication, but perhaps that should be renamed then. Note that redraws currently go correct, because only full window redraws are used, for partial redraws without any frontbuffer drawing, the window manager needs to get support for compositing subwindows. * Minor changes in the subwindow code to retrieve the matrix, and moved setlinestyle to glutil.c. * Reversed argument order in WM_event_add/remove_keymap_handler to be consistent with modal_handler. * Operators can now block events but not necessarily cancel/finish. * Modal operators are now stored in a list in the window/area/region they were created in. This means for example that when a transform operator is invoked from a region but registers a handler at the window level (since mouse motion across areas should work), it will still get removed when the region is closed while the operator is running.
2008-11-11 16:18:21 +01:00
ListBase areabase;
/* End variables that must be in sync with #ScrAreaMap. */
/** Screen level regions (menus), runtime only. */
ListBase regionbase;
Main Workspace Integration This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup) Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know! (Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.) == Main Changes/Features * Introduces the new Workspaces as data-blocks. * Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces. * Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces). * Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead. * Store screen-layouts (`bScreen`) per workspace. * Store an active screen-layout per workspace. Changing the workspace will enable this layout. * Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.) * Store an active render layer per workspace. * Moved mode switch from 3D View header to Info Editor header. * Store active scene in window (not directly workspace related, but overlaps quite a bit). * Removed 'Use Global Scene' User Preference option. * Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well. * Default .blend only contains one workspace ("General"). * Support appending workspaces. Opening files without UI and commandline rendering should work fine. Note that the UI is temporary! We plan to introduce a new global topbar that contains the workspace options and tabs for switching workspaces. == Technical Notes * Workspaces are data-blocks. * Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now. * A workspace can be active in multiple windows at the same time. * The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned). * The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that). * Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs. * `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those. * Added scene operators `SCENE_OT_`. Was previously done through screen operators. == BPY API Changes * Removed `Screen.scene`, added `Window.scene` * Removed `UserPreferencesView.use_global_scene` * Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces` * Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer` * Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name) == What's left? * There are a few open design questions (T50521). We should find the needed answers and implement them. * Allow adding and removing individual workspaces from workspace configuration (needs UI design). * Get the override system ready and support overrides per workspace. * Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc). * Allow enabling add-ons per workspace. * Support custom workspace keymaps. * Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later. * Get the topbar done. * Workspaces need a proper icon, current one is just a placeholder :) Reviewed By: campbellbarton, mont29 Tags: #user_interface, #bf_blender_2.8 Maniphest Tasks: T50521 Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
struct Scene *scene DNA_DEPRECATED;
/** General flags. */
short flag;
2023-02-02 03:59:21 +01:00
/** Window-ID from WM, starts with 1. */
short winid;
/** User-setting for which editors get redrawn during animation playback. */
short redraws_flag;
/** Temp screen in a temp window, don't save (like user-preferences). */
char temp;
/** Temp screen for image render display or file-select. */
char state;
/** Notifier for drawing edges. */
char do_draw;
/** Notifier for scale screen, changed screen, etc. */
char do_refresh;
/** Notifier for gesture draw. */
char do_draw_gesture;
/** Notifier for paint cursor draw. */
char do_draw_paintcursor;
/** Notifier for dragging draw. */
char do_draw_drag;
/** Set to delay screen handling after switching back from maximized area. */
char skip_handling;
/** Set when scrubbing to avoid some costly updates. */
char scrubbing;
char _pad[1];
/** Active region that has mouse focus. */
struct ARegion *active_region;
/** If set, screen has timer handler added in window. */
struct wmTimer *animtimer;
/** Context callback. */
void /*bContextDataCallback*/ *context;
/** Runtime. */
struct wmTooltipState *tool_tip;
PreviewImage *preview;
2002-10-12 13:37:38 +02:00
} bScreen;
typedef struct ScrVert {
struct ScrVert *next, *prev, *newv;
vec2s vec;
/* first one used internally, second one for tools */
short flag, editflag;
2002-10-12 13:37:38 +02:00
} ScrVert;
typedef struct ScrEdge {
struct ScrEdge *next, *prev;
ScrVert *v1, *v2;
/** 1 when at edge of screen. */
short border;
2002-10-12 13:37:38 +02:00
short flag;
char _pad[4];
2002-10-12 13:37:38 +02:00
} ScrEdge;
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
2018-04-20 17:14:03 +02:00
typedef struct ScrAreaMap {
/* ** NOTE: KEEP ORDER IN SYNC WITH LISTBASES IN bScreen! ** */
/** ScrVert - screens have vertices/edges to define areas. */
ListBase vertbase;
/** ScrEdge. */
ListBase edgebase;
/** ScrArea. */
ListBase areabase;
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
2018-04-20 17:14:03 +02:00
} ScrAreaMap;
Python: add Python API for layout panels This adds a Python API for layout panels that have been introduced in #113584. Two new methods on `UILayout` are added: * `.panel(idname, text="...", default_closed=False) -> Optional[UILayout]` * `.panel_prop(owner, prop_name, text="...") -> Optional[UILayout]` Both create a panel and return `None` if the panel is collapsed. The difference lies in how the open-close-state is stored. The first method internally manages the open-close-state based on the provided identifier. The second one allows for providing a boolean property that stores whether the panel is open. This is useful when creating a dynamic of panels and when it is difficult to create a unique idname. For the `.panel(...)` method, a new internal map on `Panel` is created which keeps track of all the panel states based on the idname. Currently, there is no mechanism for freeing any elements once they have been added to the map. This is unlikely to cause a problem anytime soon, but we might need some kind of garbage collection in the future. ```python import bpy from bpy.props import BoolProperty class LayoutDemoPanel(bpy.types.Panel): bl_label = "Layout Panel Demo" bl_idname = "SCENE_PT_layout_panel" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "scene" def draw(self, context): layout = self.layout scene = context.scene layout.label(text="Before") if panel := layout.panel("my_panel_id", text="Hello World", default_closed=False): panel.label(text="Success") if panel := layout.panel_prop(scene, "show_demo_panel", text="My Panel"): panel.prop(scene, "frame_start") panel.prop(scene, "frame_end") layout.label(text="After") bpy.utils.register_class(LayoutDemoPanel) bpy.types.Scene.show_demo_panel = BoolProperty(default=False) ``` Pull Request: https://projects.blender.org/blender/blender/pulls/116949
2024-01-11 19:08:45 +01:00
typedef struct LayoutPanelState {
struct LayoutPanelState *next, *prev;
/** Identifier of the panel. */
char *idname;
uint8_t flag;
char _pad[7];
} LayoutPanelState;
enum LayoutPanelStateFlag {
/** If set, the panel is currently open. Otherwise it is collapsed. */
LAYOUT_PANEL_STATE_FLAG_OPEN = (1 << 0),
};
/** The part from uiBlock that needs saved in file. */
typedef struct Panel {
struct Panel *next, *prev;
/** Runtime. */
struct PanelType *type;
/** Runtime for drawing. */
struct uiLayout *layout;
/** Defined as #BKE_ST_MAXNAME. */
char panelname[64];
2019-03-08 07:48:49 +01:00
/** Panel name is identifier for restoring location. */
char *drawname;
/** Offset within the region. */
int ofsx, ofsy;
/** Panel size including children. */
int sizex, sizey;
/** Panel size excluding children. */
int blocksizex, blocksizey;
short labelofs;
short flag, runtime_flag;
char _pad[6];
2019-03-08 07:48:49 +01:00
/** Panels are aligned according to increasing sort-order. */
int sortorder;
/** Runtime for panel manipulation. */
void *activedata;
/** Sub panels. */
ListBase children;
Python: add Python API for layout panels This adds a Python API for layout panels that have been introduced in #113584. Two new methods on `UILayout` are added: * `.panel(idname, text="...", default_closed=False) -> Optional[UILayout]` * `.panel_prop(owner, prop_name, text="...") -> Optional[UILayout]` Both create a panel and return `None` if the panel is collapsed. The difference lies in how the open-close-state is stored. The first method internally manages the open-close-state based on the provided identifier. The second one allows for providing a boolean property that stores whether the panel is open. This is useful when creating a dynamic of panels and when it is difficult to create a unique idname. For the `.panel(...)` method, a new internal map on `Panel` is created which keeps track of all the panel states based on the idname. Currently, there is no mechanism for freeing any elements once they have been added to the map. This is unlikely to cause a problem anytime soon, but we might need some kind of garbage collection in the future. ```python import bpy from bpy.props import BoolProperty class LayoutDemoPanel(bpy.types.Panel): bl_label = "Layout Panel Demo" bl_idname = "SCENE_PT_layout_panel" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "scene" def draw(self, context): layout = self.layout scene = context.scene layout.label(text="Before") if panel := layout.panel("my_panel_id", text="Hello World", default_closed=False): panel.label(text="Success") if panel := layout.panel_prop(scene, "show_demo_panel", text="My Panel"): panel.prop(scene, "frame_start") panel.prop(scene, "frame_end") layout.label(text="After") bpy.utils.register_class(LayoutDemoPanel) bpy.types.Scene.show_demo_panel = BoolProperty(default=False) ``` Pull Request: https://projects.blender.org/blender/blender/pulls/116949
2024-01-11 19:08:45 +01:00
/**
* List of #LayoutPanelState. This stores the open-close-state of layout-panels created with
* `layout.panel(...)` in Python. For more information on layout-panels, see `uiLayoutPanelProp`.
Python: add Python API for layout panels This adds a Python API for layout panels that have been introduced in #113584. Two new methods on `UILayout` are added: * `.panel(idname, text="...", default_closed=False) -> Optional[UILayout]` * `.panel_prop(owner, prop_name, text="...") -> Optional[UILayout]` Both create a panel and return `None` if the panel is collapsed. The difference lies in how the open-close-state is stored. The first method internally manages the open-close-state based on the provided identifier. The second one allows for providing a boolean property that stores whether the panel is open. This is useful when creating a dynamic of panels and when it is difficult to create a unique idname. For the `.panel(...)` method, a new internal map on `Panel` is created which keeps track of all the panel states based on the idname. Currently, there is no mechanism for freeing any elements once they have been added to the map. This is unlikely to cause a problem anytime soon, but we might need some kind of garbage collection in the future. ```python import bpy from bpy.props import BoolProperty class LayoutDemoPanel(bpy.types.Panel): bl_label = "Layout Panel Demo" bl_idname = "SCENE_PT_layout_panel" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "scene" def draw(self, context): layout = self.layout scene = context.scene layout.label(text="Before") if panel := layout.panel("my_panel_id", text="Hello World", default_closed=False): panel.label(text="Success") if panel := layout.panel_prop(scene, "show_demo_panel", text="My Panel"): panel.prop(scene, "frame_start") panel.prop(scene, "frame_end") layout.label(text="After") bpy.utils.register_class(LayoutDemoPanel) bpy.types.Scene.show_demo_panel = BoolProperty(default=False) ``` Pull Request: https://projects.blender.org/blender/blender/pulls/116949
2024-01-11 19:08:45 +01:00
*/
ListBase layout_panel_states;
struct Panel_Runtime *runtime;
} Panel;
/**
* Used for passing expansion between instanced panel data and the panels themselves.
* There are 16 defines because the expansion data is typically stored in a short.
*
* \note Expansion for instanced panels is stored in depth first order. For example, the value of
2023-05-27 07:24:52 +02:00
* UI_SUBPANEL_DATA_EXPAND_2 correspond to mean the expansion of the second sub-panel or the first
* sub-panel's first sub-panel.
*/
typedef enum uiPanelDataExpansion {
UI_PANEL_DATA_EXPAND_ROOT = (1 << 0),
UI_SUBPANEL_DATA_EXPAND_1 = (1 << 1),
UI_SUBPANEL_DATA_EXPAND_2 = (1 << 2),
UI_SUBPANEL_DATA_EXPAND_3 = (1 << 3),
UI_SUBPANEL_DATA_EXPAND_4 = (1 << 4),
UI_SUBPANEL_DATA_EXPAND_5 = (1 << 5),
UI_SUBPANEL_DATA_EXPAND_6 = (1 << 6),
UI_SUBPANEL_DATA_EXPAND_7 = (1 << 7),
UI_SUBPANEL_DATA_EXPAND_8 = (1 << 8),
UI_SUBPANEL_DATA_EXPAND_9 = (1 << 9),
UI_SUBPANEL_DATA_EXPAND_10 = (1 << 10),
UI_SUBPANEL_DATA_EXPAND_11 = (1 << 11),
UI_SUBPANEL_DATA_EXPAND_12 = (1 << 12),
UI_SUBPANEL_DATA_EXPAND_13 = (1 << 13),
UI_SUBPANEL_DATA_EXPAND_14 = (1 << 14),
UI_SUBPANEL_DATA_EXPAND_15 = (1 << 15),
} uiPanelDataExpansion;
2019-03-08 07:48:49 +01:00
/**
* Notes on Panel Categories:
*
* - #ARegion.panels_category (#PanelCategoryDyn)
* is a runtime only list of categories collected during draw.
*
* - #ARegion.panels_category_active (#PanelCategoryStack)
* is basically a list of strings (category id's).
*
* Clicking on a tab moves it to the front of region->panels_category_active,
* If the context changes so this tab is no longer displayed,
2019-03-08 07:48:49 +01:00
* then the first-most tab in #ARegion.panels_category_active is used.
*
* This way you can change modes and always have the tab you last clicked on.
*/
/* region level tabs */
#
#
typedef struct PanelCategoryDyn {
struct PanelCategoryDyn *next, *prev;
char idname[64];
rcti rect;
} PanelCategoryDyn;
/** Region stack of active tabs. */
typedef struct PanelCategoryStack {
struct PanelCategoryStack *next, *prev;
char idname[64];
} PanelCategoryStack;
typedef void (*uiListFreeRuntimeDataFunc)(struct uiList *ui_list);
/* uiList dynamic data... */
/* These two lines with # tell `makesdna` this struct can be excluded. */
#
#
typedef struct uiListDyn {
/** Callback to free UI data when freeing UI-Lists in BKE. */
uiListFreeRuntimeDataFunc free_runtime_data_fn;
/** Number of rows needed to draw all elements. */
int height;
/** Actual visual height of the list (in rows). */
int visual_height;
/** Minimal visual height of the list (in rows). */
int visual_height_min;
/** Number of columns drawn for grid layouts. */
int columns;
/** Number of items in collection. */
int items_len;
/** Number of items actually visible after filtering. */
int items_shown;
/* Those are temp data used during drag-resize with GRIP button
* (they are in pixels, the meaningful data is the
* difference between resize_prev and resize)...
*/
int resize;
int resize_prev;
2021-07-16 03:45:51 +02:00
/** Allocated custom data. Freed together with the #uiList (and when re-assigning). */
void *customdata;
/* Filtering data. */
/** This bit-field is effectively exposed in Python, and scripts are explicitly allowed to assign
* any own meaning to the lower 16 ones.
* #items_len length. */
int *items_filter_flags;
/** Org_idx -> new_idx, items_len length. */
int *items_filter_neworder;
struct wmOperatorType *custom_drag_optype;
struct PointerRNA *custom_drag_opptr;
struct wmOperatorType *custom_activate_optype;
struct PointerRNA *custom_activate_opptr;
} uiListDyn;
typedef struct uiList { /* some list UI data need to be saved in file */
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
struct uiList *next, *prev;
/** Runtime. */
struct uiListType *type;
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
/** Defined as UI_MAX_NAME_STR. */
char list_id[128];
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
2021-02-13 07:44:51 +01:00
/** How items are laid out in the list. */
int layout_type;
int flag;
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
int list_scroll;
int list_grip;
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
int list_last_len;
int list_last_activei;
/* Filtering data. */
/** Defined as UI_MAX_NAME_STR. */
char filter_byname[128];
int filter_flag;
int filter_sort_flag;
/** Custom sub-classes properties. */
IDProperty *properties;
/** Dynamic data (runtime). */
uiListDyn *dyn_data;
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
} uiList;
typedef struct TransformOrientation {
struct TransformOrientation *next, *prev;
/** MAX_NAME. */
char name[64];
float mat[3][3];
char _pad[4];
} TransformOrientation;
/** Some preview UI data need to be saved in file. */
typedef struct uiPreview {
struct uiPreview *next, *prev;
/** Defined as #BKE_ST_MAXNAME. */
char preview_id[64];
short height;
char _pad1[6];
} uiPreview;
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
2018-04-20 17:14:03 +02:00
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).
*/
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
2018-04-20 17:14:03 +02:00
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.
*/
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
2018-04-20 17:14:03 +02:00
short size_min, size_max;
/** GlobalAreaAlign. */
short align;
/** GlobalAreaFlag. */
short flag;
char _pad[2];
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
2018-04-20 17:14:03 +02:00
} ScrGlobalAreaData;
enum GlobalAreaFlag {
GLOBAL_AREA_IS_HIDDEN = (1 << 0),
};
typedef enum GlobalAreaAlign {
GLOBAL_AREA_ALIGN_TOP = 0,
GLOBAL_AREA_ALIGN_BOTTOM = 1,
} GlobalAreaAlign;
typedef struct ScrArea_Runtime {
struct bToolRef *tool;
char is_tool_set;
char _pad0[7];
} ScrArea_Runtime;
2002-10-12 13:37:38 +02:00
typedef struct ScrArea {
DNA_DEFINE_CXX_METHODS(ScrArea)
2002-10-12 13:37:38 +02:00
struct ScrArea *next, *prev;
2021-02-13 07:44:51 +01:00
/** Ordered (bottom-left, top-left, top-right, bottom-right). */
ScrVert *v1, *v2, *v3, *v4;
/** If area==full, this is the parent. */
bScreen *full;
/** Rect bound by v1 v2 v3 v4. */
rcti totrct;
/**
* eSpace_Type (SPACE_FOO).
*
* Temporarily used while switching area type, otherwise this should be SPACE_EMPTY.
* Also, versioning uses it to nicely replace deprecated * editors.
* It's been there for ages, name doesn't fit any more.
*/
char spacetype;
2019-01-07 15:00:40 +01:00
/** #eSpace_Type (SPACE_FOO). */
char butspacetype;
short butspacetype_subtype;
/** Size. */
short winx, winy;
/** OLD! 0=no header, 1= down, 2= up. */
char headertype DNA_DEPRECATED;
/** Private, for spacetype refresh callback. */
char do_refresh;
short flag;
/**
* Index of last used region of 'RGN_TYPE_WINDOW'
* runtime variable, updated by executing operators.
*/
short region_active_win;
char _pad[2];
/** Callbacks for this space type. */
struct SpaceType *type;
/** Non-NULL if this area is global. */
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
2018-04-20 17:14:03 +02:00
ScrGlobalAreaData *global;
/**
* #SpaceLink.
* 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.
*/
ListBase spacedata;
/**
* #ARegion.
* \note This region list is the one from the active/visible editor (first item in
* spacedata list). Use SpaceLink.regionbase if it's inactive (but only then)!
*/
ListBase regionbase;
2019-01-07 15:00:40 +01:00
/** #wmEventHandler. */
ListBase handlers;
2019-01-07 15:00:40 +01:00
/** #AZone. */
ListBase actionzones;
ScrArea_Runtime runtime;
2002-10-12 13:37:38 +02:00
} ScrArea;
typedef struct ARegion_Runtime {
/** Panel category to use between 'layout' and 'draw'. */
const char *category;
/**
* The visible part of the region, use with region overlap not to draw
* on top of the overlapping regions.
*
* Lazy initialize, zero'd when unset, relative to #ARegion.winrct x/y min. */
rcti visible_rect;
2022-09-19 06:47:27 +02:00
/* The offset needed to not overlap with window scroll-bars. Only used by HUD regions for now. */
int offset_x, offset_y;
/** Maps #uiBlock::name to uiBlock for faster lookups. */
struct GHash *block_name_map;
/* Dummy panel used in popups so they can support layout panels. */
Panel *popup_block_panel;
} ARegion_Runtime;
typedef struct ARegion {
struct ARegion *next, *prev;
/** 2D-View scrolling/zoom info (most regions are 2d anyways). */
View2D v2d;
/** Coordinates of region. */
rcti winrct;
/** Runtime for partial redraw, same or smaller than winrct. */
rcti drawrct;
/** Size. */
short winx, winy;
/**
* This is a Y offset on the panel tabs that represents pixels,
* where zero represents no scroll - the first category always shows first at the top.
*/
int category_scroll;
char _pad0[4];
/** Region is currently visible on screen. */
short visible;
/** Window, header, etc. identifier for drawing. */
short regiontype;
/** How it should split. */
short alignment;
/** Hide, .... */
short flag;
/** Current split size in unscaled pixels (if zero it uses regiontype).
* To convert to pixels use: `UI_SCALE_FAC * region->sizex + 0.5f`.
* However to get the current region size, you should usually use winx/winy from above, not this!
*/
short sizex, sizey;
/** Private, cached notifier events. */
short do_draw;
/** Private, cached notifier events. */
short do_draw_paintcursor;
/** Private, set for indicate drawing overlapped. */
short overlap;
2022-09-16 10:13:19 +02:00
/** Temporary copy of flag settings for clean full-screen. */
short flagfullscreen;
/** Callbacks for this region type. */
struct ARegionType *type;
2019-01-07 15:00:40 +01:00
/** #uiBlock. */
ListBase uiblocks;
/** Panel. */
ListBase panels;
/** Stack of panel categories. */
ListBase panels_category_active;
2019-01-07 15:00:40 +01:00
/** #uiList. */
ListBase ui_lists;
2019-01-07 15:00:40 +01:00
/** #uiPreview. */
ListBase ui_previews;
2019-01-07 15:00:40 +01:00
/** #wmEventHandler. */
ListBase handlers;
/** Panel categories runtime. */
ListBase panels_category;
/** Gizmo-map of this region. */
struct wmGizmoMap *gizmo_map;
/** Blend in/out. */
struct wmTimer *regiontimer;
struct wmDrawBuffer *draw_buffer;
/** Use this string to draw info. */
char *headerstr;
/** XXX 2.50, need spacedata equivalent? */
void *regiondata;
ARegion_Runtime runtime;
} ARegion;
/** #ScrArea.flag */
enum {
HEADER_NO_PULLDOWN = (1 << 0),
// AREA_FLAG_UNUSED_1 = (1 << 1),
// AREA_FLAG_UNUSED_2 = (1 << 2),
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
2018-04-20 17:14:03 +02:00
#ifdef DNA_DEPRECATED_ALLOW
AREA_TEMP_INFO = (1 << 3), /* versioned to make slot reusable */
#endif
2019-09-07 13:08:20 +02:00
/** Update size of regions within the area. */
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
2018-04-20 17:14:03 +02:00
AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
AREA_FLAG_ACTIVE_TOOL_UPDATE = (1 << 4),
// AREA_FLAG_UNUSED_5 = (1 << 5),
AREA_FLAG_UNUSED_6 = (1 << 6), /* cleared */
2019-09-07 13:08:20 +02:00
/**
* For temporary full-screens (file browser, image editor render)
* that are opened above user set full-screens.
*/
AREA_FLAG_STACKED_FULLSCREEN = (1 << 7),
2019-09-07 13:08:20 +02:00
/** Update action zones (even if the mouse is not intersecting them). */
AREA_FLAG_ACTIONZONES_UPDATE = (1 << 8),
2022-03-30 02:38:24 +02:00
/** For off-screen areas. */
AREA_FLAG_OFFSCREEN = (1 << 9),
};
#define AREAGRID 4
#define AREAMINX 29
#define HEADER_PADDING_Y 6
#define HEADERY (20 + HEADER_PADDING_Y)
2002-10-12 13:37:38 +02:00
/** #bScreen.flag */
enum {
SCREEN_DEPRECATED = 1,
SCREEN_COLLAPSE_STATUSBAR = 2,
};
/** #bScreen.state */
enum {
SCREENNORMAL = 0,
/** One editor taking over the screen. */
SCREENMAXIMIZED = 1,
/** One editor taking over the screen with no bare-minimum UI elements. */
SCREENFULL = 2,
};
/** #bScreen.redraws_flag */
typedef enum eScreen_Redraws_Flag {
TIME_REGION = (1 << 0),
TIME_ALL_3D_WIN = (1 << 1),
TIME_ALL_ANIM_WIN = (1 << 2),
TIME_ALL_BUTS_WIN = (1 << 3),
// TIME_WITH_SEQ_AUDIO = (1 << 4), /* DEPRECATED */
TIME_SEQ = (1 << 5),
TIME_ALL_IMAGE_WIN = (1 << 6),
// TIME_CONTINUE_PHYSICS = (1 << 7), /* UNUSED */
TIME_NODES = (1 << 8),
TIME_CLIPS = (1 << 9),
TIME_SPREADSHEETS = (1 << 10),
TIME_FOLLOW = (1 << 15),
} eScreen_Redraws_Flag;
/** #Panel.flag */
enum {
PNL_SELECT = (1 << 0),
PNL_UNUSED_1 = (1 << 1), /* Cleared */
PNL_CLOSED = (1 << 2),
// PNL_TABBED = (1 << 3), /* UNUSED */
// PNL_OVERLAP = (1 << 4), /* UNUSED */
PNL_PIN = (1 << 5),
PNL_POPOVER = (1 << 6),
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
2020-05-26 21:39:49 +02:00
/** The panel has been drag-drop reordered and the instanced panel list needs to be rebuilt. */
PNL_INSTANCED_LIST_ORDER_CHANGED = (1 << 7),
};
2002-10-12 13:37:38 +02:00
/** Fallback panel category (only for old scripts which need updating). */
#define PNL_CATEGORY_FALLBACK "Misc"
/** #uiList.layout_type */
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
enum {
UILST_LAYOUT_DEFAULT = 0,
UILST_LAYOUT_COMPACT = 1,
UILST_LAYOUT_GRID = 2,
UILST_LAYOUT_BIG_PREVIEW_GRID = 3,
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one). It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
2012-12-28 10:20:16 +01:00
};
/** #uiList.flag */
enum {
/** Scroll list to make active item visible. */
UILST_SCROLL_TO_ACTIVE_ITEM = 1 << 0,
};
/** Value (in number of items) we have to go below minimum shown items to enable auto size. */
#define UI_LIST_AUTO_SIZE_THRESHOLD 1
/** uiList filter flags (dyn_data)
*
* \warning Lower 16 bits are meant for custom use in Python, don't use them here! Only use the
* higher 16 bits.
* \warning Those values are used by integer RNA too, which does not handle well values > INT_MAX.
* So please do not use 32nd bit here.
*/
enum {
/* Don't use (1 << 0) to (1 << 15) here! See warning above. */
/* Filtering returned #UI_LIST_ITEM_NEVER_SHOW. */
UILST_FLT_ITEM_NEVER_SHOW = (1 << 16),
UILST_FLT_ITEM = 1 << 30, /* This item has passed the filter process successfully. */
};
/** #uiList.filter_flag */
enum {
UILST_FLT_SHOW = 1 << 0, /* Show filtering UI. */
UILST_FLT_EXCLUDE = UILST_FLT_ITEM, /* Exclude filtered items, *must* use this same value. */
};
/** #uiList.filter_sort_flag */
enum {
/* Plain values (only one is valid at a time, once masked with UILST_FLT_SORT_MASK. */
/** Just for sake of consistency. */
2020-02-20 00:21:23 +01:00
/* UILST_FLT_SORT_INDEX = 0, */ /* UNUSED */
UILST_FLT_SORT_ALPHA = 1,
/* Bitflags affecting behavior of any kind of sorting. */
/** Special flag to indicate that order is locked (not user-changeable). */
UILST_FLT_SORT_LOCK = 1u << 30,
2022-08-17 07:43:17 +02:00
/** Special value, bit-flag used to reverse order! */
UILST_FLT_SORT_REVERSE = 1u << 31,
};
#define UILST_FLT_SORT_MASK (((unsigned int)(UILST_FLT_SORT_REVERSE | UILST_FLT_SORT_LOCK)) - 1)
/**
* regiontype, first two are the default set.
* \warning Do NOT change order, append on end. Types are hard-coded needed.
*/
typedef enum eRegion_Type {
2010-01-01 21:50:58 +01:00
RGN_TYPE_WINDOW = 0,
RGN_TYPE_HEADER = 1,
RGN_TYPE_CHANNELS = 2,
RGN_TYPE_TEMPORARY = 3,
RGN_TYPE_UI = 4,
RGN_TYPE_TOOLS = 5,
RGN_TYPE_TOOL_PROPS = 6,
RGN_TYPE_PREVIEW = 7,
RGN_TYPE_HUD = 8,
/* Region to navigate the main region from (RGN_TYPE_WINDOW). */
RGN_TYPE_NAV_BAR = 9,
/* A place for buttons to trigger execution of something that was set up in other regions. */
UI: Preferences Redesign Part 2 (Part 1 was 00963afc14978b) Does the following changes visible to users: * Use panels and sub-panels for more structured & logical grouping * Re-organized options more logically than before (see images in D4148) * Use flow layout (single column by default). * New layout uses horizontal margin if there's enough space. * Change size of Preferences window to suit new layout. * Move keymap related options from "Input" into own section. * Own, left-bottom aligned region for Save Preferences button. * Adjustments of names, tooltips & icons. * Move buttons from header into the main region (except editor switch). * Hide Preferences header when opened in temporary window. * Use full area width for header. * Don't use slider but regular number widget for UI scale. * Gray out animation player path option if player isn't "Custom" Internal changes: * Rearrange RNA properties to match changed UI structure. * Introduces new "EXECUTE" region type, see reasoning in D3982. * Changes to panel layout and AZone code for dynamic panel region. * Bumps subversion and does versioning for new regions. RNA changes are documented in the release notes: https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Preferences_API Design & implementation mostly done by @billreynish and myself. I recommend checking out the screenshots posted by William: https://developer.blender.org/D4148#93787 Reviewed By: brecht Maniphest Tasks: T54115 Differential Revision: https://developer.blender.org/D4148
2019-01-04 21:40:16 +01:00
RGN_TYPE_EXECUTE = 10,
RGN_TYPE_FOOTER = 11,
RGN_TYPE_TOOL_HEADER = 12,
/* Region type used exclusively by internal code and add-ons to register draw callbacks to the XR
* context (surface, mirror view). Does not represent any real region. */
RGN_TYPE_XR = 13,
RGN_TYPE_ASSET_SHELF = 14,
RGN_TYPE_ASSET_SHELF_HEADER = 15,
#define RGN_TYPE_NUM (RGN_TYPE_ASSET_SHELF_HEADER + 1)
} eRegion_Type;
/** Use for function args. */
#define RGN_TYPE_ANY -1
/** Region supports panel tabs (categories). */
#define RGN_TYPE_HAS_CATEGORY_MASK (1 << RGN_TYPE_UI)
/** Check for any kind of header region. */
#define RGN_TYPE_IS_HEADER_ANY(regiontype) \
(((1 << (regiontype)) & ((1 << RGN_TYPE_HEADER) | 1 << (RGN_TYPE_TOOL_HEADER) | \
(1 << RGN_TYPE_FOOTER) | (1 << RGN_TYPE_ASSET_SHELF_HEADER))) != 0)
/** #ARegion.alignment */
enum {
RGN_ALIGN_NONE = 0,
RGN_ALIGN_TOP = 1,
RGN_ALIGN_BOTTOM = 2,
RGN_ALIGN_LEFT = 3,
RGN_ALIGN_RIGHT = 4,
RGN_ALIGN_HSPLIT = 5,
RGN_ALIGN_VSPLIT = 6,
RGN_ALIGN_FLOAT = 7,
RGN_ALIGN_QSPLIT = 8,
/* Maximum 15. */
/* Flags start here. */
/** Region is split into the previous one, they share the same space along a common edge.
* Includes the #RGN_ALIGN_HIDE_WITH_PREV behavior. */
RGN_SPLIT_PREV = 1 << 5,
/** Always let scaling this region scale the previous region instead. Useful to let regions
* appear like they are one (while having independent layout, scrolling, etc.). */
RGN_SPLIT_SCALE_PREV = 1 << 6,
/** Whenever the previous region is hidden, this region becomes invisible too. #RGN_FLAG_HIDDEN
* should only be set for the previous region, not this. The evaluated visibility respecting this
* flag can be queried via #ARegion.visible */
RGN_ALIGN_HIDE_WITH_PREV = 1 << 7,
};
/** Mask out flags so we can check the alignment. */
#define RGN_ALIGN_ENUM_FROM_MASK(align) ((align) & ((1 << 4) - 1))
#define RGN_ALIGN_FLAG_FROM_MASK(align) ((align) & ~((1 << 4) - 1))
/** #ARegion.flag */
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
2018-04-20 17:14:03 +02:00
enum {
RGN_FLAG_HIDDEN = (1 << 0),
RGN_FLAG_TOO_SMALL = (1 << 1),
/** Enable dynamically changing the region size in the #ARegionType::layout() callback. */
RGN_FLAG_DYNAMIC_SIZE = (1 << 2),
/** Region data is NULL'd on read, never written. */
RGN_FLAG_TEMP_REGIONDATA = (1 << 3),
/** Region resizing by the user is disabled, but the region edge can still be dragged to
* hide/unhide the region. */
RGN_FLAG_NO_USER_RESIZE = (1 << 4),
2019-03-13 23:58:20 +01:00
/** Size has been clamped (floating regions only). */
RGN_FLAG_SIZE_CLAMP_X = (1 << 5),
RGN_FLAG_SIZE_CLAMP_Y = (1 << 6),
/** When the user sets the region is hidden,
* needed for floating regions that may be hidden for other reasons. */
RGN_FLAG_HIDDEN_BY_USER = (1 << 7),
/** Property search filter is active. */
RGN_FLAG_SEARCH_FILTER_ACTIVE = (1 << 8),
/**
* Update the expansion of the region's panels and switch contexts. Only Set
* temporarily when the search filter is updated and cleared at the end of the
* region's layout pass. so that expansion is still interactive,
*/
RGN_FLAG_SEARCH_FILTER_UPDATE = (1 << 9),
UI: Region polling support Introduces *ARegionType.poll()* as a way to dynamically add/remove a region. The region is still there internally, but is not accessible to the user. Previously editors would to this manually, by either removing/adding regions altogether, or hiding them, unsetting their alignment (so no AZones are added I assume) and removing their event handlers. Polling makes this much simpler. We plan to use this in #102879. This patch refactors multiple editors to use region polling: - File Browser - Sequencer - Clip Editor - Preferences Notes: - Previously, editors would lazy-create some of the regions. Versioning is added here to ensure they are always there. Could be a separate patch. - Some editors reuse a region in different display modes, and so additional work needs to be done to reinit regions they become available or the mode changes. Typically `V2D_IS_INIT` is unset for that, which isn't great. Could be improved, but not a new issue. Behavior change: - When the Preferences are opened as a regular editor, the "execution" region in the preferences that displays the *Save Preferences* button would still be there, but empty with a scrollbar. This patch makes it disappear entirely. ## Implementation - Introduces `ARegionType.poll()` - Before a window is drawn, all contained regions have their poll checked, and the result is stored in a flag (`RGN_FLAG_POLL_FAILED` - runtime-only flag). - If the result of the poll changes, the area is re-initialized and event handlers are added/removed. - UI code checks the flag as needed. Pull Request: https://projects.blender.org/blender/blender/pulls/105088
2023-04-05 15:30:32 +02:00
/** #ARegionType.poll() failed for the current context, and the region should be treated as if it
* wouldn't exist. Runtime only flag. */
RGN_FLAG_POLL_FAILED = (1 << 10),
RGN_FLAG_RESIZE_RESPECT_BUTTON_SECTIONS = (1 << 11),
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
2018-04-20 17:14:03 +02:00
};
/** #ARegion.do_draw */
enum {
/** Region must be fully redrawn. */
RGN_DRAW = 1,
/**
* Redraw only part of region, for sculpting and painting to get smoother
* stroke painting on heavy meshes.
*/
RGN_DRAW_PARTIAL = 2,
/**
* For outliner, to do faster redraw without rebuilding outliner tree.
* For 3D viewport, to display a new progressive render sample without
* while other buffers and overlays remain unchanged.
*/
RGN_DRAW_NO_REBUILD = 4,
/** Set while region is being drawn. */
RGN_DRAWING = 8,
/** For popups, to refresh UI layout along with drawing. */
RGN_REFRESH_UI = 16,
/** Only editor overlays (currently gizmos only!) should be redrawn. */
RGN_DRAW_EDITOR_OVERLAYS = 32,
};
typedef struct AssetShelfSettings {
struct AssetShelfSettings *next, *prev;
AssetLibraryReference asset_library_reference;
ListBase enabled_catalog_paths; /* #LinkData */
/** If not set (null or empty string), all assets will be displayed ("All" catalog behavior). */
const char *active_catalog_path;
/** For filtering assets displayed in the asset view. */
char search_string[64];
short preview_size;
short display_flag; /* #AssetShelfSettings_DisplayFlag */
char _pad1[4];
#ifdef __cplusplus
/* Zero initializes. */
AssetShelfSettings();
/* Proper deep copy. */
AssetShelfSettings(const AssetShelfSettings &other);
AssetShelfSettings &operator=(const AssetShelfSettings &other);
~AssetShelfSettings();
#endif
} AssetShelfSettings;
typedef struct AssetShelf {
DNA_DEFINE_CXX_METHODS(AssetShelf)
struct AssetShelf *next, *prev;
/** Identifier that matches the #AssetShelfType.idname this shelf was created with. Used to
* restore the #AssetShelf.type pointer below on file read. */
char idname[64]; /* MAX_NAME */
/** Runtime. */
struct AssetShelfType *type;
AssetShelfSettings settings;
short preferred_row_count;
char _pad[6];
} AssetShelf;
/**
* Region-data for the main asset shelf region (#RGN_TYPE_ASSET_SHELF). Managed by the asset shelf
* internals.
*
* Contains storage for all previously activated asset shelf instances plus info on the currently
* active one (only one can be active at any time).
*/
typedef struct RegionAssetShelf {
/** Owning list of previously activated asset shelves. */
ListBase shelves;
/**
* The currently active shelf, if any. Updated on redraw, so that context changes are reflected.
* Note that this may still be set even though the shelf isn't available anymore
* (#AssetShelfType.poll() fails). The pointer isn't necessarily unset when polling.
*/
AssetShelf *active_shelf; /* Non-owning. */
#ifdef __cplusplus
static RegionAssetShelf *get_from_asset_shelf_region(const ARegion &region);
#endif
} RegionAssetShelf;
/* #AssetShelfSettings.display_flag */
typedef enum AssetShelfSettings_DisplayFlag {
ASSETSHELF_SHOW_NAMES = (1 << 0),
} AssetShelfSettings_DisplayFlag;
ENUM_OPERATORS(AssetShelfSettings_DisplayFlag, ASSETSHELF_SHOW_NAMES);
typedef struct FileHandler {
DNA_DEFINE_CXX_METHODS(FileHandler)
/** Runtime. */
FileHandlerTypeHandle *type;
} FileHandler;