UI: Region polling support #105088
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105088
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "JulianEisel/blender:temp-region-poll"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
Notes:
V2D_IS_INIT
is unset for that, which isn't great. Could be improved, but not a new issue.Behavior change:
This patch makes it disappear entirely.
Implementation
ARegionType.poll()
RGN_FLAG_POLL_FAILED
- runtime-only flag).WIP: UI: Region polling supportto UI: Region polling supportJulian Eisel referenced this pull request2023-02-24 15:45:12 +01:00
The big picture seems like an improvement. The region management in most editors was a bit ugly and this is a more general solution.
@ -164,6 +164,11 @@ typedef struct ARegionType {
void (*init)(struct wmWindowManager *wm, struct ARegion *region);
/* exit is called when the region is hidden or removed */
void (*exit)(struct wmWindowManager *wm, struct ARegion *region);
/** Optional callback to decide whether the region should be treated as existing given the
@ -2081,0 +2090,4 @@
case SPACE_FILE: {
ARegion *new_region;
new_region = do_versions_add_region_if_not_found(
How about something like this?
@ -49,0 +53,4 @@
ARegion *do_versions_ensure_region(ListBase *regionbase,
int region_type,
const char *allocname,
Do we really need to pass a name for the allocation here? Are we finding memory leaks that aren't easily found with ASAN nowadays?
@ -49,0 +66,4 @@
}
}
ARegion *new_region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), allocname));
MEM_callocN
->MEM_cnew
@ -49,0 +53,4 @@
ARegion *do_versions_ensure_region(ListBase *regionbase,
int region_type,
const char *allocname,
I think it's useful. I use it fairly often, and not everybody has ASan enabled. But sure, with ASan you don't need it I guess.
Julian Eisel referenced this pull request2023-03-30 13:01:58 +02:00
Overall this patch seems fine, one request inline.
@ -167,0 +170,4 @@
* available to the user in any way. Callbacks can assume that context has the owning area and
* space-data set.
*/
bool (*poll)(const struct bContext *C);
As this function runs a lot I think it would be best to take screen variables directly, e.g.
(wm, area, region)
arguments and not set the context.To expand on this, in tests with some basic interaction the
region_poll
function runs ~19 times on frame change with the default scene, the same on mouse wheel and mouse motion with some modal operators.Testing some basic interactivity - this function can run 10's of thousands of times in a minute or so
While I don't see this as a problem for simple checks - passing in the necessary arguments ensures slower lookups aren't used. It's also in keeping with other callbacks which take windowing arguments.
Even in this patch the function calls for data-access aren't as directly as they might be:
CTX_wm_space_clip(C)
calls intoCTX_wm_area(..)
->ctx_wm_python_context_get(..)
, thenCTX_py_dict_get(C)
&BLI_thread_is_main()
.If you anticipate needing access to data besides the area/region in the future, a parameters struct could be used instead of multiple arguments - so the scene or window can be added without having to update the function signature for every poll() function.
@ -164,6 +172,13 @@ typedef struct ARegionType {
void (*init)(struct wmWindowManager *wm, struct ARegion *region);
/* exit is called when the region is hidden or removed */
Doesn't seem like a real issue, for the majority of regions there is no poll function and so
region_poll()
early exists before any context access. But sure, easy enough of a change.