Commit Graph

132 Commits

Author SHA1 Message Date
Brecht Van Lommel
e06561a27a Build: replace Blender specific DEBUG by standard NDEBUG
NDEBUG is part of the C standard and disables asserts. Only this will
now be used to decide if asserts are enabled.

DEBUG was a Blender specific define, that has now been removed.

_DEBUG is a Visual Studio define for builds in Debug configuration.
Blender defines this for all platforms. This is still used in a few
places in the draw code, and in external libraries Bullet and Mantaflow.

Pull Request: https://projects.blender.org/blender/blender/pulls/115774
2023-12-06 16:05:14 +01:00
Harley Acheson
27992034f2 Fix #115815: Include Category name in Enum Row Calculation
Report #115815 shows a time where our calculation of rows and columns
should also include the category name lines. The code was calculating
where to break not including these and is too short if it has a
category.

Pull Request: https://projects.blender.org/blender/blender/pulls/115822
2023-12-06 01:37:04 +01:00
Campbell Barton
86f1fd5d8b BLI_idprop: simplify string creation logic, support unterminated strings
- Support passing in unterminated C-strings when clamped by the size
  argument.
- Pair string and it's size arguments together in IDP_NewStringMaxSize.
- Remove redundant size check which made it seem as if the string
  might not be null terminated.
- Replace clamping the result of strlen(..) with BLI_strnlen,
  to avoid calculating the length past the size checked.
- Add doc-string for unclamped string creation.
2023-12-05 17:11:03 +11:00
Bastien Montagne
3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Campbell Barton
c7593cc99f Cleanup: replace MAX2 with std::max 2023-11-29 17:11:09 +11:00
Hans Goudey
7e3ba529ea Cleanup: Move four blenkernel headers to C++ 2023-11-28 16:05:12 -05:00
Campbell Barton
4e10a4f635 Cleanup: various C++ updates from C 2023-11-27 10:59:54 +11:00
Harley Acheson
c5164e513f Fix #115275: Allow Wrapping of Single Column Enum Menus
Enum menus that do not have categories should be able to wrap to
multiple columns is there is enough horizontal space.

Pull Request: https://projects.blender.org/blender/blender/pulls/115283
2023-11-22 21:15:00 +01:00
Harley Acheson
2793b37f17 Fix #115085: Multicolumn Menus without Category Names
Handle menus that are meant to be multicolumn, with section dividers,
but not all sections have category names, just separators.

Pull Request: https://projects.blender.org/blender/blender/pulls/115102
2023-11-18 17:21:42 +01:00
Harley Acheson
be97ed2828 Fix #115023: Error Measuring Null Menu Item Name
Do not attempt to measure the length of a null string.

Pull Request: https://projects.blender.org/blender/blender/pulls/115027
2023-11-17 06:00:28 +01:00
Harley Acheson
83ce3ef0db Fix #72093: Collapse Wide Enum Lists to One Column
If a multi-column Enum menu gets too wide for the available space,
collapse it to a single column.

Pull Request: https://projects.blender.org/blender/blender/pulls/105386
2023-11-16 21:14:35 +01:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Julian Eisel
ecbb77c558 UI: Support dragging over node panel headers to batch (un)collapse
Makes it possible to swipe over panel header to batch open/collapse all
panels the mouse draged over. Normal panels and sub-panels support this
too.

Two changes were needed:
- Support "drag toggle" feature for `UI_BTYPE_BUT_TOGGLE` - all toggle
  buttons should/can support this.
- Allow querying the pushed state from the button used for the
  collapsing. Multiple ways to do this, in this case simply using the
  pushed state query callback seemed simplest.

Pull Request: https://projects.blender.org/blender/blender/pulls/114560
2023-11-07 10:59:33 +01:00
Campbell Barton
611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Julian Eisel
480dceab12 Asset shelf: Drag over checkboxes to enable/disable catalogs in selector
Makes it possible to swipe over the checkboxes used to enable or disable
catalogs in the asset catalog selector popup, to batch enable or disable
the ones dragged over.

Might also enable this feature for other cases where checkboxes are
displayed.
2023-11-06 22:22:54 +01:00
Julian Eisel
72a8851a95 UI Code Quality: Rename UI_ACTIVE button flag to UI_HOVER
Calling this state "active" has been confusing for a long time for a number of reasons:
- It's not clear that this is essentially a mouse hover state.
- Easy to confuse with "select" state (`UI_SELECT`), both terms are vague.
- Buttons can be "inactive" (`UI_BUT_INACTIVE`) which is totally related to this "active" state.
- Button handling can consider a button as active that doesn't have this flag set (e.g. during text input).
- Active and selected are well established terms in Blender, but they mean a different thing there.

See #112160.

Pull Request: https://projects.blender.org/blender/blender/pulls/114113
2023-10-25 18:36:27 +02:00
Brecht Van Lommel
38ec7ab51a Merge branch 'blender-v4.0-release' into main 2023-10-23 17:14:05 +02:00
Brecht Van Lommel
34a11f962f Fix Cycles time limit not showing unit when scene units are set to none 2023-10-23 17:12:38 +02:00
Harley Acheson
8919fb8bc7 UI: Fix Placeholder Bad String Comparison
Bad string comparison in ui_but_placeholder_get()

Pull Request: https://projects.blender.org/blender/blender/pulls/113706
2023-10-14 01:42:49 +02:00
Harley Acheson
0c064fab59 UI: Never Show Unknown Type Placeholder
Some but types of UI_BTYPE_SEARCH_MENU can have no ID code and also be
of UnknownType. Don't show placeholder in this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/113700
2023-10-13 23:39:45 +02:00
Harley Acheson
5a1ad7d61d UI: Improved Placeholder Defaults
Improvements to how placeholder strings are guessed. Checking for
search icon, and also using name of the RNA property type.

Pull Request: https://projects.blender.org/blender/blender/pulls/113688
2023-10-13 18:53:33 +02:00
Harley Acheson
3c4f84e0fc UI: Input Placeholders
Optional inline hint describing the expected value of an input field.

Pull Request: #112104
2023-10-12 11:44:08 -07:00
Harley Acheson
aa88d9a8e3 Revert "UI: Input Placeholders"
This reverts commit b0515e34f9.
Unintentionally added to 4.0
2023-10-11 08:01:24 -07:00
Harley Acheson
b0515e34f9 UI: Input Placeholders
Optional inline hint describing the expected value of an input field.

Pull Request: https://projects.blender.org/blender/blender/pulls/112104
2023-10-11 00:47:13 +02:00
Julian Eisel
e3d4cf9b3d UI: Allow popover panels to register own notifier listeners
This is necessary to let popovers redraw when asynchronously loading
data. For example to display assets or asset catalogs as they get
loaded. Needed for the asset shelf catalog selector popover. Menus
already do the same to allow populating the menu with assets as they get
loaded.
2023-09-27 11:31:21 +02:00
Hans Goudey
916d4c9d9b Cleanup: Move BKE_screen.h to C++
See #103343
2023-09-25 17:53:11 -04:00
Jacques Lucke
8362563949 UI: show recently selected items at the top of searches
The goal is to make the search faster to use by dynamically adapting to the user.
This can be achieved using the simple but common approach of showing recently
selected items at the top. Note, that the "matching score" between the query and
each search item still has precedence when determining the order. So the last used
item is only at the top, if there is no other search item that matches the query better.

Besides making the search generally faster to use, my hope is that this can also
reduce the need for manually weighting search items in some places. This is
because while the ordering might not be perfect the first time, it will always be
once the user selected the element that should be at the top once.

This patch includes:
* Support for taking recent searches into account in string searching.
* Keep track of a global list of recent searches.
* Store recent searches on disk similar to recently opened files.
* A new setting in the user preferences that allows disabling the functionality.
  This can be used if deterministic key strokes are required, e.g. for automated tests.

In the future this could be improved in different ways:
* Add some kind of separator in the search list to indicate which elements are at
  the top because they have been used recently.
* Store the recent search items per search, instead of in a global list. This way
  it could adapt to the user even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/110828
2023-09-25 10:56:12 +02:00
Hans Goudey
867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Julian Eisel
8b610723b6 Fix tooltip showing button label redundantly (regression)
With 9d0907560a, button tooltips would now often display the label even though
it's already visible in the button itself.

This fix brings back the old logic for displaying the label, but it's still
possible to override the label via the callback introduced in the earlier
commit.

Comments are updated/added here to make the behavior more clear.

Pull Request: https://projects.blender.org/blender/blender/pulls/110469
2023-09-21 14:49:53 +02:00
Julian Eisel
638881ed31 Fix incorrect preview tile button size label height
Mismatch between what drawing assumes and what the function to query the
full preview tile uses. This would cause previews to be scaled down
because the button wasn't tall enough. Only affected the asset shelf and
the asset view template.
2023-09-20 20:09:45 +02:00
Harley Acheson
6453b00f44 UI: Custom Tooltips with Optional Images
This adds an optional uiBut callback that allows creating a tooltip
line-by-line with specified style and color in any order. It also
allows adding images as well to create very informative tooltips.

Pull Request: https://projects.blender.org/blender/blender/pulls/105905
2023-09-15 21:06:30 +02:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Jacques Lucke
7f9d51853c UI: support searching in menus
The basic idea is very simple. Whenever a supported menu is open, one can just
start typing and this opens a search that contains all the (nested) menu entries.

The main downside is that this collides with accelerator keys. Those are the
underlined characters in each menu. For now, we just enable this new searching
behavior in a few selected menus: Node Add Menu, View3D Add Menu and
Modifier Add Menu.

This new functionality can be enabled for a menu by setting
`bl_options = {'SEARCH_ON_KEY_PRESS'}` to true in the menu type.

The status bar shows `Type to search...` when a menu is opened that supports search.

Pull Request: https://projects.blender.org/blender/blender/pulls/110855
2023-09-06 18:16:45 +02:00
Harley Acheson
d49c3d4d07 UI: Fixes for the highlighting of Selected Enums
Remove need for adding UI_BUT_LIST_ITEM, and replace use
of UI_BUT_ACTIVE_DEFAULT with UI_SELECT_DRAW

Pull Request: https://projects.blender.org/blender/blender/pulls/111938
2023-09-06 17:55:56 +02:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Harley Acheson
afa71adbb1 UI: Improved Enum Title Determination
Show Enum titles if there is a non-blank label before on the same row.

Pull Request: https://projects.blender.org/blender/blender/pulls/111818
2023-09-02 05:03:56 +02:00
Harley Acheson
9f4b28bba8 UI: Highlight Selected Enum
Highlight the currently-selected item in enum, and some other, lists.

Pull Request: https://projects.blender.org/blender/blender/pulls/111074
2023-09-01 21:33:03 +02:00
Harley Acheson
b122faf705 UI: Consistent Menu/Block/Popup Content Ordering
All Content is shown in natural top-down order regardless of where it
is initiated.

Pull Request: https://projects.blender.org/blender/blender/pulls/109798
2023-08-31 20:24:53 +02:00
Hans Goudey
ceb3d75c18 Cleanup: Use const for context store variables
Generally the context store is owned by `uiBlock`. Other pointers
to the store (in `bContext` and other operator data) shouldn't change
it, so those variables are now const. One exception is the pointer in
`uiLayout`, but that has a clearly short lifetime, so that's okay.
2023-08-31 12:00:04 -04:00
Hans Goudey
1763a46cbf Cleanup: UI: Store uiBlock context stores in vector instead of list
Also fix an issue where contest stores were copied with the "used"
flag set after 7d7e90ca68.
2023-08-31 12:00:04 -04:00
Julian Eisel
5dcf704324 Refactor: Solve invalid icon-id enum values, use type alias
Some code attempted to use `BIFIconID` instead of `int` to pass around
icon-ids. Problem is, that this is just a subset of the allowed ids,
more icons may be created at runtime and extend the range of valid
icon-ids. Such icons could give runtime warning prints.

Idea is to use a `using BIFIconID = int;` instead. This way there is
still a descriptive type name, while the whole dynamic range of possible
icon-ids is supported.

Additionally multiple `using BIFIconID = int;` declarations are valid,
so we can place these in multiple headers and use the type name in APIs
instead of just `int`, whithout having to include a single header
defining them. A type mismatch (one instance differs from the others)
will result in a compiler error.

Pull Request: https://projects.blender.org/blender/blender/pulls/111052
2023-08-14 12:06:35 +02:00
Hans Goudey
f0467b4615 Cleanup: Return std::string from operator name and description callbacks
With the end goal of simplifying ownership and memory management,
and allowing the use of `get_name` in contexts without statically
allocated strings, use `std::string` for the return values of these two
operator type callbacks instead of `const char *` and `char *`.

In the meantime things get uglier in some places. I'd expect `std::string`
to be used more in the future elsewhere in Blender though.

Pull Request: https://projects.blender.org/blender/blender/pulls/110823
2023-08-11 19:11:27 +02: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
Jacques Lucke
9150f6d1a9 BLI: refactor string search to use C++ API
The API becomes much simpler by using C++. Also, it removes the need
for manual memory management.

Pull Request: https://projects.blender.org/blender/blender/pulls/110826
2023-08-05 10:54:23 +02:00
Jacques Lucke
4719caf660 Cleanup: move BLI_string_search.h to C++ 2023-08-05 08:52:29 +02: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
98142f5e35 UI: Asset Shelf Support (Experimental Feature)
No user visible changes expected, except of new experimental feature
option.

------------------------------------------------------------------------------

This introduces asset shelves as a new standard UI element for accessing
assets. Based on the current context (like the active mode and/or tool), they
can provide assets for specific workflows/tasks. As such they are more limited
in functionality than the asset browser, but a lot more efficient for certain
tasks.

The asset shelf is developed as part of the brush assets project (see #101895),
but is also meant to replace the current pose library UI.

Support for asset shelves can quite easily be added to different editor types,
the following commit will add support for the 3D View. If an editor type
supports asset shelves, add-ons can chose to register an asset shelf type for
an editor with just a few lines of Python.

It should be possible to entirely remove `UILayout.asset_view_template()` once
asset shelves are non-experimental.

Some changes are to be expected still, see #107881.

Task: #102879
Brush asset workflow blog post: https://code.blender.org/2022/12/brush-assets-workflow/
Initial technical documentation: https://developer.blender.org/docs/asset_system/user_interface/asset_shelf/

Pull Request: #104831
2023-08-03 16:54:39 +02:00
Campbell Barton
c6f3f19648 Cleanup: reduce variable scope when removing in a while loop 2023-08-03 19:17:43 +10:00