Commit Graph

7670 Commits

Author SHA1 Message Date
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
Campbell Barton
9e481b484e Cleanup: don't use boolean literals to set flag members
This could be renamed as it reads like a boolean but is a flag.
2024-05-09 12:11:46 +10:00
Campbell Barton
38d11482f5 UI: set the context's menu on creation
Set the context menu when first creating the popup,
not only when refreshing it.

Previously `Context::wm::menu` was set when a popups draw function ran
after being tagged RGN_REFRESH_UI, however the first time the draw
function ran this would be null. Ensure this is set in both cases
so logic that requires accessing the popup region can rely on it
being set.

Needed so the splash region is always accessible to implement #120612.
2024-05-09 12:03:21 +10:00
Jacques Lucke
2f289857af Object: add Shade Auto Smooth operator
Based on the design in #120230.
* Replaces the `Shade Smooth by Angle` operator with `Shade Auto Smooth`
  in the object context menu menu.
* The new operator automatically adds and removes the modifier instead
  of being a destructive operation.
* The `Shade Smooth` and `Shade Flat` operators now remove the
  `Smooth by Angle` modifier automatically.
* Add a pin option to modifiers, which limits dragging and keeps the
  modifier after newly added modifiers in the list.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121494
2024-05-08 20:24:10 +02:00
Julian Eisel
d3b2906348 UI: Respect fixed layout width in grid view layout calculations
Fixed layout widths would previously be ignored, resulting in incorrectly sized
grid view items. This is especially relevant for displaying grid views in
popups, where these fixed width are commonly used.

Necessary for the brush assets project which adds a popup version of the asset
shelf, see #116337.
2024-05-08 13:36:11 +02:00
Julian Eisel
b7bb0e94a0 UI: Allow displaying grid views in popups
The optimization to only add grid view items to the layout that are actually in
view relied on View2D information on scrolling. Popups don't use View2D, so
with this change the optimization will be skipped when View2D is not used.

Necessary for the brush assets project which adds a popup version of the asset
shelf, see #116337.
2024-05-08 13:30:27 +02:00
Campbell Barton
e64d067c78 Docs: document why the eventstate is cleared while refreshing a popup
Also correct a comments grammar.
2024-05-08 20:44:36 +10:00
Guillermo Venegas
3a640a4707 Fix #121280: clamp layout panel sub-background color to block region
Pull Request: https://projects.blender.org/blender/blender/pulls/121534
2024-05-08 12:32:51 +02:00
Pratik Borhade
5f1a31c88a GPv3: Change "active" property to "active_layer"
Rename layer property `active` -> `active_layer` to distinguish
between active layer and active layer group.
The active group property was introduced in d1710f7232.

Pull Request: https://projects.blender.org/blender/blender/pulls/121563
2024-05-08 12:18:00 +02:00
Pratik Borhade
d1710f7232 GPv3: Support layer group selection
Introduce new `active_group` pointer and get/set api functions.
Use RNA to change active group in on_activate() function, similar to
layer selection: 4c12801532

Pull Request: https://projects.blender.org/blender/blender/pulls/121524
2024-05-08 09:05:32 +02:00
Julian Eisel
952bc075ae Fix #121490: Unable to access asset from context in asset shelf
Displaying an operator in the context menu that would access the asset
via context would fail.

3 issues here in fact:
- 798219225d removed code to attach the asset to the button's context.
  Brought this back.
- If the `AssetShelf.get_active_asset()` method (in Python) isn't set,
  `AssetViewItem::should_be_active()` would always return false, making
  it impossible to lookup the active item. Instead it should return an
  empty value so the view's internal active state is used instead.
  Mistake in a700c90ec3.
- These kind of context queries can't rely on cursor coordinates, it's
  not well defined what state they are in. In fact `wmWindow.eventstate`
  is unset in debug builds to help enforce this. Also an issue from
  a700c90ec3. With the above two corrections this change can be
  undone so the query doesn't depend on cursor coordinates anymore.
2024-05-07 17:45:15 +02:00
Pratik Borhade
8d8d358196 GPv3: Replace active_layer with active_node
This was discussed in #121390 for further selection support of
layer groups.

Pull Request: https://projects.blender.org/blender/blender/pulls/121475
2024-05-07 11:26:33 +02:00
Campbell Barton
eda129a768 Cleanup: quiet parentheses warning 2024-05-07 12:59:12 +10:00
Hans Goudey
88b4498b32 Cleanup: Miscellaneous cleanups to workspace status items
- Remove meaningless const for by-value arguments in declarations
- Use std::move for strings (otherwise StringRef should be used)
- Move struct to C++ namespace
- Avoid unnecessary namespace specification
- Use static constexpr instead of macros
- Add const for other arguments in function definitions
- Avoid copying struct in for loop
- Remove redundnat "private" in class
2024-05-06 18:20:43 -04:00
Harley Acheson
44606c5e4d UI: Status Bar While Menus Are Open
While menus are open display a nicer status in the Status Bar, whether
spacebar search or type to search.

Pull Request: https://projects.blender.org/blender/blender/pulls/121502
2024-05-07 00:19:01 +02:00
Harley Acheson
c4e5a70e07 UI: Optional Complex Layout for Workspace Status
Optionally allow complex layout instead of just plain text when using
ED_workspace_status_text.

Pull Request: https://projects.blender.org/blender/blender/pulls/120595
2024-05-06 23:52:37 +02:00
Campbell Barton
0fedcc2f3c Cleanup: correct invalid use of "r_" prefixed return arguments
These arguments are modified in-place and aren't output-only variables.
2024-05-06 11:58:44 +10:00
Campbell Barton
bb172dae61 Cleanup: use const variables & arguments 2024-05-06 09:20:03 +10:00
Julian Eisel
a700c90ec3 Asset Shelf: Add callback to get active asset
Add a function for asset shelves, `get_active_asset` in RNA, that
can be used to sync the active item of an asset shelf with an asset
reference elsewhere in Blender. In the brush asset system this is
used to retrieve the asset reference from the active `Paint` struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/121405
2024-05-03 15:27:35 -04:00
Hans Goudey
798219225d Asset Shelf: Add optional operator to activate assets
The operator stored when registering the asset shelf will be called
with properties that reference the asset (a weak reference, split into
three properties already used in other asset-related operators). The
operator is called whenever a grid view item is activated, and is
meant to do things like import and activate a brush asset.

Previously Reviewed: https://projects.blender.org/blender/blender/pulls/117861

Pull Request: https://projects.blender.org/blender/blender/pulls/121402
2024-05-03 19:24:00 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
YimingWu
e8d028b7a5 Fix #121338: Depthdropper ensure viewport camera
Depthdropper should ensure that the viewport is in camera view to use
active camera position, otherwise it should still use rv3d->viewinv[3]
to ensure correct distance result.

Pull Request: https://projects.blender.org/blender/blender/pulls/121339
2024-05-02 13:24:22 +02:00
Campbell Barton
f6b7464b4c Cleanup: spelling in comments 2024-05-02 16:44:10 +10:00
Hans Goudey
9c1fe82e06 UI: Enable "apply" handler for preview tile buttons
For example, allow calling an operator when clicking on a
preview tile button. Useful for brush assets where clicking
on an asset shelf item activates the brush.
2024-05-01 13:17:44 -04:00
Hans Goudey
14e8d0d9aa UI: Use "label tooltip" as a fallback for quick favorites menu text
Useful when the button has no display text but has been set up
to have a quickly accessible tooltip in its place (for example
a brush asset item in the asset shelf).
2024-05-01 13:11:55 -04:00
Hans Goudey
722ad638c5 UI: Add optional icon argument to search visit params
Allows adding an icon to some search items, similar to what is done
manually for property search. Used for asset catalog search in the
brush assets branch, but more widely useful too.
2024-05-01 11:49:48 -04:00
Pratik Borhade
a42e2a5a29 GPv3: Mask toggle in dopesheet channel
Add `use_mask` property in dopesheet layer channel.
Also add an icon to the `use_mask` property.

Pull Request: https://projects.blender.org/blender/blender/pulls/121259
2024-05-01 15:10:22 +02:00
Campbell Barton
da4b81e980 Cleanup: move doc-strings into headers 2024-04-30 12:52:52 +10:00
Nathan Vegdahl
bd3518946e Anim: implement "Copy Driver to Selected" operator
This allows the user to copy the driver(s) of a property to other selected items (e.g. objects, nodes, etc.) via the right-click menu.  The implementation is based on the "Copy to Selected" operator, and generally behaves the same except for copying drivers instead of values.

Resolves #120518
2024-04-29 18:34:57 +02:00
Campbell Barton
c9dba4d31f Cleanup: use const variables & argument, remove duplicate include 2024-04-29 09:09:44 +10:00
Jacques Lucke
71ba360ddc Cleanup: use Map for operator types
This simplifies the code, makes it more type safe and also makes it
easier to use the construct-on-first-use-idiom.

Pull Request: https://projects.blender.org/blender/blender/pulls/121170
2024-04-27 21:44:55 +02:00
Bartosz Kosiorek
749433f20b UI: Add tooltips with node description to node titles
These were already displayed in the node add menu. But it can also be
useful to see node descriptions when opening existing projects.

Pull Request: https://projects.blender.org/blender/blender/pulls/119705
2024-04-26 16:29:46 +02:00
Falk David
fe0e2907b3 GPv3: Remove OB_MODE_PAINT_GREASE_PENCIL flag
This reverts part of 36cda3b3116acba3b895daf68689f8af01b62392
and replaces the use of `OB_MODE_PAINT_GREASE_PENCIL`
`OB_MODE_PAINT_GPENCIL_LEGACY` flag instead.
The `OB_MODE_PAINT_GREASE_PENCIL` is removed.

The `GREASE_PENCIL_OT_draw_mode_toggle` operator is removed
and the `GPENCIL_OT_paintmode_toggle`  operator is adapted to
work with GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/121027
2024-04-25 14:23:46 +02:00
Campbell Barton
08b3db500f Cleanup: correct asserts
Also remove redundant assert.
2024-04-25 12:02:14 +10:00
Pratik Borhade
1e61cf7cf4 Fix #120958: Redundant Operations Tips in Status Bar when Transforming
Caused by 49bd285529.
keyitem with "release" events are shown in the status bar which is not
necessary. Move the if condition outside of for loop and exit early from
`uiTemplateStatusBarModalItem` to skip drawing of "release" type of
keyitems.

Pull Request: https://projects.blender.org/blender/blender/pulls/120974
2024-04-24 20:19:59 +02:00