Commit Graph

56 Commits

Author SHA1 Message Date
Jacques Lucke
04fcc4126e Fix #147282: double clicking on value enters node group
This fix makes the enter-node-group operator pass through when interacting with a button.

The code is by @JulianEisel.

Pull Request: https://projects.blender.org/blender/blender/pulls/148133
2025-10-16 19:21:12 +02:00
Guillermo Venegas
9c98ea1a18 Refactor: UI: Make button type params typed enums
This converts `eButType` and `eButPointerType` as typed enums.

This improves a bit `uiDefBut` self-documentation by taking an
struct with `ButType` and `ButPointerType` types, instead of
using a single `int` to write both enum types and bit index.

Almost all other `uiDefBut*` functions take just a `ButType`
parameter now.

`uiDefButI` for example is equivalent to:
`uiDefBut({ButType(type), ButPointerType::Int},...);`

Pull Request: https://projects.blender.org/blender/blender/pulls/142132
2025-07-18 13:12:16 +02:00
Jacques Lucke
fc05a70dcd UI: support fully custom layout tooltips
The goal is to be able to build fully custom tooltips for entire layouts (e.g.
for all `uiBut` for a socket). We already support tooltip callbacks for layouts
and fully custom tooltips for `uiBut`, however not fully custom tooltips for an
entire layout.

This will be used by #140540.

The main noteworthy thing here is that now `uiBut` is passed into the custom
tooltip function. This is necessary when the tooltip still has to be customized
for the exact hovered `uiBut`. For example, we generate a tooltip that applies
to an entire vector socket, but when hovering over e.g. the X input value, the
Python tooltip should show the path for that specific property.

This also fixes a bug in `ui_but_is_interactive_ex` which didn't consider custom
and quick tooltips before.

`uiLayoutSetTooltipCustomFunc` is pretty much the same as its non-custom
counterpart.

Pull Request: https://projects.blender.org/blender/blender/pulls/142044
2025-07-16 13:09:29 +02:00
Guillermo Venegas
091db9d52b Cleanup: UI: Use UI_interface_layout.hh instead of UI_interface.hh
This removes the include `UI_interface_layout.hh` from
`UI_interface_c.hh`, and in many places this swaps the include
from `UI_interface.hh` to `UI_interface_layout.hh`.

Also, cleanups some `UI_interface.hh` includes with
`UI_interface_icons.hh` or `UI_interface_types.hh`
2025-06-20 18:07:47 +02:00
Julian Eisel
e9bb58e6df UI: Remove asset view template specific UI list features
Reverts most of the additions from ae1dc8f5f9 and 68c6fc6d38 to allow
internally defined UI lists to set operators to execute on click and
drag events. This was added and used only for the asset view UI
template was removed for 5.0 in the previous commit, as part of #110461.

Pull Request: https://projects.blender.org/blender/blender/pulls/140149
2025-06-12 16:13:56 +02:00
Jacques Lucke
4acd6d46d4 UI: rename Tooltip Label to Quick Tooltip
Change the mentions of "tooltip label" to "quick tooltip" to make this feature more
universally useful. The new name was suggested in #138583.

Pull Request: https://projects.blender.org/blender/blender/pulls/138639
2025-05-09 13:34:35 +02:00
Guillermo Venegas
6397a4fb9a Refactor: UI: Use typed enum class for eUIEmbossType enum
Part of incoming refactors in interface layout c++ code, this enables
forward declaring this enum type. Enum is renamed as `EmbossType` and
moved to `blender::ui` namespace. No user visible changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/136725
2025-03-31 00:36:46 +02:00
Julian Eisel
4499fad40e UI: Horizontal list view for asset browser
Part of #134755 / #134766.

The asset browser currently lacks a compact view that leaves names
readable. Especially when managing asset libraries (e.g. to prepare it
for sharing or set up a production library), this is quite a usability
issue. A column view like the file browser has can solve this, allowing
a quick overview and fast browsing of libraries, while keeping names
readable.

Adds a new "Horizontal List" display mode to the asset browser that
distributes assets over multiple columns, with horizontal scrolling.
Asset previews are shown in this mode, plus an asset type icon if
there's enough space. The size of previews and the columns can be
configured next to the display mode, for optimizing the display.

Pull Request: https://projects.blender.org/blender/blender/pulls/135306
2025-03-14 16:43:12 +01:00
Harley Acheson
0ee642611c UI: Add Specific Icon to Represent Preview While Loading
Rather than continuing to use ICON_TEMP, meant to represent temporary
locations, this PR adds a specific one - ICON_PREVIEW_LOADING - for
this purpose. Just a copy of ICON_TEMP for now, but with all parts at
40% opacity, matching how we use it now. Not only gives us an icon we
can later change, but also removes our special handling of reducing
opacity for one icon id.

Pull Request: https://projects.blender.org/blender/blender/pulls/135463
2025-03-04 23:35:30 +01:00
Hans Goudey
568c791e22 Cleanup: Use StringRef for uiBut tooltips
And replace nullptr arguments for tooltips in UI button
creation functions with std::nullopt. Though the distinction
between "no tooltip" and "empty tooltip" doesn't seem to exist,
it seems safer to keep the distinction since it existed with null before.
2025-02-14 15:12:48 -05:00
Guillermo Venegas
7682258ff9 Refactor: UI: Use a Vector to store buttons in UI blocks
This changes the ui-blocks buttons storage from Listbase to Vector.

Major changes that might cause a performance considerations are
in `ui_but_update_from_old_block` that requires to track buttons when restoring
button state between block redraws or in  `uiItemFullR` that may needs to insert
uiButs in the middle of the vector to add decorators. This might not be as fast as
removing or inserting elements in the middle of a listbase container. Also buttons currently
don't know its position in the container, so to get the previous and next
button its required to make a lookup of the button in the container.

`UI_block_update_from_old> ui_but_update_from_old_block` restores the state
of buttons between frames, this is done by sequentially testing if a button is the
same as an old button, however since UI can be created procedurally some old buttons
may not be drawn while editing other button data, this requires an extra track of what
buttons may not match to a new button while comparing for restoring state, but still
this buttons may be candidates to match to an new button.

Not functional changes expected.
Ref: #117604

Co-authored-by: Julian Eisel <julian@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/127128
2025-02-14 15:29:26 +01:00
Julian Eisel
1f88645728 UI: Draw loading icon while previews load
Show a dimmed loading icon while previews are being loaded in a
background thread. The asset shelf and asset/file browsers do this
similarly already.

This is implemented in drawing code, so the loading icon will always
appear when an in-progress preview is being drawn. I experimented with
doing this in `ui_def_but_icon()`, but this won't update correctly with
popups that don't support full refreshing.

This also makes any normal icon that is drawn as preview use the normal
icon size. These icons are usually made for smaller sizes and look very
outblown when displayed at the size of a preview. Yet it's useful to
sometimes pass a normal icon. E.g. for the asset shelf we would already
draw the data-block type icon in place of the preview if there was no
preview to display, and we'd use the normal, smaller size already.
Larger can still be drawn differently.
I don't know of any current cases this would affect though.

Pull Request: https://projects.blender.org/blender/blender/pulls/133880
2025-02-03 16:03:06 +01: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
Campbell Barton
04b7e8fe1d Merge branch 'blender-v4.2-release' 2024-07-06 15:00:40 +10:00
Campbell Barton
850e715682 UI: add UILayout.template_popup_confirm(..) function
This makes it possible for popups to have their confirm & cancel buttons
defined in the operator's draw callback.

When used with popups created by: `WindowManager::invoke_props_dialog()`
to override the default confirm/cancel buttons.

In the case of `WindowManager::popover(..)` & `bpy.ops.wm.call_panel()`
this can be used to add confirm/cancel buttons.

Details:

- When the confirm or cancel text argument is a blank string the button
  isn't shown, making it possible to only show a single button.
- The template is similar to UILayout::operator in that it returns the
  operator properties for the confirm action.
- MS-Windows alternate ordering of Confirm/Cancel is followed.

Needed to resolve #124098.

Ref !124139
2024-07-06 14:49:39 +10: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
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
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
Hans Goudey
1050d6147f Cleanup: Remove unnecessary C wrappers for UI view classes 2024-03-08 09:16:07 -05:00
Hans Goudey
089c389b5c Cleanup: Store UI button drawstr with std::string
Similar to bff51ae66c
2024-01-22 14:54:44 -05:00
Campbell Barton
b3f9663011 Cleanup: use a mask combining all pie menu directions
Avoid looping over buttons to check which directions are in use.
2023-09-14 16:10:36 +10:00
Campbell Barton
a8db828618 UI: remove unnecessarily dead zones for pie menus
Previously when there were 5 or more menu items in a pie menu
the acceptable angle to select an item was limited to 45 degrees.

This makes sense when all 8 menu items are set, however it unnecessarily
restricts the range for menu items that don't have adjacent items.

Resolve using a 90 degree angle range then checking of the adjacent
buttons exist and are a better match.

This also resolves a very small dead-zone between adjacent buttons
for both 4 or 8 button pie menus. It was possible for a direction to
select neither. Compare the direction enum as a tie breaker.

Ref !112311.
2023-09-14 15:43:33 +10:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Jacques Lucke
cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Campbell Barton
9e3dc02bed Cleanup: naming consistency for find functions
- find_from_name -> find_by_name.
- find_from_index -> find_index.

This matches naming used elsewhere in Blender API's.
2023-08-06 15:57:24 +10:00
Hans Goudey
ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey
bc8c892c65 Cleanup: Move WM headers to C++
Also move a few more headers that included WM headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/110815
2023-08-04 23:11:22 +02:00
Julian Eisel
9d0907560a UI: Refactor quick label tooltip implementation for buttons
No user visible changes expected. Used in the asset shelf branch,
see #104831.

These tooltips only show a label string and appear after a shorter timeout
than the regular tooltips. After the regular tooltip timeout they expand to
the full tooltip. The toolbar and properties editor navigation tabs make use
of this already.

The changes here enable more control over quick label tooltips, making them
usable in more cases, and less ad-hoc. Main changes:
- Refactors internal logic so a single `UI_BUT_HAS_TOOLTIP_LABEL` button flag
  can be used to enable quick label tooltips. This decentralizes logic in a
  way that's more consistent and extensible.
- Custom callback to return a quick label. This is useful when a label tooltip
  should be displayed even when there is no button string set. E.g. in the
  asset shelf with "Show Names" disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/110200
2023-07-25 16:22:31 +02:00
Campbell Barton
e63a77eeb8 Cleanup: rename uiButProgressbar to uiButProgress
Prepare for other types of progress to be added.
2023-07-12 13:31:46 +10:00
Philipp Oeser
693a921f02 Merge branch 'blender-v3.6-release' 2023-06-06 14:25:46 +02:00
Philipp Oeser
014825dd26 Fix: UI: cannot copy-paste many array buttons in nodes
This came up in #108096

Reason this fails is the `ui_but_has_array_value` check [which depends
on a property subtype that supports arrays]. The default `VectorBuilder`
has a `PropertySubType` of `PROP_NONE` though, so one possibility
would be to change this to `PROP_XYZ`.

However, RNA should know much better which RNA property buttons
have arrays than the UI code, so use RNA_property_array_check now
(instead of checking particular UI property subtypes).

Pull Request: https://projects.blender.org/blender/blender/pulls/108349
2023-06-06 14:24:45 +02:00
Campbell Barton
aada2800fd Cleanup: use BLI_strchr_or_end to simplify new-line stepping
- DRW_draw_region_engine_info:

  - Remove duplicate line drawing for the last line.
  - Remove string copying, pass the length to BLF_draw_default instead.
  - Resolve a potential buffer overflow as the source string length was
    used to define the destinations maximum size.

- CONSOLE_OT_paste:

  - Remove the need to null-terminate each line.
  - Buffer stepping uses const values
  - console_line_insert no longer strips the string it inserts.

- CONSOLE_OT_insert:

  - New lines in the middle of text now reports an error,
    new lines at the end of text is stripped (as before).
2023-06-05 12:36:12 +10:00
Campbell Barton
74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton
df54b627b3 Cleanup: use of the term 'len' & 'maxlen'
Only use the term len & maxlen when they represent the length & maximum
length of a string. Instead of the available bytes to use.

Also include the data they're referencing as a suffix, otherwise it's
not always clear what the length is in reference to.
2023-05-07 16:46:37 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Julian Eisel
1b94e60fb0 UI: Quick tooltip showing tab name for Properties editor tabs
Adds "quick tooltips" to quickly see the name of a tab in the Properties
editor. (See patch for visuals.)

From own experience users are often confused about the name of the different
tabs, and I always found the delay to see it in the tooltip annoying. These
quick tooltips have been introduced for the toolshelf and solve this issue
nicely here. There is still a delay so that simple mouse movements won't
trigger the tooltips, but they show up a lot faster than normal tooltips now.

This may have the side-effect that icon only enum-item buttons will show the
enum name when there is no RNA property description. Previously we wouldn't
show this, even if available.

Pull Request: https://projects.blender.org/blender/blender/pulls/106906
2023-04-14 11:43:20 +02:00
Julian Eisel
0256bfd309 UI: Support minimum row count for tree views
No user visible changes expected.

With this, empty rows will be added to the tree view so that the
background box is at least a few lines high (like with UI lists). If the
view is used as a drop target, data can be dropped on these empty rows
too then.
This was requested for the Cycles light linking project.
2023-03-28 12:39:24 +02:00
Julian Eisel
c437a8aea8 Revert release branch only commit after merge
This is a revert of a revert, because the initial revert is only
supposed to be in the release branch.

This reverts commit 3eed00dc54.
2023-02-20 11:51:16 +01:00
Julian Eisel
3eed00dc54 Revert "GPencil: Include UV information in simplify->sample modifier."
This reverts commit 19222627c6.

Something went wrong here, seems like this commit merged the main branch
into the release branch, which should never be done.
2023-02-20 11:20:07 +01:00
YimingWu
19222627c6 GPencil: Include UV information in simplify->sample modifier.
Simplify modifier sample mode didn't transfer UV parameters, now fixed.

Pull Request #104942
2023-02-19 11:45:22 +01:00
Dalai Felinto
4ec9aff2af Revert "Fix #104850: Create Geometry Nodes operators fails if not in English"
This reverts commit 68181c2560.

I merged 3.6 into 3.5 by mistake. Basically I had a PR against main,
 then changed it in the last minute to be against 3.5 via the
 web-interface unaware that I shouldn't do it without updating the
 patch.

 Original Pull Request: #104889
2023-02-17 18:45:42 +01:00
Dalai Felinto
68181c2560 Fix #104850: Create Geometry Nodes operators fails if not in English
Note that the node group has its sockets names
translated, while the built-in nodes don't.

So we need to use data_ for the built-in nodes names,
and the sockets of the created node groups.

Pull Request #104889
2023-02-17 18:39:17 +01:00
Hans Goudey
2652029f3b Cleanup: Clang tidy
Addressed almost all warnings except for replacing defines
with enums and variable assignment in if statements.
2022-12-29 12:01:32 -05:00
Hans Goudey
4ecc7cf14a Cleanup: Move interface_intern.hh
The entire interface directory is now compiled as C++ files.
2022-11-26 10:12:58 -06:00
Campbell Barton
331f850056 Cleanup: redundant parenthesis 2022-10-07 22:55:03 +11:00
Hans Goudey
97746129d5 Cleanup: replace UNUSED macro with commented args in C++ code
This is the conventional way of dealing with unused arguments in C++,
since it works on all compilers.

Regex find and replace: `UNUSED\((\w+)\)` -> `/*$1*/`
2022-10-03 17:38:16 -05:00
Campbell Barton
0419ee871f Cleanup: remove redundant parenthesis (especially with macros) 2022-09-25 22:41:22 +10:00
Campbell Barton
f68cfd6bb0 Cleanup: replace C-style casts with functional casts for numeric types 2022-09-25 20:17:08 +10:00