UI: Generalize drop target API, support them for UI views #105963
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105963
Loading…
Reference in New Issue
No description provided.
Delete Branch "JulianEisel:temp-ui-view-drop-controller"
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?
Previously UI view items would support custom drop controllers (so they
could react to data being dragged over them and dropped). This is now
more generalized so the views themselves can do this as well.
3 main changes:
ui::DropControllerInterface
now.ui::AbstractView
base class, so custom views can use this.First of all, good to generalize the idea of a drop target, I think that's helpful. However, with these interfaces, inheritance, etc. I'm a bit afraid that we're heading in the direction of having massive class hierarchies that will end up being overwhelming and hard to grasp.
Without a full understanding of the issue, it's hard for me to suggest alternatives, but I wonder if a few things would help:
ControllerInterface
, quite technically correct I guess, is pretty vague and theoretical. I think simplyDropTarget
would be a simpler name that gets the same things across.DropTarget
can still have virtual methods and be inherited from, but at least it corresponds to a real thing that's more easily imaginable.DropHandler
might work too.UI_
wrapper functionsDo you think that's reasonable. I know it's hard to move towards a proper design when the existing UI code is so hard to change.
@ -56,1 +62,4 @@
/**
* Interface class to implement dropping for various kinds of UI elements. This isn't used widely,
* only UI views and view items use it. Would probably be nice to have more general support for
This sort of "would probably be nice to use this more in the future" comment shouldn't be added to main I think. That makes sense in code documentation or design tasks, but the code should stand for itself generally, and this comment will just become out of date otherwise.
@ -113,0 +165,4 @@
* Call #DropControllerInterface::drop_tooltip() and return the result as newly allocated C string
* (unless the result is empty, returns null then). Needs freeing with MEM_freeN().
*/
char *UI_drop_controller_drop_tooltip(const blender::ui::DropControllerInterface &drop_controller,
Ideally new functions added to this UI C++ header should be in the proper
blender::ed::ui
(looks like it'sblender::ui
right now, oops!) namespace, without theUI_
prefix. Might as well start that now IMO.I'm well aware of the short comings of inheritance and actually often try to avoid it. But for this kind of thing it just makes a lot of sense. For a while there was no common base class for views for example and I tried to share behavior differently. But this caused more trouble than it was helpful.
The views API is already becoming a bit too complex (or inelegant) for my taste although it's not too bad yet. We're still early in exploring this. Generalizing features like dropping out of the views already seems like an improvement in that regard.
I think I'd like to go with
DropTargetInterface
for now. Interface is just a good reminder that this is a base class, and may avoid accidental object slicing. No strong opinion though.Some of them I'm just keeping because I want to keep the
reinterpret_cast
s from the C handle to the C++ type local to the implementation files. Hopefully we can get rid of the casting on the longer run.Briefly checking the code, I think we can get rid of
uiViewHandle
anduiViewItemHandle
easily now, and call the member functions directly instead of requiringUI_
wrappers.@ -113,0 +165,4 @@
* Call #DropControllerInterface::drop_tooltip() and return the result as newly allocated C string
* (unless the result is empty, returns null then). Needs freeing with MEM_freeN().
*/
char *UI_drop_controller_drop_tooltip(const blender::ui::DropControllerInterface &drop_controller,
Hmmm, I just can't myself to like non-member API functions that don't start with a prefix like
UI_
. It just looks like local functions to me, not API functions.Not sure if this is a reasonable concern, or just me having this too deeply embedded in my brain cells :)
@ -113,0 +165,4 @@
* (unless the result is empty, returns null then). Needs freeing with MEM_freeN().
*/
char *UI_drop_target_tooltip(const blender::ui::DropTargetInterface &drop_target,
const wmDrag &drag);
TBH I'd guess it's just something you're used to. With namespaces, it will usually be something like
ui::public_function_thing(...)
anyway, so the information is there it just looks different. That way it elegantly replaces the need for theui_
prefix too.I think consistency is worth it here.
@ -113,0 +165,4 @@
* (unless the result is empty, returns null then). Needs freeing with MEM_freeN().
*/
char *UI_drop_target_tooltip(const blender::ui::DropTargetInterface &drop_target,
const wmDrag &drag);
Still causes some itches to me, but that won't change unless I try hard enough ;/
UI: Generalize drop controllers, support them for UI viewsto UI: Generalize drop target API, support them for UI viewsCommitted as
a2d0f7049a
.Pull request closed