2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-18 14:05:18 +01:00
|
|
|
*/
|
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_types.hh"
|
2020-03-02 15:07:49 +01:00
|
|
|
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
#include "BKE_context.h"
|
|
|
|
|
2023-09-15 16:17:44 +02:00
|
|
|
namespace blender::asset_system {
|
|
|
|
class AssetRepresentation;
|
|
|
|
}
|
2020-03-02 15:07:49 +01:00
|
|
|
|
2008-01-07 19:03:41 +01:00
|
|
|
struct ARegion;
|
2020-11-06 00:29:00 +01:00
|
|
|
struct BlendDataReader;
|
|
|
|
struct BlendLibReader;
|
|
|
|
struct BlendWriter;
|
2009-04-19 19:12:16 +02:00
|
|
|
struct Header;
|
2015-12-01 02:55:57 +01:00
|
|
|
struct ID;
|
2022-01-25 14:51:35 +01:00
|
|
|
struct IDRemapper;
|
2020-05-27 02:52:07 +02:00
|
|
|
struct LibraryForeachIDData;
|
2011-11-04 02:15:04 +01:00
|
|
|
struct ListBase;
|
2009-04-22 20:39:44 +02:00
|
|
|
struct Menu;
|
2011-11-04 02:15:04 +01:00
|
|
|
struct Panel;
|
|
|
|
struct Scene;
|
2008-12-18 03:56:48 +01:00
|
|
|
struct ScrArea;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct ScrAreaMap;
|
2023-09-25 23:52:54 +02:00
|
|
|
struct ScrEdge;
|
2018-04-13 21:43:57 +02:00
|
|
|
struct ScrVert;
|
2008-12-18 03:56:48 +01:00
|
|
|
struct SpaceType;
|
2011-11-04 02:15:04 +01:00
|
|
|
struct View3D;
|
2018-07-11 11:43:56 +02:00
|
|
|
struct View3DShading;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct WorkSpace;
|
2011-11-04 02:15:04 +01:00
|
|
|
struct bContext;
|
|
|
|
struct bScreen;
|
|
|
|
struct uiLayout;
|
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;
|
2018-07-14 23:49:00 +02:00
|
|
|
struct wmGizmoMap;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct wmKeyConfig;
|
|
|
|
struct wmMsgBus;
|
2008-01-07 19:03:41 +01:00
|
|
|
struct wmNotifier;
|
2008-12-15 17:54:47 +01:00
|
|
|
struct wmWindow;
|
2008-12-18 03:56:48 +01:00
|
|
|
struct wmWindowManager;
|
2009-07-21 22:05:16 +02:00
|
|
|
|
2018-06-03 17:06:13 +02:00
|
|
|
/* spacetype has everything stored to get an editor working, it gets initialized via
|
2023-06-12 18:30:55 +02:00
|
|
|
* #ED_spacetypes_init() in `editors/space_api/spacetypes.cc` */
|
2008-01-07 19:03:41 +01:00
|
|
|
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
|
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
#define BKE_ST_MAXNAME 64
|
2008-12-08 16:02:57 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct wmSpaceTypeListenerParams {
|
|
|
|
wmWindow *window;
|
|
|
|
ScrArea *area;
|
|
|
|
const wmNotifier *notifier;
|
|
|
|
const Scene *scene;
|
|
|
|
};
|
2021-01-19 00:28:47 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct SpaceType {
|
|
|
|
SpaceType *next, *prev;
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
char name[BKE_ST_MAXNAME]; /* for menus */
|
|
|
|
int spaceid; /* unique space identifier */
|
|
|
|
int iconid; /* icon lookup for menus */
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2018-04-21 19:30:56 +02:00
|
|
|
/* Initial allocation, after this WM will call init() too. Some editors need
|
|
|
|
* area and scene data (e.g. frame range) to set their initial scrolling. */
|
2023-09-25 23:52:54 +02:00
|
|
|
SpaceLink *(*create)(const ScrArea *area, const Scene *scene);
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 12:10:31 +02:00
|
|
|
/* not free spacelink itself */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*free)(SpaceLink *sl);
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2008-12-10 14:56:54 +01:00
|
|
|
/* init is to cope with file load, screen (size) changes, check handlers */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*init)(wmWindowManager *wm, ScrArea *area);
|
2013-03-15 20:56:29 +01:00
|
|
|
/* exit is called when the area is hidden or removed */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*exit)(wmWindowManager *wm, ScrArea *area);
|
2008-12-10 14:56:54 +01:00
|
|
|
/* Listeners can react to bContext changes */
|
2021-01-19 02:59:00 +01:00
|
|
|
void (*listener)(const wmSpaceTypeListenerParams *params);
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2019-05-19 02:09:45 +02:00
|
|
|
/* called when the mouse moves out of the area */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*deactivate)(ScrArea *area);
|
2019-05-19 02:09:45 +02:00
|
|
|
|
2023-09-05 02:49:20 +02:00
|
|
|
/** Refresh context, called after file-reads, #ED_area_tag_refresh(). */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*refresh)(const bContext *C, ScrArea *area);
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 12:10:31 +02:00
|
|
|
/* after a spacedata copy, an init should result in exact same situation */
|
2023-09-25 23:52:54 +02:00
|
|
|
SpaceLink *(*duplicate)(SpaceLink *sl);
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 12:10:31 +02:00
|
|
|
|
|
|
|
/* register operator types on startup */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*operatortypes)();
|
2008-12-08 16:02:57 +01:00
|
|
|
/* add default items to WM keymap */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*keymap)(wmKeyConfig *keyconf);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* on startup, define dropboxes for spacetype+regions */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*dropboxes)();
|
2.5 Branch
==========
* Changed wmOperatorType, removing init/exit callbacks and adding cancel
callback, removed default storage in favor of properties. Defined return
values for exec/invoke/modal/cancel.
* Don't allocate operator on the stack, and removed operator copy for
handlers. Now it frees based on return values from callbacks, and just
keeps a wmOperator on the heap. Also it now registers after the operator
is fully finished, to get the correct final properties.
* Changed OP_get_* functions to return 1 if the property is found and 0
otherwise, gives more readable code in my opinion. Added OP_verify_*
functions to quickly check if the property is available and set if it's
not, that's common for exec/invoke.
* Removed WM_operatortypelist_append in favor of WM_operatortype_append
which takes a function pointer instead of a list, avoids macro's and
duplicating code.
* Fix a crash where the handler would still be used while it was freed by
the operator.
* Spacetypes now have operatortypes() and keymap() callbacks to abstract
them a bit more.
* Renamed C->curarea to C->area for consistency. Removed View3D/View2D/
SpaceIpo from bContext, seems bad to keep these.
* Set context variables like window/screen/area/region to NULL again when
leaving that context, instead of leaving the pointers there.
* Added if(G.f & G_DEBUG) for many of the prints, makes output a bit
cleaner and easier to debug.
* Fixed priority of the editors/interface module in scons, would otherwise
give link errors.
* Added start of generic view2d api.
* Added space_time with some basic drawing and a single operator to change
the frame.
2008-06-11 12:10:31 +02:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
/* initialize gizmo-map-types and gizmo-group-types with the region */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*gizmos)();
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2008-12-18 03:56:48 +01:00
|
|
|
/* return context data */
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
bContextDataCallback context;
|
2008-12-18 03:56:48 +01:00
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/* Used when we want to replace an ID by another (or NULL). */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*id_remap)(ScrArea *area, SpaceLink *sl, const IDRemapper *mappings);
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
|
2023-08-17 14:42:04 +02:00
|
|
|
/**
|
|
|
|
* foreach_id callback to process all ID pointers of the editor. Used indirectly by lib_query's
|
2023-08-18 00:51:29 +02:00
|
|
|
* #BKE_library_foreach_ID_link when #IDWALK_INCLUDE_UI bit-flag is set (through WM's foreach_id
|
2023-08-17 14:42:04 +02:00
|
|
|
* usage of #BKE_screen_foreach_id_screen_area).
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*foreach_id)(SpaceLink *space_link, LibraryForeachIDData *data);
|
2023-08-17 14:42:04 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
int (*space_subtype_get)(ScrArea *area);
|
|
|
|
void (*space_subtype_set)(ScrArea *area, int value);
|
|
|
|
void (*space_subtype_item_extend)(bContext *C, EnumPropertyItem **item, int *totitem);
|
2018-05-29 09:19:06 +02:00
|
|
|
|
2022-09-28 11:52:22 +02:00
|
|
|
/**
|
|
|
|
* Update pointers for all structs directly owned by this space.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*blend_read_data)(BlendDataReader *reader, SpaceLink *space_link);
|
2022-09-28 11:52:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update pointers to other id data blocks.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*blend_read_after_liblink)(BlendLibReader *reader, ID *parent_id, SpaceLink *space_link);
|
2022-09-28 11:52:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write all structs that should be saved in a .blend file.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*blend_write)(BlendWriter *writer, SpaceLink *space_link);
|
2022-09-28 11:52:22 +02:00
|
|
|
|
2008-12-08 16:02:57 +01:00
|
|
|
/* region type definitions */
|
2012-05-12 22:39:39 +02:00
|
|
|
ListBase regiontypes;
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2023-08-03 16:54:39 +02:00
|
|
|
/** Asset shelf type definitions. */
|
|
|
|
ListBase asset_shelf_types; /* #AssetShelfType */
|
|
|
|
|
2008-01-07 19:03:41 +01:00
|
|
|
/* read and write... */
|
2018-06-03 17:06:13 +02:00
|
|
|
|
2022-09-16 10:13:19 +02:00
|
|
|
/** Default key-maps to add. */
|
2012-05-12 22:39:39 +02:00
|
|
|
int keymapflag;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2008-01-07 19:03:41 +01:00
|
|
|
|
2008-12-08 16:02:57 +01:00
|
|
|
/* region types are also defined using spacetypes_init, via a callback */
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct wmRegionListenerParams {
|
|
|
|
wmWindow *window;
|
|
|
|
ScrArea *area; /* Can be NULL when the region is not part of an area. */
|
|
|
|
ARegion *region;
|
|
|
|
const wmNotifier *notifier;
|
|
|
|
const Scene *scene;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wmRegionMessageSubscribeParams {
|
|
|
|
const bContext *context;
|
|
|
|
wmMsgBus *message_bus;
|
|
|
|
WorkSpace *workspace;
|
|
|
|
Scene *scene;
|
|
|
|
bScreen *screen;
|
|
|
|
ScrArea *area;
|
|
|
|
ARegion *region;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RegionPollParams {
|
|
|
|
const bScreen *screen;
|
|
|
|
const ScrArea *area;
|
|
|
|
const ARegion *region;
|
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
|
|
|
|
2023-07-05 17:56:58 +02:00
|
|
|
/** Full context, if WM context above is not enough. */
|
2023-09-25 23:52:54 +02:00
|
|
|
const bContext *context;
|
|
|
|
};
|
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
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct ARegionType {
|
|
|
|
ARegionType *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
int regionid; /* unique identifier within this space, defines RGN_TYPE_xxxx */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-10 14:56:54 +01:00
|
|
|
/* add handlers, stuff you only do once or on area/region type/size changes */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*init)(wmWindowManager *wm, ARegion *region);
|
2013-03-15 20:56:29 +01:00
|
|
|
/* exit is called when the region is hidden or removed */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*exit)(wmWindowManager *wm, ARegion *region);
|
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
|
|
|
/**
|
|
|
|
* Optional callback to decide whether the region should be treated as existing given the
|
|
|
|
* current context. When returning false, the region will be kept in storage, but is not
|
|
|
|
* available to the user in any way. Callbacks can assume that context has the owning area and
|
|
|
|
* space-data set.
|
|
|
|
*/
|
|
|
|
bool (*poll)(const RegionPollParams *params);
|
2008-12-10 14:56:54 +01:00
|
|
|
/* draw entirely, view changes should be handled here */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw)(const bContext *C, ARegion *region);
|
2020-07-17 21:18:54 +02:00
|
|
|
/**
|
|
|
|
* Handler to draw overlays. This handler is called every draw loop.
|
|
|
|
*
|
|
|
|
* \note Some editors should return early if the interface is locked
|
|
|
|
* (check with #CTX_wm_interface_locked) to avoid accessing scene data
|
|
|
|
* that another thread may be modifying
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw_overlay)(const bContext *C, ARegion *region);
|
2018-04-29 12:24:08 +02:00
|
|
|
/* optional, compute button layout before drawing for dynamic size */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*layout)(const bContext *C, ARegion *region);
|
2018-04-26 12:01:44 +02:00
|
|
|
/* snap the size of the region (can be NULL for no snapping). */
|
2023-09-25 23:52:54 +02:00
|
|
|
int (*snap_size)(const ARegion *region, int size, int axis);
|
2008-12-10 14:56:54 +01:00
|
|
|
/* contextual changes should be handled here */
|
2021-01-19 02:59:00 +01:00
|
|
|
void (*listener)(const wmRegionListenerParams *params);
|
2017-11-13 09:43:34 +01:00
|
|
|
/* Optional callback to generate subscriptions. */
|
2021-01-19 02:59:00 +01:00
|
|
|
void (*message_subscribe)(const wmRegionMessageSubscribeParams *params);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*free)(ARegion *);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 17:54:41 +01:00
|
|
|
/* split region, copy data optionally */
|
2018-06-03 15:11:31 +02:00
|
|
|
void *(*duplicate)(void *poin);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-08 16:02:57 +01:00
|
|
|
/* register operator types on startup */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*operatortypes)();
|
2008-12-10 14:56:54 +01:00
|
|
|
/* add own items to keymap */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*keymap)(wmKeyConfig *keyconf);
|
2009-01-04 20:17:34 +01:00
|
|
|
/* allows default cursor per region */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*cursor)(wmWindow *win, ScrArea *area, ARegion *region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-18 03:56:48 +01:00
|
|
|
/* return context data */
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
bContextDataCallback context;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-21 15:08:26 +02:00
|
|
|
/**
|
|
|
|
* Called whenever the user changes the region's size. Not called when the size is changed
|
|
|
|
* through other means, like to adjust for a scaled down window.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*on_user_resize)(const ARegion *region);
|
2020-08-12 12:12:29 +02:00
|
|
|
/* Is called whenever the current visible View2D's region changes.
|
|
|
|
*
|
|
|
|
* Used from user code such as view navigation/zoom operators to inform region about changes.
|
|
|
|
* The goal is to support zoom-to-fit features which gets disabled when manual navigation is
|
|
|
|
* performed.
|
|
|
|
*
|
|
|
|
* This callback is not called on indirect changes of the current viewport (which could happen
|
2021-06-24 07:56:58 +02:00
|
|
|
* when the `v2d->tot is changed and `cur` is adopted accordingly). */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*on_view2d_changed)(const bContext *C, ARegion *region);
|
2020-08-12 12:12:29 +02:00
|
|
|
|
2.5
New: Custom region draw callbacks.
For Martin: an example is now in space_view3d/view3d_edit.c
On middlemouse rotate view, it draws a small square in center.
It works likes this:
#include "ED_space_api.h"
handle= ED_region_draw_cb_activate(region->type, drawfunc, type)
and to stop it:
ED_region_draw_cb_exit(region->type, handle)
drawfunc is of type (const bContext *C, ARegion *ar)
currently it gets called only as type REGION_DRAW_POST, later we
can add more (PRE, POST_XRAY, POST_2D, etc).
For correct usage, these calls should return leaving view transform
unaltered.
2009-01-09 16:04:52 +01:00
|
|
|
/* custom drawing callbacks */
|
2012-05-12 22:39:39 +02:00
|
|
|
ListBase drawcalls;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-29 21:44:39 +02:00
|
|
|
/* panels type definitions */
|
|
|
|
ListBase paneltypes;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-29 21:44:39 +02:00
|
|
|
/* header type definitions */
|
|
|
|
ListBase headertypes;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-10 14:56:54 +01:00
|
|
|
/* hardcoded constraints, smaller than these values region is not visible */
|
2012-05-12 22:39:39 +02:00
|
|
|
int minsizex, minsizey;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 19:18:21 +01:00
|
|
|
/* when new region opens (region prefsizex/y are zero then */
|
2012-05-12 22:39:39 +02:00
|
|
|
int prefsizex, prefsizey;
|
2008-12-10 14:56:54 +01:00
|
|
|
/* default keymaps to add */
|
2012-05-12 22:39:39 +02:00
|
|
|
int keymapflag;
|
2019-04-27 04:07:07 +02:00
|
|
|
/* return without drawing.
|
|
|
|
* lock is set by region definition, and copied to do_lock by render. can become flag. */
|
2012-05-12 22:39:39 +02:00
|
|
|
short do_lock, lock;
|
2020-03-12 15:19:22 +01:00
|
|
|
/** Don't handle gizmos events behind #uiBlock's with #UI_BLOCK_CLIP_EVENTS flag set. */
|
|
|
|
bool clip_gizmo_events_by_ui;
|
2012-05-22 16:13:33 +02:00
|
|
|
/* call cursor function on each move event */
|
|
|
|
short event_cursor;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2008-01-07 19:03:41 +01:00
|
|
|
|
2009-03-29 21:44:39 +02:00
|
|
|
/* panel types */
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct PanelType {
|
|
|
|
PanelType *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-15 15:32:29 +01:00
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
|
|
char label[BKE_ST_MAXNAME]; /* for panel header */
|
2023-06-09 16:41:11 +02:00
|
|
|
const char *description; /* for panel tooltip */
|
2013-03-15 15:32:29 +01:00
|
|
|
char translation_context[BKE_ST_MAXNAME];
|
|
|
|
char context[BKE_ST_MAXNAME]; /* for buttons window */
|
2013-12-16 17:21:55 +01:00
|
|
|
char category[BKE_ST_MAXNAME]; /* for category tabs */
|
2018-06-03 13:32:36 +02:00
|
|
|
char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */
|
2020-06-25 15:13:02 +02:00
|
|
|
char parent_id[BKE_ST_MAXNAME]; /* parent idname for sub-panels */
|
2020-11-30 23:43:14 +01:00
|
|
|
/** Boolean property identifier of the panel custom data. Used to draw a highlighted border. */
|
|
|
|
char active_property[BKE_ST_MAXNAME];
|
2018-07-03 19:50:00 +02:00
|
|
|
short space_type;
|
|
|
|
short region_type;
|
|
|
|
/* For popovers, 0 for default. */
|
|
|
|
int ui_units_x;
|
2019-05-19 11:23:43 +02:00
|
|
|
int order;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
int flag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-03-29 21:44:39 +02:00
|
|
|
/* verify if the panel should draw or not */
|
2023-09-25 23:52:54 +02:00
|
|
|
bool (*poll)(const bContext *C, PanelType *pt);
|
2009-05-19 19:13:33 +02:00
|
|
|
/* draw header (optional) */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw_header)(const bContext *C, Panel *panel);
|
2018-04-27 13:50:26 +02:00
|
|
|
/* draw header preset (optional) */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw_header_preset)(const bContext *C, Panel *panel);
|
2009-03-29 21:44:39 +02:00
|
|
|
/* draw entirely, view changes should be handled here */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw)(const bContext *C, Panel *panel);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-26 21:39:49 +02:00
|
|
|
/* For instanced panels corresponding to a list: */
|
|
|
|
|
|
|
|
/** Reorder function, called when drag and drop finishes. */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*reorder)(bContext *C, Panel *pa, int new_index);
|
2020-05-26 21:39:49 +02:00
|
|
|
/**
|
2020-05-29 04:58:07 +02:00
|
|
|
* Get the panel and sub-panel's expansion state from the expansion flag in the corresponding
|
|
|
|
* data item. Called on draw updates.
|
|
|
|
* \note Sub-panels are indexed in depth first order,
|
|
|
|
* the visual order you would see if all panels were expanded.
|
2020-05-26 21:39:49 +02:00
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
short (*get_list_data_expand_flag)(const bContext *C, Panel *pa);
|
2020-05-26 21:39:49 +02:00
|
|
|
/**
|
2020-05-29 04:58:07 +02:00
|
|
|
* Set the expansion bit-field from the closed / open state of this panel and its sub-panels.
|
2020-05-26 21:39:49 +02:00
|
|
|
* Called when the expansion state of the panel changes with user input.
|
2020-05-29 04:58:07 +02:00
|
|
|
* \note Sub-panels are indexed in depth first order,
|
|
|
|
* the visual order you would see if all panels were expanded.
|
2020-05-26 21:39:49 +02:00
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*set_list_data_expand_flag)(const bContext *C, Panel *pa, short expand_flag);
|
2020-05-26 21:39:49 +02:00
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
/* sub panels */
|
2023-09-25 23:52:54 +02:00
|
|
|
PanelType *parent;
|
2018-06-03 13:32:36 +02:00
|
|
|
ListBase children;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
/* RNA integration */
|
2020-04-03 18:24:08 +02:00
|
|
|
ExtensionRNA rna_ext;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2009-03-29 21:44:39 +02:00
|
|
|
|
2020-11-13 19:15:41 +01:00
|
|
|
/* #PanelType.flag */
|
|
|
|
enum {
|
2020-11-13 19:56:55 +01:00
|
|
|
PANEL_TYPE_DEFAULT_CLOSED = (1 << 0),
|
|
|
|
PANEL_TYPE_NO_HEADER = (1 << 1),
|
2020-11-13 19:15:41 +01:00
|
|
|
/** Makes buttons in the header shrink/stretch to fill full layout width. */
|
2020-11-13 19:56:55 +01:00
|
|
|
PANEL_TYPE_HEADER_EXPAND = (1 << 2),
|
|
|
|
PANEL_TYPE_LAYOUT_VERT_BAR = (1 << 3),
|
2020-11-13 19:15:41 +01:00
|
|
|
/** This panel type represents data external to the UI. */
|
2020-11-13 19:56:55 +01:00
|
|
|
PANEL_TYPE_INSTANCED = (1 << 4),
|
2020-11-17 16:17:00 +01:00
|
|
|
/** Don't search panels with this type during property search. */
|
|
|
|
PANEL_TYPE_NO_SEARCH = (1 << 7),
|
2020-11-13 19:15:41 +01:00
|
|
|
};
|
|
|
|
|
2023-09-26 11:50:04 +02:00
|
|
|
/* #uiList types. */
|
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
|
|
|
|
2023-09-26 11:50:04 +02:00
|
|
|
/** Draw an item in the `ui_list`. */
|
2023-09-25 23:52:54 +02:00
|
|
|
using uiListDrawItemFunc = void (*)(uiList *ui_list,
|
|
|
|
const bContext *C,
|
|
|
|
uiLayout *layout,
|
|
|
|
PointerRNA *dataptr,
|
|
|
|
PointerRNA *itemptr,
|
|
|
|
int icon,
|
|
|
|
PointerRNA *active_dataptr,
|
|
|
|
const char *active_propname,
|
|
|
|
int index,
|
|
|
|
int flt_flag);
|
2013-08-29 14:55:31 +02:00
|
|
|
|
|
|
|
/* Draw the filtering part of an uiList */
|
2023-09-25 23:52:54 +02:00
|
|
|
using uiListDrawFilterFunc = void (*)(uiList *ui_list, const bContext *C, uiLayout *layout);
|
2013-08-29 14:55:31 +02:00
|
|
|
|
|
|
|
/* Filter items of an uiList */
|
2023-09-25 23:52:54 +02:00
|
|
|
using uiListFilterItemsFunc = void (*)(uiList *ui_list,
|
|
|
|
const bContext *C,
|
|
|
|
PointerRNA *,
|
|
|
|
const char *propname);
|
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
|
|
|
|
UI/Assets: Initial Asset View UI template
The asset view UI template is a mini-version of the Asset Browser that
can be placed in regular layouts, regions or popups. At this point it's
made specifically for placement in vertical layouts, it can be made more
flexible in the future.
Generally the way this is implemented will likely change a lot still as
the asset system evolves.
The Pose Library add-on will use the asset view to display pose
libraries in the 3D View sidebar.
References:
* https://developer.blender.org/T86139
* https://code.blender.org/2021/06/asset-browser-project-update/#what-are-we-building
* https://code.blender.org/2021/05/pose-library-v2-0/#use-from-3d-viewport
Notes:
* Important limitation: Due to the early & WIP implementation of the
asset list, all asset views showing the same library will show the
same assets. That is despite the ID type filter option the template
provides. The first asset view created will determine what's visible.
Of course this should be made to work eventually.
* The template supports passing an activate and a drag operator name.
The former is called when an asset is clicked on (e.g. to apply the
asset) the latter when dragging (e.g. to .blend a pose asset). If no
drag operator is set, regular asset drag & drop will be executed.
* The template returns the properties for both operators (see example
below).
* The argument list for using the template is quite long, but we can't
avoid that currently. The UI list design requires that we pass a
number of RNA or custom properties to work with, that for the Pose
Libraries should be registered at the Pose Library add-on level, not
in core Blender.
* Idea is that Python scripts or add-ons that want to use the asset view
can register custom properties, to hold data like the list of assets,
and the active asset index. Maybe that will change in future and we
can manage these internally.
As an example, the pose library add-on uses it like this:
```
activate_op_props, drag_op_props = layout.template_asset_view(
"pose_assets",
workspace,
"active_asset_library",
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
filter_id_types={"filter_action"},
activate_operator="poselib.apply_pose_asset",
drag_operator="poselib.blend_pose_asset",
)
drag_op_props.release_confirm = True
drag_op_props.flipped = wm.poselib_flipped
activate_op_props.flipped = wm.poselib_flipped
```
2021-07-13 18:07:57 +02:00
|
|
|
/* Listen to notifiers. Only for lists defined in C. */
|
2023-09-25 23:52:54 +02:00
|
|
|
using uiListListener = void (*)(uiList *ui_list, wmRegionListenerParams *params);
|
UI/Assets: Initial Asset View UI template
The asset view UI template is a mini-version of the Asset Browser that
can be placed in regular layouts, regions or popups. At this point it's
made specifically for placement in vertical layouts, it can be made more
flexible in the future.
Generally the way this is implemented will likely change a lot still as
the asset system evolves.
The Pose Library add-on will use the asset view to display pose
libraries in the 3D View sidebar.
References:
* https://developer.blender.org/T86139
* https://code.blender.org/2021/06/asset-browser-project-update/#what-are-we-building
* https://code.blender.org/2021/05/pose-library-v2-0/#use-from-3d-viewport
Notes:
* Important limitation: Due to the early & WIP implementation of the
asset list, all asset views showing the same library will show the
same assets. That is despite the ID type filter option the template
provides. The first asset view created will determine what's visible.
Of course this should be made to work eventually.
* The template supports passing an activate and a drag operator name.
The former is called when an asset is clicked on (e.g. to apply the
asset) the latter when dragging (e.g. to .blend a pose asset). If no
drag operator is set, regular asset drag & drop will be executed.
* The template returns the properties for both operators (see example
below).
* The argument list for using the template is quite long, but we can't
avoid that currently. The UI list design requires that we pass a
number of RNA or custom properties to work with, that for the Pose
Libraries should be registered at the Pose Library add-on level, not
in core Blender.
* Idea is that Python scripts or add-ons that want to use the asset view
can register custom properties, to hold data like the list of assets,
and the active asset index. Maybe that will change in future and we
can manage these internally.
As an example, the pose library add-on uses it like this:
```
activate_op_props, drag_op_props = layout.template_asset_view(
"pose_assets",
workspace,
"active_asset_library",
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
filter_id_types={"filter_action"},
activate_operator="poselib.apply_pose_asset",
drag_operator="poselib.blend_pose_asset",
)
drag_op_props.release_confirm = True
drag_op_props.flipped = wm.poselib_flipped
activate_op_props.flipped = wm.poselib_flipped
```
2021-07-13 18:07:57 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct uiListType {
|
|
|
|
uiListType *next, *prev;
|
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
|
|
|
|
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
|
|
|
|
|
|
uiListDrawItemFunc draw_item;
|
2013-08-29 14:55:31 +02:00
|
|
|
uiListDrawFilterFunc draw_filter;
|
|
|
|
uiListFilterItemsFunc filter_items;
|
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
|
|
|
|
UI/Assets: Initial Asset View UI template
The asset view UI template is a mini-version of the Asset Browser that
can be placed in regular layouts, regions or popups. At this point it's
made specifically for placement in vertical layouts, it can be made more
flexible in the future.
Generally the way this is implemented will likely change a lot still as
the asset system evolves.
The Pose Library add-on will use the asset view to display pose
libraries in the 3D View sidebar.
References:
* https://developer.blender.org/T86139
* https://code.blender.org/2021/06/asset-browser-project-update/#what-are-we-building
* https://code.blender.org/2021/05/pose-library-v2-0/#use-from-3d-viewport
Notes:
* Important limitation: Due to the early & WIP implementation of the
asset list, all asset views showing the same library will show the
same assets. That is despite the ID type filter option the template
provides. The first asset view created will determine what's visible.
Of course this should be made to work eventually.
* The template supports passing an activate and a drag operator name.
The former is called when an asset is clicked on (e.g. to apply the
asset) the latter when dragging (e.g. to .blend a pose asset). If no
drag operator is set, regular asset drag & drop will be executed.
* The template returns the properties for both operators (see example
below).
* The argument list for using the template is quite long, but we can't
avoid that currently. The UI list design requires that we pass a
number of RNA or custom properties to work with, that for the Pose
Libraries should be registered at the Pose Library add-on level, not
in core Blender.
* Idea is that Python scripts or add-ons that want to use the asset view
can register custom properties, to hold data like the list of assets,
and the active asset index. Maybe that will change in future and we
can manage these internally.
As an example, the pose library add-on uses it like this:
```
activate_op_props, drag_op_props = layout.template_asset_view(
"pose_assets",
workspace,
"active_asset_library",
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
filter_id_types={"filter_action"},
activate_operator="poselib.apply_pose_asset",
drag_operator="poselib.blend_pose_asset",
)
drag_op_props.release_confirm = True
drag_op_props.flipped = wm.poselib_flipped
activate_op_props.flipped = wm.poselib_flipped
```
2021-07-13 18:07:57 +02:00
|
|
|
/* For lists defined in C only. */
|
|
|
|
uiListListener listener;
|
|
|
|
|
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
|
|
|
/* RNA integration */
|
2020-04-03 18:24:08 +02:00
|
|
|
ExtensionRNA rna_ext;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
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
|
|
|
|
2009-03-29 21:44:39 +02:00
|
|
|
/* header types */
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct HeaderType {
|
|
|
|
HeaderType *next, *prev;
|
2009-03-29 21:44:39 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
|
|
int space_type;
|
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
|
|
|
int region_type;
|
2009-03-29 21:44:39 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
bool (*poll)(const bContext *C, HeaderType *ht);
|
2009-03-29 21:44:39 +02:00
|
|
|
/* draw entirely, view changes should be handled here */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw)(const bContext *C, Header *header);
|
2009-03-29 21:44:39 +02:00
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
/* RNA integration */
|
2020-04-03 18:24:08 +02:00
|
|
|
ExtensionRNA rna_ext;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2008-01-07 19:03:41 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct Header {
|
|
|
|
HeaderType *type; /* runtime */
|
|
|
|
uiLayout *layout; /* runtime for drawing */
|
|
|
|
};
|
2009-07-21 03:14:55 +02:00
|
|
|
|
2009-04-22 20:39:44 +02:00
|
|
|
/* menu types */
|
|
|
|
|
2023-09-06 10:01:00 +02:00
|
|
|
enum class MenuTypeFlag {
|
|
|
|
/**
|
|
|
|
* Whether the menu depends on data retrieved via #CTX_data_pointer_get. If it is context
|
|
|
|
* dependent, menu search has to scan it in different contexts.
|
|
|
|
*/
|
|
|
|
ContextDependent = (1 << 0),
|
2023-09-06 18:16:45 +02:00
|
|
|
/**
|
|
|
|
* Automatically start searching in the menu when pressing a key.
|
|
|
|
*/
|
|
|
|
SearchOnKeyPress = (1 << 1),
|
2023-09-06 10:01:00 +02:00
|
|
|
};
|
|
|
|
ENUM_OPERATORS(MenuTypeFlag, MenuTypeFlag::ContextDependent)
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct MenuType {
|
|
|
|
MenuType *next, *prev;
|
2009-04-22 20:39:44 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
|
|
char label[BKE_ST_MAXNAME]; /* for button text */
|
2013-03-15 15:32:29 +01:00
|
|
|
char translation_context[BKE_ST_MAXNAME];
|
2018-02-28 15:26:02 +01:00
|
|
|
char owner_id[BKE_ST_MAXNAME]; /* optional, see: #wmOwnerID */
|
2014-02-06 21:39:44 +01:00
|
|
|
const char *description;
|
2009-04-22 20:39:44 +02:00
|
|
|
|
|
|
|
/* verify if the menu should draw or not */
|
2023-09-25 23:52:54 +02:00
|
|
|
bool (*poll)(const bContext *C, MenuType *mt);
|
2009-04-22 20:39:44 +02:00
|
|
|
/* draw entirely, view changes should be handled here */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw)(const bContext *C, Menu *menu);
|
2022-11-01 17:36:36 +01:00
|
|
|
void (*listener)(const wmRegionListenerParams *params);
|
2009-04-22 20:39:44 +02:00
|
|
|
|
2023-09-06 10:01:00 +02:00
|
|
|
MenuTypeFlag flag;
|
2023-08-31 18:56:57 +02:00
|
|
|
|
2009-07-21 22:05:16 +02:00
|
|
|
/* RNA integration */
|
2020-04-03 18:24:08 +02:00
|
|
|
ExtensionRNA rna_ext;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2009-04-22 20:39:44 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct Menu {
|
|
|
|
MenuType *type; /* runtime */
|
|
|
|
uiLayout *layout; /* runtime for drawing */
|
|
|
|
};
|
2009-07-21 03:14:55 +02:00
|
|
|
|
2023-08-03 16:54:39 +02:00
|
|
|
/* asset shelf types */
|
|
|
|
|
|
|
|
/* #AssetShelfType.flag */
|
2023-09-25 23:52:54 +02:00
|
|
|
enum AssetShelfTypeFlag {
|
2023-08-03 16:54:39 +02:00
|
|
|
/** Do not trigger asset dragging on drag events. Drag events can be overridden with custom
|
|
|
|
* keymap items then. */
|
|
|
|
ASSET_SHELF_TYPE_FLAG_NO_ASSET_DRAG = (1 << 0),
|
|
|
|
|
|
|
|
ASSET_SHELF_TYPE_FLAG_MAX
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2023-08-03 16:54:39 +02:00
|
|
|
ENUM_OPERATORS(AssetShelfTypeFlag, ASSET_SHELF_TYPE_FLAG_MAX);
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
struct AssetShelfType {
|
|
|
|
AssetShelfType *next, *prev;
|
2023-08-03 16:54:39 +02:00
|
|
|
|
|
|
|
char idname[BKE_ST_MAXNAME]; /* unique name */
|
|
|
|
|
|
|
|
int space_type;
|
|
|
|
|
|
|
|
AssetShelfTypeFlag flag;
|
|
|
|
|
|
|
|
/** Determine if asset shelves of this type should be available in current context or not. */
|
2023-09-25 23:52:54 +02:00
|
|
|
bool (*poll)(const bContext *C, const AssetShelfType *shelf_type);
|
2023-08-03 16:54:39 +02:00
|
|
|
|
|
|
|
/** Determine if an individual asset should be visible or not. May be a temporary design,
|
|
|
|
* visibility should first and foremost be controlled by asset traits. */
|
2023-09-25 23:52:54 +02:00
|
|
|
bool (*asset_poll)(const AssetShelfType *shelf_type,
|
|
|
|
const blender::asset_system::AssetRepresentation *asset);
|
2023-08-03 16:54:39 +02:00
|
|
|
|
|
|
|
/** Asset shelves can define their own context menu via this layout definition callback. */
|
2023-09-25 23:52:54 +02:00
|
|
|
void (*draw_context_menu)(const bContext *C,
|
|
|
|
const AssetShelfType *shelf_type,
|
|
|
|
const blender::asset_system::AssetRepresentation *asset,
|
|
|
|
uiLayout *layout);
|
2023-08-03 16:54:39 +02:00
|
|
|
|
|
|
|
/* RNA integration */
|
|
|
|
ExtensionRNA rna_ext;
|
2023-09-25 23:52:54 +02:00
|
|
|
};
|
2023-08-03 16:54:39 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* Space-types. */
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
SpaceType *BKE_spacetype_from_id(int spaceid);
|
|
|
|
ARegionType *BKE_regiontype_from_id(const SpaceType *st, int regionid);
|
|
|
|
const ListBase *BKE_spacetypes_list();
|
|
|
|
void BKE_spacetype_register(SpaceType *st);
|
2015-01-21 03:43:46 +01:00
|
|
|
bool BKE_spacetype_exists(int spaceid);
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_spacetypes_free(); /* only for quitting blender */
|
2008-12-08 16:02:57 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* Space-data. */
|
|
|
|
|
2008-01-07 19:03:41 +01:00
|
|
|
void BKE_spacedata_freelist(ListBase *lb);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
2021-12-07 08:26:35 +01:00
|
|
|
* \param lb_dst: should be empty (will be cleared).
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2021-12-07 08:26:35 +01:00
|
|
|
void BKE_spacedata_copylist(ListBase *lb_dst, ListBase *lb_src);
|
2021-12-07 07:19:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Facility to set locks for drawing to survive (render) threads accessing drawing data.
|
|
|
|
*
|
|
|
|
* \note Lock can become bit-flag too.
|
|
|
|
* \note Should be replaced in future by better local data handling for threads.
|
|
|
|
*/
|
2021-02-26 06:50:36 +01:00
|
|
|
void BKE_spacedata_draw_locks(bool set);
|
2008-01-07 19:03:41 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Version of #BKE_area_find_region_type that also works if \a slink
|
|
|
|
* is not the active space of \a area.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink,
|
|
|
|
const ScrArea *area,
|
|
|
|
int region_type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
2018-11-25 16:21:35 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_spacedata_callback_id_remap_set(
|
|
|
|
void (*func)(ScrArea *area, SpaceLink *sl, ID *old_id, ID *new_id));
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Currently unused!
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_spacedata_id_unref(ScrArea *area, SpaceLink *sl, ID *id);
|
2015-05-04 07:07:24 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* Area/regions. */
|
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Doesn't free the region itself.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_area_region_free(SpaceType *st, ARegion *region);
|
|
|
|
void BKE_area_region_panels_free(ListBase *panels);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Doesn't free the area itself.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_area_free(ScrArea *area);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Gizmo-maps of a region need to be freed with the region.
|
|
|
|
* Uses callback to avoid low-level call.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_region_callback_free_gizmomap_set(void (*callback)(wmGizmoMap *));
|
|
|
|
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(wmGizmoMap *));
|
2008-12-14 18:25:46 +01:00
|
|
|
|
2022-06-24 10:23:31 +02:00
|
|
|
/**
|
|
|
|
* Find a region of type \a region_type in provided \a regionbase.
|
|
|
|
*
|
|
|
|
* \note this is useful for versioning where either the #Area or #SpaceLink regionbase are typical
|
|
|
|
* inputs
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_region_find_in_listbase_by_type(const ListBase *regionbase, const int region_type);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find a region of type \a region_type in the currently active space of \a area.
|
|
|
|
*
|
|
|
|
* \note This does _not_ work if the region to look up is not in the active space.
|
|
|
|
* Use #BKE_spacedata_find_region_type if that may be the case.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_area_find_region_type(const ScrArea *area, int type);
|
|
|
|
ARegion *BKE_area_find_region_active_win(const ScrArea *area);
|
|
|
|
ARegion *BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2])
|
|
|
|
ATTR_NONNULL(3);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \note This is only for screen level regions (typically menus/popups).
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_screen_find_region_xy(const bScreen *screen,
|
|
|
|
int regiontype,
|
|
|
|
const int xy[2]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 3);
|
2019-07-01 04:10:49 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
ARegion *BKE_screen_find_main_region_at_xy(const bScreen *screen, int space_type, const int xy[2])
|
|
|
|
ATTR_NONNULL(1, 3);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \note Ideally we can get the area from the context,
|
|
|
|
* there are a few places however where this isn't practical.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ScrArea *BKE_screen_find_area_from_space(const bScreen *screen,
|
|
|
|
const SpaceLink *sl) ATTR_WARN_UNUSED_RESULT
|
2015-01-07 15:14:07 +01:00
|
|
|
ATTR_NONNULL(1, 2);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \note Using this function is generally a last resort, you really want to be
|
|
|
|
* using the context when you can - campbell
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
ScrArea *BKE_screen_find_big_area(const bScreen *screen, int spacetype, short min);
|
|
|
|
ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap,
|
|
|
|
int spacetype,
|
|
|
|
const int xy[2]) ATTR_NONNULL(1, 3);
|
|
|
|
ScrArea *BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2])
|
|
|
|
ATTR_NONNULL(1, 3);
|
|
|
|
|
|
|
|
void BKE_screen_gizmo_tag_refresh(bScreen *screen);
|
|
|
|
|
|
|
|
void BKE_screen_view3d_sync(View3D *v3d, Scene *scene);
|
|
|
|
void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene);
|
|
|
|
bool BKE_screen_is_fullscreen_area(const bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
|
|
|
bool BKE_screen_is_used(const bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
2010-04-22 21:57:18 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* Zoom factor conversion. */
|
|
|
|
|
2011-05-20 06:14:29 +02:00
|
|
|
float BKE_screen_view3d_zoom_to_fac(float camzoom);
|
|
|
|
float BKE_screen_view3d_zoom_from_fac(float zoomfac);
|
2010-04-22 21:57:18 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_view3d_shading_init(View3DShading *shading);
|
2018-07-11 11:43:56 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* Screen. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback used by lib_query to walk over all ID usages
|
|
|
|
* (mimics `foreach_id` callback of #IDTypeInfo structure).
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area);
|
2020-05-18 18:51:06 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Free (or release) any data used by this screen (does not free the screen itself).
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_free_data(bScreen *screen);
|
|
|
|
void BKE_screen_area_map_free(ScrAreaMap *area_map) ATTR_NONNULL();
|
2008-12-14 18:25:46 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
ScrEdge *BKE_screen_find_edge(const bScreen *screen, ScrVert *v1, ScrVert *v2);
|
|
|
|
void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2);
|
|
|
|
void BKE_screen_remove_double_scrverts(bScreen *screen);
|
|
|
|
void BKE_screen_remove_double_scredges(bScreen *screen);
|
|
|
|
void BKE_screen_remove_unused_scredges(bScreen *screen);
|
|
|
|
void BKE_screen_remove_unused_scrverts(bScreen *screen);
|
2018-04-13 21:43:57 +02:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_header_alignment_reset(bScreen *screen);
|
2019-02-06 11:15:39 +01:00
|
|
|
|
2020-10-30 14:44:03 +01:00
|
|
|
/* .blend file I/O */
|
2021-12-07 07:19:15 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading);
|
|
|
|
void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading);
|
2020-10-30 14:44:03 +01:00
|
|
|
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \return false on error.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *area_map);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* And as patch for 2.48 and older.
|
2023-03-29 05:16:31 +02:00
|
|
|
* For the saved 2.50 files without `regiondata`.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions);
|
2023-03-11 18:07:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after lib linking process is done, to perform some validation on the read data, or some
|
|
|
|
* complex specific reading process that requires the data to be fully read and ID pointers to be
|
|
|
|
* valid.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
void BKE_screen_area_blend_read_after_liblink(BlendLibReader *reader,
|
|
|
|
ID *parent_id,
|
|
|
|
ScrArea *area);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Cannot use #IDTypeInfo callback yet, because of the return value.
|
|
|
|
*/
|
2023-09-25 23:52:54 +02:00
|
|
|
bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen);
|