Commit Graph

94 Commits

Author SHA1 Message Date
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
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
Harley Acheson
49bd285529 UI: Collapse XYZ Operations in Status Bar
Reduce the number of duplicated modal operator keymap entries by just
showing "XYZ Axis" rather than "X X Axis", "Y Y Azis", etc. This allows
more items to be shown on the status bar. Note this only does so if the
keymap contains all of X, Y, & Z.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/120148
2024-04-22 20:03:11 +02:00
Harley Acheson
d8f6ae7919 UI: Outliner "File Mode" Manage User Count
In Outliner "Blender File Mode" view, show user counts, and allow
removing and adding fake user, requested in #118655.

Pull Request: https://projects.blender.org/blender/blender/pulls/118691
2024-04-20 02:50:12 +02:00
Campbell Barton
01101dcaf9 Cleanup: use const references instead of copy-by-value 2024-04-17 11:36:44 +10:00
Brecht Van Lommel
07922a99e9 UI: Tweaks to collection export
* Remove embossing from preset / export / delete buttons.
   For example modifiers also don't have emboss for X, and presets
   never do. So it seems consistent.
* Remove duplicated preset buttons, only have the one in the header
  like other panels in properties editor.
* Use property separate layout without boxes for file path.
* Show info message when exporting a single or all collections,
  otherwise it's not obvious that something happened when clicking
  the button.

Pull Request: https://projects.blender.org/blender/blender/pulls/120667
2024-04-16 15:02:33 +02:00
Jacques Lucke
d1634b2a4a UI: support adding a search weight to menu entries for menu-search
The goal is to support better search experience in the cases where we want to
explicitly influence the ordering instead of relying only on general heuristics.
We used to support this already at some point I think, but not anymore since we
started using menu-search.

The implementation is fairly straight forward. It mainly just forwards the
search weight from the menu definition to the search code through various
required steps. The main annoying thing is that changing the signature of e.g.
`uiItemFullO_ptr` is fairly involved. Even using default parameters for these
functions is a bit annoying and becomes fairly unreadable and error-prone on the
call-site. For now, I worked around this by storing the search weight on the
`uiLayout` and to copy it to the `uiBut` from there. That seems preferable until
we have a better solution for adding parameters to all the `uiItem*` functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/120572
2024-04-16 12:18:45 +02:00
Jesse Yurkovich
509a7870c3 Collection Exporters: Enable file exporters to be specified on Collections
This implements the ability to have file exporters added and configured on Collections.

Exporting is reachable from several locations:
- Individually on each exporter configuration: The `Export` button in each panel header
- For all exporters on the collection: The `Export All` button in the main panel interface
- For all exporters on all collections in the scene: The `File`->`Export All Collections` button

Visibility of which collections currently have exporters configured is done by ways of an icon added to the Collection row in the Outliner.

Adding multiple exporters for the same file type is permitted. The user is free to setup several exports of the same format but with different file locations or settings etc.

Notes:
Only USD and Wavefront OBJ are enabled for the initial commit. Additional formats, including those implemented in Python will be added as separate commits after this.

Ref #115690
Pull Request: https://projects.blender.org/blender/blender/pulls/116646
2024-04-08 22:10:39 +02:00
Brecht Van Lommel
d99f2e8eb7 Refactor: Add ability for UI block to own operator
Instead of only referencing an existing one. This will be used for
collection exporter and presets, to make sure the operator instance
stays alive long enough for the preset to be able to be applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/120034
2024-03-29 14:52:35 +01:00
Hans Goudey
acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Julian Eisel
b1db1702c6 Cleanup: Deduplicate UI list filtering checks
Followup to 303014bfac.
2024-03-22 16:04:03 +01:00
Guillermo Venegas
aa03646a74 UI: support layout panels in popups
Enables operators that uses `WM_operator_props_dialog_popup`
or `redo` popup to use layout panels.

Other popups would likely also support layout panels, only
they need to set its dummy panel with `UI_popup_dummy_panel_set`.
Popups don't normally use `Panel`, but that's the type that stores the
layout panel states. Therefore, to use layout panels in a popup, one
currently needs to create a dummy panel whose purpose is to store the
layout panel states for as long as the popup is open.

Alternatively, we could potentially also store the layout panel states
somewhere else in the future for popups, but that might be a more involved
change for now.

See #119519 for an example script that uses layout panels in a popup.

Pull Request: https://projects.blender.org/blender/blender/pulls/119519
2024-03-21 10:31:05 +01:00
Harley Acheson
061a9ee885 UI: Add Optional Flags for Tooltip Image Fields
Add more flexibility to tooltip images by adding the ability to specify
if (one of two) checkerboards are added, border, premultiplied
blending, or recoloring.

Pull Request: https://projects.blender.org/blender/blender/pulls/119437
2024-03-18 22:17:45 +01:00
Hans Goudey
1050d6147f Cleanup: Remove unnecessary C wrappers for UI view classes 2024-03-08 09:16:07 -05:00
Hans Goudey
744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own",  "her own", or "the object's own".
It also isn't used separately to mean something like "separate".

Also, "its own" is correct instead of "it's own" which is a misues of the verb.
2024-03-07 16:23:35 -05:00
Hans Goudey
ce80cc1526 Cleanup: Remove unused UI button creation function
Last used over 11 years ago apparently.
2024-03-04 12:22:50 -05:00
Hans Goudey
aab9ecc396 Cleanup: Remove very old hack to fix linking in interface module
Pull Request: https://projects.blender.org/blender/blender/pulls/118988
2024-03-01 23:47:18 +01:00
Hans Goudey
d29ce3d531 UI: Remove uiBut a1 and a2 values
Over the last couple years (!) UI buttons have moved to derived classes,
meaning we don't need to use the same "a1" and "a2" variables to store
different information. At this point, that information is set specifically
by internal UI code, or functions like `UI_but_*_set`.

These values are only set to their default 0 values now (or -1 in some
non-meaningful cases). This commit removes the values from buttons
and removes the remaining a1 and a2 arguments from the UI API.
2024-03-01 14:27:57 -05:00
Hans Goudey
365966d51d Cleanup: UI: Use derived struct for label buttons, remove a1, a2 usage 2024-03-01 14:27:56 -05:00
Hans Goudey
f4e670af2c Refactor: UI: Use regular button callbacks for curve, color ramp templates
Previously these used a special "menu func" that used an argument value
passed through each menu button's a2 value. This was more complex than
necessary given the existence of generic button callbacks.

So use std::function in these remaining cases, and remove the now-unused
`butm_func` and `butm_func_arg` values in the uiBlock.
2024-03-01 14:27:56 -05:00
Hans Goudey
e1023b22f1 Cleanup: UI: Remove more uses of a1 and a2 arguments
Remove uses for `uiDefButS`. -1 was passed as a2 still in a few
places, but that was most likely just because of copy & paste,
it doesn't look like that's actually used anywhere.
2024-02-29 22:39:37 -05:00
Hans Goudey
aabd5de1f9 Cleanup: Remove unused UI button creation function 2024-02-29 22:39:37 -05:00
Hans Goudey
121ded625f Cleanup: Remove unnecessary a1 and a2 arguments for some UI functions 2024-02-29 22:39:37 -05:00
Hans Goudey
0e2fed5a57 Refactor: UI: Avoid a1 and a1 values for search button preview grid size 2024-02-29 22:39:37 -05:00
Campbell Barton
7db790c4b7 Cleanup: spelling in comments 2024-02-28 12:13:20 +11:00
Campbell Barton
a9803765dc Cleanup: remove colon after "return" doxy command 2024-02-28 12:13:17 +11:00
Hans Goudey
eb484188dd Cleanup: Move asset filter settings out of DNA
There's no reason for this struct to be declared in DNA when it isn't
saved to files.

Pull Request: https://projects.blender.org/blender/blender/pulls/118285
2024-02-21 14:23:17 +01:00
Campbell Barton
64213e6c24 Cleanup: use std::string for manual_id access 2024-02-19 12:18:30 +11:00
Campbell Barton
eafecb2bc3 Cleanup: remove unused WM_DRAG_VALUE 2024-02-16 14:26:56 +11:00
Harley Acheson
4c50e6992f UI: Configurable Layout Separators
Ability to create vertical bar separators in horizontal layouts,
horizontal lines in popovers, and vertical (non-line) spacers in menus.

Pull Request: https://projects.blender.org/blender/blender/pulls/117310
2024-02-09 17:38:36 +01:00
Hans Goudey
fbf47b9a12 Refactor: Use std::string for keymap string return values
The main simplification is using return values rather than return
arguments, and the additional semantic clarity from std::optional.
Also use `fmt` for formatting and use lambdas instead of macros
as helpers in a few modal keymap formatting functions.

Similar commits:
- a1792e98a4
- f04bc75f8c
- 6abf43cef5
- 7ca4dcac5a

Pull Request: https://projects.blender.org/blender/blender/pulls/117785
2024-02-07 14:22:54 +01:00
Campbell Barton
9996d95ab9 Cleanup: spelling in comments 2024-02-06 22:28:10 +11:00
Hans Goudey
df8c85d3f9 Cleanup: UI Remove more unnecessary a1 and a2 parameters
Similar to 5155feeeb8. These had values without any meeting,
almost completely just 0 or -1 (which meant "find good values if possible"
anyway).
2024-02-05 14:38:11 -05:00
Hans Goudey
266230dd88 Refactor: UI: Pass StringRef to more button definition functions
Similar to 9c3aa8b824. This time there is one null argument
that has to be changed. It was simple to just move the logic to that one
caller.
2024-02-01 14:40:40 -05:00
Hans Goudey
5155feeeb8 Cleanup: UI: Remove a1 and a2 unused arguments from uiDefButF function
These were removed in previous commits like e6f0b60c2e.
2024-02-01 13:09:09 -05:00
Hans Goudey
809499a3d0 Refactor: UI: Use derived struct for number slider buttons
Similar to d204830107. This is the last real use of
the a1 and a2 arguments for many button definition functions.
2024-02-01 13:08:50 -05:00
Hans Goudey
9c3aa8b824 Cleanup: Use StringRef arguments for some UI button functions
The benefits are O(1) access to the string size, clearer ownership,
and easily accessible utility functions. For now, only change functions
where the string is clearly non-null. It's not clear in what cases some
other functions recieve null strings.
2024-01-31 17:16:25 -05:00
Hans Goudey
e89b4927e4 Cleanup: UI: Remove unused button creation functions 2024-01-31 13:45:26 -05:00
Hans Goudey
f04bc75f8c Cleanup: Use std::string for some RNA function return values
This significantly simplifies memory management, mostly by avoiding
the need to free the memory manually. It may also improve performance,
since std::string has an inline buffer that can prevent heap
allocations and it stores the size.

Pull Request: https://projects.blender.org/blender/blender/pulls/117695
2024-01-31 17:08:09 +01:00
Jacques Lucke
f358843108 UI: simplify layout panels C++ API
This simplifies the C++ API for making layout panels. Now it is also more similar to the Python API.
`uiLayoutPanel` is like `layout.panel` and `uiLayoutPanelProp` is like `layout.panel_prop`.

Both, `uiLayoutPanel` and `uiLayoutPanelProp`, now exist in two variants. One that takes a label
parameter and one that does not. If the label is passed in, only the panel body layout is returned.
Otherwise, the header and body are returned for more customization.

Pull Request: https://projects.blender.org/blender/blender/pulls/117670
2024-01-30 17:44:56 +01:00
Hans Goudey
13d280b8d8 Cleanup: Rename function to ensure button operator properties
For some reason the "get" function actually allocates the button's
operator properties container. This may or may not make sense to
do, but while it happens, the function name might as well make
that clear.
2024-01-29 16:33:12 -05:00
Harley Acheson
28366f624f UI: Operator Confirm Dialog Changes
Removal of "confirm" operator callback for confirmation customization,
in favor of new method that shares existing operator dialog code and
allows python configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/117564
2024-01-29 18:52:18 +01:00
Hans Goudey
1bb358f423 Fix: Tooltip memory leak
Use std::string for custom tooltip function return value.
2024-01-26 14:39:05 -05:00
Jesse Yurkovich
ddd06eeb8f UI: Add ability to configure the header row of layout panels
There are many instances where customizing the header row is desired so
return both the header row layout and the main body layout.

For consistency and correctness, the arrow symbol and the is_open check
are always performed so callers only need to perform layout tasks.

The C++ side now receives a `PanelLayout` structure containing both:
```cpp
PanelLayout panel_layout = uiLayoutPanelWithHeader( ... );
uiItemL(panel_layout.header, ... );
if (panel_layout.body) {
    ...
}
```

And the Python side receives a tuple:
```python
header, body = layout.panel( ... )
header.label(...)
if body:
    ...
```

```python
import bpy
from bpy.props import BoolProperty

class LayoutDemoPanel(bpy.types.Panel):
    bl_label = "Layout Panel Demo"
    bl_idname = "SCENE_PT_layout_panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        layout.label(text="Basic Panels")

        header, panel = layout.panel("my_panel_id", default_closed=True)
        header.label(text="Hello World")
        if panel:
            panel.label(text="Success")

        header, panel = layout.panel_prop(scene, "show_demo_panel")
        header.label(text="My Panel")
        if panel:
            panel.prop(scene, "frame_start")
            panel.prop(scene, "frame_end")

        layout.label(text="Customized headers")

        # Add a checkbox to the Panel header. text must be None for this panel
        header, panel = layout.panel("my_panel_id-2", default_closed=True)
        header.prop(scene, "use_checkmark", text="") # text must be empty for the checkbox
        header.label(text="Checkmark at beginning")
        if panel:
            panel.label(text="Success")

        header, panel = layout.panel("my_panel_id-3", default_closed=True)
        header.label(text="Buttons at the end")
        header.operator("mesh.primitive_cube_add", text="", icon='EXPORT')
        header.operator("mesh.primitive_cube_add", text="", icon='X')
        if panel:
            panel.label(text="Success")

        header, panel = layout.panel("my_panel_id-4", default_closed=True)
        header.prop(scene, "use_checkmark2", text="")
        header.label(text="Both")
        header.operator("mesh.primitive_cube_add", text="", icon='EXPORT')
        header.operator("mesh.primitive_cube_add", text="", icon='X')
        if panel:
            panel.label(text="Success")

bpy.utils.register_class(LayoutDemoPanel)
bpy.types.Scene.show_demo_panel = BoolProperty(default=False)
bpy.types.Scene.use_checkmark = BoolProperty(default=False)
bpy.types.Scene.use_checkmark2 = BoolProperty(default=False)
```

Pull Request: https://projects.blender.org/blender/blender/pulls/117248
2024-01-26 10:11:22 +01:00
Brecht Van Lommel
487adcb992 Fix: build error when not using unity build 2024-01-19 20:12:45 +01:00
Hans Goudey
7ca4dcac5a Cleanup: Use std::string for UI drop box tooltip return type
And use fmt for formatting strings.
2024-01-19 12:08:48 -05:00
Hans Goudey
6abf43cef5 Cleanup: Use std::string to store and pass tooltip text
Store temporrary tooltip text as `std::string` instead of
manually allocated C strings. Use `fmt` to format instead
of our own formatting utilities that return an allocated C
string.
2024-01-19 09:27:56 -05:00
Hans Goudey
90c4e2e6ec Cleanup: Replace UI button "string info" function
Instead of a single function with variadic arguments, a special enum
type containing which string to request, and a special struct to
contain the request and the result, just use separate functions for
each request, and return a std::string by value. Also change the enum
item string access to just give access to the enum item itself and add
const in a few places as necessary.

The callers of the API function get much clearer this way, and it's
much easier to see which information is used to create certain tooltip
strings.
2024-01-19 09:27:56 -05:00
Hans Goudey
f929fb5d77 Cleanup: Store uiBlock name as std::string
And change some adjacent code to benefit from the simplicity
and constant time access to the length of the string.
2024-01-18 16:13:00 -05:00