Fix: Remove duplicate image_add operators in the 3D view port #118973

Merged
Sebastian Parborg merged 1 commits from ZedDB/blender:fix_image_add into main 2024-03-11 16:18:34 +01:00

As part of #118623, we discovered that the operator used for adding images in the 3D viewport was not the same when drag and dropping as when adding it from the add menu. This lead to different and potentially confusing behaviour for the user when they use both.

This patch removes the python operator and unifies the functionality into one operator. It also renames the operator to be in line with the other "Add X" object operators.

As part of #118623, we discovered that the operator used for adding images in the 3D viewport was not the same when drag and dropping as when adding it from the add menu. This lead to different and potentially confusing behaviour for the user when they use both. This patch removes the python operator and unifies the functionality into one operator. It also renames the operator to be in line with the other "Add X" object operators.
Sebastian Parborg added the
Module
User Interface
label 2024-03-01 18:58:41 +01:00
Sebastian Parborg requested review from Campbell Barton 2024-03-01 19:00:26 +01:00
Sebastian Parborg requested review from Julian Eisel 2024-03-01 19:00:26 +01:00
Campbell Barton requested changes 2024-03-08 04:29:59 +01:00
@ -1284,3 +1322,3 @@
}
void OBJECT_OT_drop_named_image(wmOperatorType *ot)
void OBJECT_OT_image_add(wmOperatorType *ot)

The name OBJECT_OT_empty_image_add clearer this makes it more obvious this adds and empty object.

The name `OBJECT_OT_empty_image_add` clearer this makes it more obvious this adds and empty object.
ZedDB marked this conversation as resolved
@ -1294,3 +1330,3 @@
/* api callbacks */
ot->invoke = empty_drop_named_image_invoke;
ot->invoke = image_add_invoke;

These read as if they handle image data blocks, perhaps object_image_add_* could be used as a prefix.

These read as if they handle image data blocks, perhaps `object_image_add_*` could be used as a prefix.
ZedDB marked this conversation as resolved
@ -877,6 +877,14 @@ static void view3d_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
{
ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0);
if (STREQ(drop->opname, "OBJECT_OT_image_add")) {

Initializing defaults here seems odd, this could be set in the image_add_invoke code-path that deals with dropping an image, initializing it based on the 3D view-port if the property hasn't been set.

Initializing defaults here seems odd, this could be set in the `image_add_invoke` code-path that deals with dropping an image, initializing it based on the 3D view-port if the property hasn't been set.
ZedDB marked this conversation as resolved
@ -591,3 +583,3 @@
}
static bool background_image_add_poll(bContext *C)
static int camera_background_image_add_invoke(bContext *C,

This invoke function can be removed if it's only calling exec.

This invoke function can be removed if it's only calling exec.
ZedDB marked this conversation as resolved
@ -616,0 +618,4 @@
true,
"Relative Path",
"Select the file relative to the blend file");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));

*picky* (PropertyFlag)(...) can use a function style cast PropertyFlag(...).

\*picky\* `(PropertyFlag)(...)` can use a function style cast `PropertyFlag(...)`.
ZedDB marked this conversation as resolved
Sebastian Parborg requested review from Campbell Barton 2024-03-08 17:29:42 +01:00
Campbell Barton approved these changes 2024-03-09 06:25:20 +01:00
Campbell Barton left a comment
Owner

Accepting with minor requests.

Accepting with minor requests.
@ -1241,0 +1293,4 @@
/* Check if we should switch to "background" mode. */
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d->persp != RV3D_PERSP) {
RNA_boolean_set(op->ptr, "background", true);

This should only be set if the value isn't set, RNA_struct_property_is_set.

This should only be set if the value isn't set, `RNA_struct_property_is_set`.
ZedDB marked this conversation as resolved
@ -1315,0 +1364,4 @@
RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE));
/* Hide the filepath and relative path prop */
prop = RNA_struct_type_find_property(ot->srna, "filepath");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_PRESET));

(PropertyFlag)(...) -> PropertyFlag(...)

`(PropertyFlag)(...)` -> `PropertyFlag(...)`
ZedDB marked this conversation as resolved
Author
Member

@blender-bot build

@blender-bot build
Sebastian Parborg force-pushed fix_image_add from 03fcd4bc54 to 25c773eb73 2024-03-11 16:16:30 +01:00 Compare
Sebastian Parborg merged commit 013cd3d1ba into main 2024-03-11 16:18:34 +01:00
Sebastian Parborg deleted branch fix_image_add 2024-03-11 16:18:36 +01:00
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118973
No description provided.