Commit Graph

252 Commits

Author SHA1 Message Date
Harley Acheson
7c3db55b29 Refactor: Simplify Block Re-centering
PR #129125 allowed the movement of centered dialogs, like About and
Splash, without them snapping back to their original positions. But
that change was more complex than necessary. This returns
interface_region_popup.cc to exactly as it was before any of this, and
interface.cc gets simpler too. In a nutshell recentering these dialogs
is a lot easier that seemed at first.

Pull Request: https://projects.blender.org/blender/blender/pulls/131464
2024-12-06 00:57:32 +01:00
Harley Acheson
154ab16ee2 Fix #128419: Allow the Positioning of Centered Dialogs
Some popups are positioned centered in the window, like "Splash",
"About", and the large confirmations. But when you drag these to
a different location they will snap back when there is any window
interaction.  This PR allows you to move these popups and they will
stay in the new location.

Pull Request: https://projects.blender.org/blender/blender/pulls/129125
2024-12-02 22:01:05 +01:00
Hans Goudey
2b20871216 Cleanup: Move region UI block name map from GHash to Map 2024-11-21 14:04:34 -05:00
Hans Goudey
129a2aa0f4 Refactor: Move region runtime data out of DNA
Pull Request: https://projects.blender.org/blender/blender/pulls/130303
2024-11-21 19:34:53 +01:00
Julian Eisel
f0db870822 UI: Support persistent view state, write tree-view height to files
Adds support for saving some view state persistently and uses this to keep the
height of a tree-view, even as the region containing it is hidden, or the file
re-loaded.

Fixes #129058.

Basically the design is to have state stored in the region, so it can be saved
to files. Views types (tree-view, grid-view, etc) can decide themselves if they
have state to be preserved, and what state that is. If a view wants to preserve
state, it's stored in a list inside the region, identified by the view's idname.

Limitation is that multiple instances of the same view would share these bits of
state, in practice I don't think that's ever an issue.

More state can be added to be preserved as needed. Since different kinds of
views may require different state, I was thinking we could add ID properties to
`uiViewState` even, making it much more dynamic.

Pull Request: https://projects.blender.org/blender/blender/pulls/130292
2024-11-18 18:19:48 +01:00
Hans Goudey
091c175c5c Refactor: Move region runtime to separate C++ runtime struct
This allows using C++ types in the region runtime data, which will
make it easier to move the remaining runtime data out of the
`ARegion` DNA type and improve code readability in these areas.

Pull Request: https://projects.blender.org/blender/blender/pulls/130196
2024-11-15 02:00:11 +01:00
Hans Goudey
6c3ac28eb3 Nodes: Slightly improve editor drawing performance with large node trees
Avoid retrieving context data for every single node which can be
expensive when there are thousands of nodes. In the "Mouse House"
test file I observed a 13% improvement in drawing timings.

Pull Request: https://projects.blender.org/blender/blender/pulls/130239
2024-11-14 16:04:33 +01:00
Julian Eisel
68a74c4095 Merge branch 'blender-v4.3-release' 2024-11-01 15:34:39 +01:00
Julian Eisel
a641001207 Fix: UI previews don't refresh outside of properties editor
The preview template (`UILayout.template_preview()`) to display previews
for materials, textures or similar would only work correctly in the
Properties editor. This had explicit logic to trigger rerendering on
changes. When displaying such previews elsewhere (e.g. in the 3D View
sidebar), the only way to have changes reflected would be by resizing
the preview.

This fix makes sure such previews are tagged as dirty and refreshed on
changes to the underlying ID. We do this the same way as tagging the ID
previews as dirty, through a function called by the dependency graph for
such updates.

Pull Request: https://projects.blender.org/blender/blender/pulls/129641
2024-11-01 15:25:24 +01:00
Campbell Barton
64027cd178 Merge branch 'blender-v4.3-release' 2024-10-21 22:00:40 +11:00
Campbell Barton
c836c0a20e Fix #129151: Crash showing tool-tips from dynamic enums
Duplicate descriptions for dynamic enum menu items to resolve
use-after-free error.
based on !129008.

Ref !129164

Co-authored-by: Julian Eisel <julian@blender.org>
2024-10-21 21:59:13 +11:00
Pratik Borhade
9e6c884394 Fix #122206: Int soft limits changed to 10000
When soft limits set to extreme int values, the softmin/max of custom
property changes to -10k/10k. Instead use extreme values.

Pull Request: https://projects.blender.org/blender/blender/pulls/123223
2024-10-09 14:05:36 +02:00
Campbell Barton
4fa3dc0dd4 Cleanup: spelling in comments, use uppercase tags 2024-10-03 12:11:52 +10:00
Sybren A. Stüvel
7ebe7a3b3b Fix #128200: Crash when duplicating essential brush asset
The check for the RNA property type was missing a nullptr check.

Pull Request: https://projects.blender.org/blender/blender/pulls/128441
2024-10-01 18:25:52 +02:00
Julian Eisel
f57b9b12d2 UI: Increase size of active asset highlight in asset shelf
Generally increases padding of preview widgets a bit (while keeping the
preview size the same), and increases the size of the highlight surface
a bit. The default grease pencil brushes from the essentials asset
library use an opaque background, so the highlight was barely visible
before. It was difficult to identify the active brush from that. Now
it's a lot easier to identify visually.

See PR for comparison screenshots.

Pull Request: https://projects.blender.org/blender/blender/pulls/128432
2024-10-01 15:33:15 +02:00
Campbell Barton
33b80415aa Cleanup: use const, correct arg names, spelling, use ELEMN(..) 2024-09-27 11:01:37 +10:00
Christoph Lendenfeld
fae19d7c92 Anim: Eyedropper for bone properties
This adds an eyedropper button to properties where you can choose a bone.

Clicking it activates the modal operation and you can pick:
* Bones from the Outliner
* Bones from the 3D Viewport if the Armature is in Pose Mode or Edit Mode

## Limitation

Picking from the 3D viewport while in Object Mode doesn't work due to technical reasons.
The selection buffer is only filled with pose bones if the armature is in pose mode.
Using the picker while in object mode gives you the Armature object, not its bones.

So you cannot use the bone picker to constrain an object to a bone.
UNLESS you pin the panel with the object, go to pose mode and then pick.

There is a warning printed for those cases to tell the user why this hasn't worked.

Pull Request: https://projects.blender.org/blender/blender/pulls/121523
2024-09-26 10:05:09 +02:00
Jonas Holzman
5cfe733f84 UI: Color Picker layout rework
Refactoring of the color picker popup. This simplifies code, removes
cruft, and adds new features. The Hex input is removed from its own
tab and placed at the bottom of the layout. The picker circle is made
just a bit smaller. "#" added to the hex values.

Pull Request: https://projects.blender.org/blender/blender/pulls/125675
2024-09-25 18:56:32 +02:00
Bastien Montagne
22477956e2 Refactor: Move BPY main/public extern headers to proper C++ ones.
Pull Request: https://projects.blender.org/blender/blender/pulls/128081
2024-09-25 18:04:33 +02:00
Bastien Montagne
3e03576b09 Add more control over ID renaming behavior.
This commit adds low-level logic in BKE to support three behaviors in
case of name conflict when renaming an ID:
1. Always tweak new name of the renamed ID (never modify the other ID
  name).
2. Always set requested name in renamed ID, modifying as needed the
  other ID name.
3. Only modify the other ID name if it shares the same root name with the
  current renamed ID's name.

It also adds quite some changes to IDTemplate, Outliner code, and
RNA-defined UILayout code, and the lower-level UI button API, to allow
for the new behavior defined in the design (i.e. option three from above list).

When renaming from the UI either 'fails' (falls back to adjusted name) or forces
renaming another ID, an INFO report is displayed.

This commit also fixes several issues in existing code, especially
regarding undo handling in rename operations (which could lead to saving
the wrong name in undo step, and/or over-generating undo steps).

API wise, the bahavior when directly assigning a name to the `ID.name`
property remains unchanged (option one from the list above). But a new
API call `ID.rename` has been added, which offers all three behaviors.

Unittests were added to cover the new implemented behaviors (both at
BKE level, and the RNA/Py API).

This commit implements #119139 design.

Pull Request: https://projects.blender.org/blender/blender/pulls/126996
2024-09-20 13:36:50 +02:00
Campbell Barton
94183b9e2e Refactor: add a function to access the window size in pixels
Replace uses of WM_window_native_pixel_x,y with
WM_window_native_pixel_size() which returns an int2 for convenience
and avoids an unnecessary call to GHOST_GetNativePixelSize(..).
2024-09-16 11:38:57 +10:00
Guillermo Venegas
033f18b5e9 Fix #127502: Popup resizes few times after closing a layout panel
Avoid truncation errors causing unneccessary resizing by passing floats
to UI_block_translate. That function translates block and button rects
which are floats.

Pull Request: https://projects.blender.org/blender/blender/pulls/127505
2024-09-13 20:04:15 +02:00
Jesse Yurkovich
da2bacae3d Fix: MEM_new/MEM_freeN mismatch inside ui_block_free_active_operator 2024-09-05 03:30:11 +02:00
Harley Acheson
fb651c1613 UI: Show Splash Version Text in White
The version text shown over the splash screen image needs to always be
white regardless of the theme. With "Blender Light" this text is black
and almost impossible to read. This PR adds the ability to set a
specific color for labels without icons and does so for the splash
screen.

Pull Request: https://projects.blender.org/blender/blender/pulls/126340
2024-08-30 20:52:17 +02:00
Bastien Montagne
0ade063f33 Refactor: Move KeyMaps and Operators PointerRNA storage to C++ allocations.
This commit essentially moves allocation of KeyMaps and Operators
PointerRNA data storage to use C++ new/delet, instead of C alloc/free.

Part of the effort to make PointerRNA non-trivial (#122431).

Pull Request: https://projects.blender.org/blender/blender/pulls/126935
2024-08-30 20:44:00 +02:00
Bastien Montagne
733ed5dc83 Refactor: Move some UI-related allocations to use C++ new/delete.
Mainly changes some UI-internal structs allocation, and the Panel
runtime custom data storage.

These changes from C-style alloc/free to C++ new/delete are a step
towards making PointerRNA non-trivial (part of #122431).

Pull Request: https://projects.blender.org/blender/blender/pulls/126698
2024-08-27 15:35:18 +02:00
Jonas Holzman
6bb2e5a691 WM API: Improve naming of WM_window_pixels_* functions
The WM API has WM_window_pixels_{x,y,coords}` functions that returns the
window size/point coordinate in the host native pixel size.

As "pixels" in itself doesn't really mean anything the intent of
these functions wasn't really clear. To clarify this, this commit
renames their prefix from `WM_window_pixels_` to
`WM_window_native_pixel_`.

Pull Request: https://projects.blender.org/blender/blender/pulls/125994
2024-08-07 22:30:31 +02:00
Leon Schittek
e68bdd44af Fix #125669: Add additional check to ui_but_equals_old
A button being wrongly matched during update caused a crash when it was
freed. The additional check prevents this false positive.

Pull Request: https://projects.blender.org/blender/blender/pulls/125821
2024-08-05 23:40:00 +02:00
Campbell Barton
111a40239a Cleanup: match argument names for function & declarations
Match function and declaration names, picking names based on
consistency with related code & clarity.

Also changes for old conventions, missed in previous cleanups:

- name -> filepath
- tname -> newname
- maxlen -> maxncpy
2024-07-27 13:32:51 +10:00
Harley Acheson
5bf44c6eb4 UI: Text Style for Tooltips
This gives users the ability to control the size of tooltip text
separately from other text styles. This is an accessibility issue
in that users with low vision can choose to make these larger than
the working text.

Pull Request: https://projects.blender.org/blender/blender/pulls/125147
2024-07-25 19:12:41 +02:00
Harley Acheson
108b71047a UI: Remove "Widget Label" Text Style
This PR removes the "Widget Label" text style, found in Preferences /
Themes / Text Style. This results in both labels and the text found in
input boxes sharing settings. This results in a slight loss of
customization but it isn't that useful to have these things separate
and results in code complication and errors.

Pull Request: https://projects.blender.org/blender/blender/pulls/122898
2024-07-19 21:57:49 +02:00
Julian Eisel
99fe6785d0 Fix issues with asset shelf context menu operators
Shortcut and quick favorite operators wouldn't show up in the regular asset
shelf. In the popup the shortcut operators would but they crashed with use
after frees.

Basic issue is that activating view-items by applying the button didn't work
well. That messes with button storage, but also the operator data (like
`uiBut.optype`) is unset after applying, in this case before the context menu
was built.

Instead, activate the view-item directly, and call the activate operator in its
`on_activate()` callback. The button shouldn't call this operator again, so
added a way to attach operators to buttons without calling them.

Seems generally useful to be able to attach an operator to buttons for
tooltips, "Assign Shortcut" and the like, without it being called on button
apply.

Pull Request: https://projects.blender.org/blender/blender/pulls/124466
2024-07-12 10:02:10 +02:00
Julian Eisel
1ed408fdd9 Cleanup: Remove wrong/unnecessary type cast in UI function 2024-07-10 17:53:44 +02:00
Pratik Borhade
5d8e29f84e Fix #124372: Crash in curve custom falloff UI
Caused by 9f90594db7
`func_argN_copy_fn` is assigned when `UI_but/block_funcN_set` is used.
In case of `ui_but_new`, it is uninitialized. Use block's callback
for but if `block/but->func_argN` exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/124388
2024-07-09 09:26:50 +02:00
Hans Goudey
bbcc720c13 Fix: Property search crash after recent allocator change
The button's callback function argument "free function" needs to be
copied along with the resource itself. We used to just call MEM_freeN
in this case, now we call the dedicated deallocation function which
supports non-trivial types.

Caused by 9f90594db7.
2024-07-08 19:09:25 -04:00
Julian Eisel
5f6586526c UI: Support semi-modal text input while other UI stays interactive
Adds support for text buttons that capture text input, while the rest of the
UI stays interactive. This is useful for example for filter buttons in popups
that are used for searching. Current search popups are an ad-hoc implementation
that doesn't use the normal widget system (and thus are quite limited).

For the brush assets project this is important to allow quickly popping up the
brush asset shelf popup, immediately typing to search a brush, and activating
a brush with a single click (rather than having to confirm text input first).
All UI elements stay interactive with hover feedback, changing asset library
and catalogs is possible, tooltips and context menus can be opened, and any
text input is still sent to the search button.

Normal search popups already keep their search results interactive like this
during text input, but are too limited because they don't use our widget
system. For example custom layouts are not possible with them. With this
feature implemented, we could consider rewriting them to use the widget
system, removing the ad-hoc implementation.

Part of the brush assets project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303

Initially reviewed in:
https://projects.blender.org/blender/blender/pulls/122871
2024-07-08 17:50:24 +02:00
Bastien Montagne
9f90594db7 UI: Support non-C-allocated data for buttons and blocks func_argN data.
This change allows to pass optional freeing and copy callbacks to
functions setting the `func_argN` member of the `uiBut` and `uiBlock`
structs. These callbacks are used to free or duplicate the data stored
in these void pointers.

Defaults are set respectively to `MEM_freeN` and `MEM_dupallocN`, to
match previous hard-coded behavior.

Utils template functions are added to easily generate callbacks to
types that are managed with the `MEM_new`/`MEM_delete` C++-style
allocation, as long as they provide a copy constructor.

Note that this change should be considered as a temporary, transitional
solution. A more robust and future-proof solution is to move towards
more usage of `std::function` for these callbacks, which can then own
and manage their custom data themselves.
2024-07-08 13:54:15 +02:00
Julian Eisel
7ef0c37bef Fix MEM_new/MEM_freeN mistach
Calling `MEM_freeN` on data allocated with `MEM_new` is bad, since it will not
call a destructor matching the one invoked as part of `MEM_new`.

Would crash with the guarded allocator, which detects such mismatches now.
2024-07-07 19:08:13 +02:00
Harley Acheson
1992296828 Fix #124068: Update Text Style Weights With Change of UI Font
Only when the user changes the UI font to one that does not have a
variable weight axis, update the text style weights to match the font's
design weight. So if changing to an old-school font that has a fixed
weight, for example bold, also update UI Text Style weights to match
so everything looks as designed and expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/124074
2024-07-03 18:02:20 +02:00
Julian Eisel
4a9e8087a7 UI: Highlight first view item on type to search & activate on enter
In particular, this makes the asset shelf popup search highlight the
first asset when changing the search filter using text input. Pressing
Enter will activate this asset then. The feature is implemented
generally for grid and tree views, but only the asset shelf implements
filtering so far. Plus, it requires the
`UI_BUT2_FORCE_SEMI_MODAL_ACTIVE` behavior on the filter text button,
otherwise it captures all input. Only the popup version of the asset
shelf uses this currently. Moving the mouse makes the highlight jump
back to the brush under the cursor again. This is how search menus
behave too.

Part of the brush assets project, see blender/blender!123853. It's made
so it's possible to quickly spawn the brush asset shelf popup, input
text to search a brush and press Enter to activate it. Based on user
feedback this is an important workflow to support well.

More info about the changes in the pull request.

Pull Request: https://projects.blender.org/blender/blender/pulls/123853
2024-07-01 20:36:51 +02:00
Harley Acheson
4ef2381ce3 Cleanup: UI: Remove Unused Icon Texture Drawing Code
About 330 lines of code removed that supported the old
ICON_TYPE_COLOR_TEXTURE icon drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/123868
2024-06-28 05:25:18 +02:00
Harley Acheson
eed83b56d2 UI: Calm Warnings With New Icons
Just calming warning with unused argument and
missing switch default.

Pull Request: https://projects.blender.org/blender/blender/pulls/123802
2024-06-27 01:35:45 +02:00
Harley Acheson
5c377686e7 UI: Use SVG Icons for Alert Icons on Dialogs
Use new SVG icons in place of current "Alert" icons, used on dialogs
and confirmations. No need for alert_icons.svg, alert_icons.png,
alert_icons_update.py. Also looks better as they are made at exact
requested size instead of 256x256 then scaled down to display.

Pull Request: https://projects.blender.org/blender/blender/pulls/123786
2024-06-26 20:54:20 +02:00
Bastien Montagne
65c5721c5a Fix (unreported): MEM_new/MEM_freeN mistaches.
Calling `MEM_freeN` on data allocated with `MEM_new` is bad, since it
will not call a destructor matching the one invoked as part of
`MEM_new`.

While in practice cases fixed below were 'not a problem' currently, as
they are trivial Cpp types (and therefore their destructor is doing
nothing), `MEM_freeN` has no way to ensure it is dealing with such a
trivial data type, so allowing such mismatch is dirty and dangerous.

Note that almost all fixed cases look more like unintentional mistakes
(mis-usages of `MEM_new` instead of `MEM_cnew`).

NOTE: There is one more (known!) case in the asset code, which fix is
slightly less trivial, and will go through a separate PR.

NOTE: This is a by-product of some work to detect such invalid usages of
`MEM_freeN` on memory chunks allocated with `MEM_new`.

Pull Request: https://projects.blender.org/blender/blender/pulls/123691
2024-06-24 18:42:26 +02:00
Julian Eisel
e425faf696 Cleanup: Replace term "radial" with "pie menu" in UI code
Code was often referring to pie menus using the term "radial" which just
obfuscates that it relates to pie menus. Just call it what it is
directly.

Doesn't replace usages of the term for names that are not strictly tied
to pie menus. Also doesn't change instances of the term in the Python
API to keep compatibility, noted in #110461.

Pull Request: https://projects.blender.org/blender/blender/pulls/122825
2024-06-06 14:55:23 +02:00
Pratik Borhade
25351738f7 UI: Add title to tree view context menus
Add new string member in `AbstractView` class to store title/header of
tree view. Later use this to set title (`pup->title`) of context menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/120694
2024-06-05 11:28:44 +02:00
Julian Eisel
2fbf206491 UI: Allow passing named strings via context
Sometimes it is necessary to pass additional data through generic UI entities,
to specific implementations. For example to pass additional options to panel
polling & drawing when instantiating a panel through its panel type. Or storing
additional data in a button, without hardcoding it in the button struct/class.

Passing data via context is a simple solution to this, however so far this only
works using hardcoded context queries or RNA pointers. For passing arbitrary
strings we've used workarounds like creating an RNA type to wrap it already.
For example `RNA_AssetCatalogPath`, which is used to dynamically populate menu
items based on an asset catalog path, via a generic menu type.
type instantiation. This makes it possible to invoke specific asset shelves as
popover panels.

Idea is simply to let `bContextStore` entries hold copies of the string (as
`std::string`), avoiding lifetime issues. Context APIs are extended to support
setting/querying strings via a context member name.

Pull Request: https://projects.blender.org/blender/blender/pulls/122113
2024-05-27 18:46:19 +02:00
Julian Eisel
717389887b Cleanup: Keep panel functions internal to UI code
These were added/exposed in aa03646a74.

There's no need to expose them in the public UI API, and they don't seem
like functions that should be used outside of the UI internals.
2024-05-24 20:29:37 +02:00
Campbell Barton
bc5b77b390 Cleanup: rename Context::wm::menu to popup_region
The term "menu" was misleading as this is used for all temporary popups.
2024-05-10 11:27:03 +10:00
Campbell Barton
eda129a768 Cleanup: quiet parentheses warning 2024-05-07 12:59:12 +10:00