Commit Graph

7704 Commits

Author SHA1 Message Date
Harley Acheson
707503bf73 Fix #122403: Show correct Hex values for managed colors
Adjusted calculation of hex values so that what is shown matches what
is displayed for material colors as well as for theme colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/122409
2024-05-29 01:13:50 +02:00
Campbell Barton
0cbadd00a3 Cleanup: various non functional changes 2024-05-28 14:09:40 +10:00
Campbell Barton
ca9b105e6c Cleanup: spelling in comments 2024-05-28 13:47:43 +10:00
Julian Eisel
71b0e9d92a UI: Don't refresh searchbox region blocks on text input
Refreshing refers to the recreation of the block and it's buttons in
this case.

Refreshing popup regions on text input was added in 7d80fde033. It can
be useful to update the popup contents on text input, searchboxes have
their completely own update handling however.
2024-05-27 21:25:28 +02:00
Damien Picard
b37d121e0a I18n: extract and disambiguate a few messages
Extract
- Add to Quick Favorites tooltip.
- "Mask", the name of a newly created mask (DATA_).
- "New" in the context of the new mask ID button.
- A few strings using BLI_STR_UTF8_ defines were not extracted.
  Take the special characters out of the translation macros.
- "External" menu items from the filebrowser's Files context
  menu (right-click on a file). These items were already extracted,
  but not translated.

Improve
- Separate formatted error message "%s is not compatible with
  ["the specified", "any"] 'refresh' options" into two messages.

Disambiguate
- Use Action context for new F-modifiers' names. This is already used
  for the "type" operator prop.
- Translate ImportHelper's default confirmation text using the
  Operator context, as it uses the operator name which is extracted
  with this context.
- "Scale" can be a noun, the scale of something, or a verb, to scale
  something. The latter mostly uses the Operator context, so apply
  this context to verbs, and the default contexts to nouns.
- "Scale Influence" can mean "Influence on Scale" (tracking
  stabilization) and "to Scale the Influence" (dynamic paint canvas).
- "Object Line Art" as type of Line Art to add, as opposed to the
  active object's Line Art settings.
- Float to Integer node: use NodeTree context for the node label, as
  this is already extracted and used for the enum.

Do not translate
- Sequencer labels containing only a string formatting field.

Some issues reported by Gabriel Gazzán and Ye Gui.

Pull Request: https://projects.blender.org/blender/blender/pulls/122283
2024-05-27 19:33:35 +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
Philipp Oeser
6256e2a838 Fix #122150: UI: layout.template_search() crash without an active item
`template_search` was introduced in c20c203b82

Seems it assumed an active item is always there.
Without an active item, we are running into a crash trying to get the
textbut width.

So solution is to not draw that text button at all until an active item
is chosen.

This also goes in line with what `template_ID` is doing (it also skips
the text button without an active item).

Pull Request: https://projects.blender.org/blender/blender/pulls/122165
2024-05-27 14:04:32 +02:00
Philipp Oeser
9c534cda00 Fix: Still allow unpacking of editable linked datablocks
Similar to 918d34a9ed, enable the button in `template_ID()`

Ref #122092

Pull Request: https://projects.blender.org/blender/blender/pulls/122199
2024-05-26 11:30:56 +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
Julian Eisel
46f5079f11 Fix: Various crashes and issues with popups
Fixes #121902, #121865, #121905 and some other reports that were closed
as duplicates.

Reverts a change done as part of 7d80fde033.

Reverting this change breaks the yet-to-be-used asset shelf popup a bit,
in that refreshing it won't work propery anymore. Think that's fair
given that 1) the popup isn't in use yet, 2) its refreshing implementation
causes a bunch of high priority bugs, and 3) #122068 is in review with a
better solution to handle refreshing. Namely, it converts the popup to a
popover, which handles refreshing differently, and thus makes the change
being reverted here unnecessary anyway.
2024-05-23 13:22:39 +02:00
Jeroen Bakker
eb20f30e15 Fix: Crash in interface layout when using custom nodes
`node_socket_add_tooltip_in_node_editor` doesn't set a free function.
but uiLayoutSetTooltipFunc didn't check on it. Documentation states
that the free_arg parameter is optional.

Pull Request: https://projects.blender.org/blender/blender/pulls/122115
2024-05-23 08:22:48 +02:00
Campbell Barton
3b21b0deb1 Fix invalid length passed to BLF_str_selection_boxes
Correct recent fix 643f23f4ed.
2024-05-23 13:08:09 +10:00
Harley Acheson
79847acd0c Cleanup: Make format
Just formatting changes resulting from Make Format.
2024-05-22 16:43:32 -07:00
Lalit Shankar Chowdhury
b561771f50 Fix #122110: Remove long text selection flickering
Fix flickering when selecting long (scrolled) text from the left.

Pull Request: https://projects.blender.org/blender/blender/pulls/122123
2024-05-23 01:41:56 +02:00
Harley Acheson
643f23f4ed Fix #122047: Correct text selection when text is scrolled
Correct calculation of start of visual string and position of the
selection start when the text is scrolled (showing a subset of the
text) within an input box.

Pull Request: https://projects.blender.org/blender/blender/pulls/122110
2024-05-22 19:40:37 +02:00
Pratik Borhade
dada0c41ee GPv3: Getter and setter for active node
This adds the functions `get_active_node` and `set_active_node`.
It also changes the the parameter of the `set_active_layer` to be
non-const.

Requested in !121970.

Pull Request: https://projects.blender.org/blender/blender/pulls/122006
2024-05-22 15:25:00 +02:00
Philipp Oeser
c6aa1fec2b Fix: Dont unpack resources that are packed in linked files
These remain linked, so data remains to be read/loaded from the packed
version from the library (making this a useless and wasteful
duplication, also changes could be perceived as lost). Tooltip was also
reading "Unpack all files packed **into this .blend** to external ones",
so that bring it in line with the tooltip.

This came up in #122033

Pull Request: https://projects.blender.org/blender/blender/pulls/122092
2024-05-22 14:50:25 +02:00
Julian Eisel
20df089341 Assets: Clear asset data by default on all "Make Local" actions
Fixes #107880.

When making a linked asset local, you typically wouldn't want this new
data-block to suddenly be part of the asset libraries this file is in. To the
user it seems like making such a data-block local also implicitly makes it an
asset.  Appending an asset already handles this, and clears the asset data by
default.

This patch modifies the `bpy.types.ID.make_local()` method, as well as all
internal calls to the make local functions, so that asset data is cleared by
default. The Python method has a new `clear_asset_data` parameter (optional,
true by default). Maybe this should not be optional.

Pull Request: https://projects.blender.org/blender/blender/pulls/110197
2024-05-21 20:41:16 +02:00
Brecht Van Lommel
5f9f3116db Libraries: Support editing linked datablocks from some libraries
For the brush assets, this mechanism makes brush, texture, node tree and
image datablocks editable even when library linked.

This commit should introduce no functional change yet, as the code to
actually tag such libraries as editable will come later.

* These libraries and their datablocks are preserved when loading a new
  blend file, much like the UI can be preserved.
* Operators that create new datablocks to be assigned to such datablocks
  will put the datablocks in the same library immediately. This was
  implemented for datablocks relevant for brush assets.
* RNA does not allow assignment of pointers from such linked datablocks
  to local datablocks.

Co-authored-by: Bastien Montagne <bastien@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/121920
2024-05-21 18:16:36 +02:00
Campbell Barton
57707ca9ae Cleanup: const pointers for FCurves where possible 2024-05-21 13:17:35 +10:00
Hans Goudey
5445fae9cf Refactor: Use more standard storage for PreviewImage runtime data
Using a non-virtual derived struct for polymorphism is error prone,
especially combined with the requirements of DNA. Instead, use a
separately allocated runtime struct as done for many other DNA structs.

In a followup commit, the remaining runtime members of `PreviewImage`
could be moved to the new runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/121509
2024-05-20 14:25:44 +02:00
Campbell Barton
096eed9d7f Cleanup: spelling in comments 2024-05-20 10:23:54 +10:00
Iliya Katueshenock
14233be92f Nodes: hide reroute input socket in sidebar
The same as d27a1c47fa. Reroute node is
value-less and there is no actual value of input socket that should be used.

Pull Request: https://projects.blender.org/blender/blender/pulls/121150
2024-05-19 21:35:10 +02:00
Harley Acheson
24873963a6 BLF: String length to cursor position, not INT_MAX
BLF_str_offset_from_cursor_position is being called with a str_len of
INT_MAX, so max buffer size instead of string length. This works fine
right now but will not when this gets more complex. For example if we
need to call functions like BLI_str_cursor_step_next_utf8, which
assumes that str_len is the actual end of the string.

Pull Request: https://projects.blender.org/blender/blender/pulls/121966
2024-05-19 05:53:56 +02:00
Habib Gahbiche
567012ef1d Fix cursor remains visibile in sequencer editor while panning and zooming
Cursor is already set to invisible by the gizmo in `WIDGETGROUP_navigate_setup()`. Setting the cursor visibility again in the operator overwrites the desired behavior of gizmos.

Pull Request: https://projects.blender.org/blender/blender/pulls/121927
2024-05-18 12:46:38 +02:00
Harley Acheson
ba36c69c9f Refactor: Add BLF Function to determine input selection boxes
Add a separate function that calculates text selection box positioning
given a string's selection start and end offsets. Moves this to a
better place and allows to have more complex boxes in future when we
might have multi-line and/or multi-directional text input.

Pull Request: https://projects.blender.org/blender/blender/pulls/121448
2024-05-18 00:13:32 +02:00
Brecht Van Lommel
a926f5b67d Refactor: Replace ID_IS_LINKED by !ID_IS_EDITABLE
Add new ID_IS_EDITABLE macro that checks if the ID can be edited in the
user interface. Replace usage of ID_IS_LINKED where it is used with this
meaning.

Also add a corresponding ID.is_editable property for Python.

This prepares for the ability to edit some linked datablocks for brush
assets.

Pull Request: https://projects.blender.org/blender/blender/pulls/121838
2024-05-16 14:53:09 +02:00
Julian Eisel
7d80fde033 UI: Popup version of the asset shelf
Developed as part of the brush assets project, see #106303. No user visible
changes at this point.

Makes it possible to display asset shelves as popups. These popup asset shelves
use static storage for their settings, mainly to remember the active catalog
and filter string, while keeping them separate from the permanent asset shelf
region. Further, the popup can be displayed in any editor, making asset
selectors possible to add anywhere in the UI. When an asset is chosen, an
operator passed to the asset shelf as bl_activate_operator is called, with an
asset weak-reference to refer to the activated asset stored in the operator
properties.

Adds UILayout.template_asset_shelf_popover() to insert asset shelf popup
buttons, taking an asset shelf idname and some normal UI parameters.
2024-05-16 00:11:47 +02:00
Harley Acheson
bef05382a0 Fix #121765: Default Separator for Pie Menu Should be UI_BTYPE_SEPR
As described in the report, pie menus can show horizontal lines if they
use separators without explicit type. This just makes them use blank
space by default instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/121839
2024-05-15 20:55:08 +02:00
Damien Picard
fb5e7caa70 UI: improve "Compact with Milliseconds" timecode style
The user preference Timecode Style has a "Compact with
Milliseconds" item, but they are not actually milliseconds. For
example at 25 fps, frame 42 will be at 00:01+17, or 00:01.68, which
is just seconds with the decimal part. Actual milliseconds would be
00:01+680ms or something, which would be cumbersome.

This PR rephrases the option to "Compact with Decimals" instead of
"Milliseconds".

Timecodes in animation editors currently show only one decimal
place when this timecode style is selected. This may not be
sufficient precision, so increase the precision to 2 places
instead.

If one animates at 25 fps, each timecode is currently duplicated 2
or 3 times, which makes it hard to distinguish each frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/119768
2024-05-15 15:25:14 +02:00
Omar Emara
2b622bd3c4 Fix #121682: Hue Correct corrupted for out of bound points
The Hue Correct node curves gets corrupted when the user disabled
clipping and adds points outside of the range. To fix this, we remove
the ability to change the range of the curves and disable clipping,
which doesn't really make sense for the use case of wrapping.

Pull Request: https://projects.blender.org/blender/blender/pulls/121746
2024-05-15 08:24:23 +02:00
YimingWu
9b2130be56 Fix #120759: Prevent tooltip translation crash
Previously the `disabled_msg` is freed in a wrong code path, this patch
fixes that.

Pull Request: https://projects.blender.org/blender/blender/pulls/121657
2024-05-15 04:36:34 +02:00
Campbell Barton
a39e78ec29 Cleanup: declare uiPopupBlockHandle on assignment 2024-05-14 14:27:12 +10:00
Campbell Barton
9ed5ed1a2b Fix #121686: Regression: Context Menu has many operations disabled
Resolve own regression in [0] which caused operators poll functions
in context menus to fail because the menus own region was set
causing the button clicked on not to be detected as the active button.

Resolve by passing "can_refresh" as an argument to ui_popup_block_create
which only sets the "region_popup" context item for popups that can
refresh. This is done because previously "region_popup" was only ever
set for temporary regions that refreshed (details in code-comments).

[0]: 38d11482f5
2024-05-14 14:08:28 +10:00
Campbell Barton
01a78bf3e6 Cleanup: avoid matching names for public & static functions
While supported it's confusing to use the same name for a public
function and it's private implementation.
2024-05-14 13:27:18 +10:00
Hans Goudey
ac7ceba950 Fix: Asset shelf missing deactivation if new item hidden
When a new item is active, other items are only deactivated in the
`set_state_active` method. This doesn't run if the new item is not
displayed by the shelf for whatever reason (e.g. catalog filters).
To fix this, just set the item inactive. This may be redundant with
the deactivation in `set_state_active`, or it might not be, depending
on whether the active item is visible.

Pull Request: https://projects.blender.org/blender/blender/pulls/121589
2024-05-14 05:11:07 +02:00
Harley Acheson
41bbbd2359 UI: Color Tooltips
Hovering over a color button shows a tooltip that includes the color
values and a large sample.

Pull Request: https://projects.blender.org/blender/blender/pulls/117815
2024-05-13 23:48:29 +02:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Sybren A. Stüvel
d94a56bdad Anim: merge Animation data-block into bAction
The new/experimental, layered `Animation` data-block is merged with the
existing `bAction` data-block.

The `Animation` data-block is considerably newer than `bAction`, so the
supporting code that was written for it is also more modern. When moving
that code into `bAction`, I chose to keep the modernity where possible,
and thus some of the old code has been updated as well. Things like
preferring references over pointers.

The `Animation` data-block is now gone from DNA, the main database, etc.
As this was still an experimental feature, there is no versioning code
to convert any of that to Actions.

The DNA struct `bAction` now has a C++ wrapper `animrig::Action`, that
can be obtained via `some_action->wrap()`.

`animrig::Action` has functions `is_empty()`, `is_action_legacy()`, and
`is_action_layered()`. They **all** return `true` when the Action is
empty, as in that case none of the data that makes an action either
'legacy' or 'layered' is there.

The 'animation filtering' code (for showing things in the dope sheet,
graph editor, etc) that I wrote for `Animation` is intentionally kept
around. These types now target 'layered actions' and the
already-existing ones 'legacy actions'. A future PR may merge these two
together, but given how much work it was to add something new there, I'd
rather wait until the dust has settled on this commit.

There are plenty of variables (and some comments) named `anim` or
`animation` that now are of type `animrig::Action`. I haven't renamed
them all, to keep the noise level low in this commit (it's already big
enough). This can be done in a followup, non-functional PR.

Related task: #121355

Pull Request: https://projects.blender.org/blender/blender/pulls/121357
2024-05-13 15:58:04 +02:00
Falk David
7f8d4df410 UI: Add eyedropper button to camera focus distance
Blender already had the ability to sample the depth with an eyedropper
and fill the focus distance (see `"ui.eyedropper_depth"`). But this feature
was fairly hidden. You had to hover over the `focal_distance` property
in the camera data panel and then press `E` (then sample a distance
in the 3D viewport).

This patch adds a `prop_data_path` property to the `ui.eyedropper_depth`
operator to allow specifying the property that should be filled with the
depth value.

The idea for this is taken from `wm.radial_control`, which also uses this
approach to write to a property. This allows us to add the eyedropper
as a button.

Pull Request: https://projects.blender.org/blender/blender/pulls/121486
2024-05-13 11:01:57 +02:00
Pratik Borhade
05be3413a9 Fix: Warning due to lower case gpv3 menu identifier
Caused by 30e3f14bcd

Pull Request: https://projects.blender.org/blender/blender/pulls/121684
2024-05-11 12:44:26 +02:00
Aras Pranckevicius
3582e52f9c UI: Improved overlay text contrast with new outline text decoration
Overlay texts were previously drawn with two sets of shadows:
- 3px blur,
- 5px blur, slightly offset

But since the shadow color was always set to black, it was still
causing legibility issues when the text itself was dark (set
via theme for example).

This PR adds a new "outline" BLF text decoration, and uses that
for the overlays. And it picks text/outline color depending
on the "background" color of the view.

Details:

- Instead of "shadow level" integer where the only valid options
  are 0, 3 or 5, have a FontShadowType enum.
- Add a new FontShadowType::Outline enum entry, that does a 1px
  outline by doing a 3x3 dilation in the font shader.
- BLF_draw_default_shadowed is changed to do outline, instead of
  drawing the shadow twice.
- In the font shader, instead of encoding shadow type in signs of
  the glyph_size, pass that as a "flags" vertex attribute. Put
  font texture channel count into the same flags, so that the
  vertex size stays the same.
- Well actually, vertex size becomes smaller by 4 bytes, since turns
  out glyph_mode vertex attribute was not used for anything at all.

Images in the PR.

Co-authored-by: Harley Acheson <harley.acheson@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/121383
2024-05-10 21:06:44 +02:00
Falk David
30e3f14bcd GPv3: Remove Groups
This implements removing of groups and adds an operator
`GREASE_PENCIL_OT_layer_group_remove`.

Groups can be removed in two ways:
 * Remove the group and keep the children.
 * Remove the group together with all its children.

Based on an earlier attempt by @PratikPB2123 here: !121611

Pull Request: https://projects.blender.org/blender/blender/pulls/121663
2024-05-10 18:39:51 +02:00
Pratik Borhade
9b5f0cb8a2 GPv3: Drag & drop for layer groups
New drag type `WM_DRAG_GREASE_PENCIL_GROUP` introduced for layer group nodes.
Replaced layer struct with `GreasePencilLayerTreeNode` in `wmDragGreasePencilLayer`
so group node can be stored while dragging in `wmdrag->poin`.

Using `can_drop()`, drop operation of layer group node returns `false`
if the target node is its child.

Part of #121390.

Pull Request: https://projects.blender.org/blender/blender/pulls/121654
2024-05-10 18:18:03 +02:00
Falk David
de037ce3b5 GPv3: Add API functions for active group
This adds the functions `has_active_group` and `get_active_group`,
similar to the `has_active_layer` and `get_active_layer` ones.

Also refactors some of the code to use these new functions instead.
2024-05-10 17:57:54 +02:00
Guillermo Venegas
4b2f1b2829 Fix: allow panel drag-collapse in popovers and fix uiBut event handling
Sets missing context menu region in popovers that is required to handle drag collapse
event.

Also fix layout panel header but events handling.

| Main | Fix |
| -------- | -------- |
| <video src="/attachments/03409a9f-751d-4b4c-b464-d62a65b9b477" title="2024-05-08 12-21-14.mp4" controls></video>     | <video src="/attachments/a50be151-8d5e-485d-bc47-3e2c7292c063" title="2024-05-08 12-18-08.mp4" controls></video>     |

Pull Request: https://projects.blender.org/blender/blender/pulls/121594
2024-05-10 14:25:26 +02:00
Pratik Borhade
10c677ba91 GPv3: Group node selection undo debug crash
Debug crash when undoing the selection of layer group. `active_node`
points to garbage memory in this case.
In release mode, undo does not select the group due to missing
`should_be_active`.

Noticed this during !121611

Pull Request: https://projects.blender.org/blender/blender/pulls/121615
2024-05-10 12:02:26 +02:00
Campbell Barton
7ae77e61cd Cleanup: assert that popup regions are temporary 2024-05-10 11:31:31 +10: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
Jesse Yurkovich
d089b5e6ad Fix #121432: Rework collection exporter UI to prevent panel id collisions
When exporters use layout panels, it was possible for their panel ids to
conflict if more than 1 of the same exporter was configured on the same
collection. The result would be that opening/closing a panel in one
exporter would open/close it for all other exporters of the same type.

This fix changes the layout to avoid the issue entirely by using a list
and only having only one exporter drawn at a time.

A few alternate designs were considered but they would either cause
intrusive changes to each location where a layout panel was used or
would result in tricky disambiguation code inside the UI system itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/121555
2024-05-09 22:25:46 +02:00