Commit Graph

6114 Commits

Author SHA1 Message Date
Germano Cavalcante d6b2b5d0c5 Fix #112978: MacOS no longer has a path associated with the window
The problem was introduced in 636f3697ee

MacOS has a different way of handling the title.

In this OS the directory is searched and taken from the title string
which is then formatted.

This limits the title format and makes it prone to errors.

This commit makes the code more generic by splitting each component of
the title beforehand and allowing the associated directory to be informed
with `GHOST_SetTitle`.
2023-10-04 21:23:38 -03:00
Campbell Barton 30a580bf30 Fix failure to remove temp-dir when initializing GPU backend fails
Call WM_exit() instead of exit() cleanup functions run.
2023-10-04 11:41:59 +11:00
Damien Picard 52fcd5fdfd I18n: extract and disambiguate a few messages
Disambiguate:
- Rename "Near" to "Proximity" as a particle event type, because using
  an adjective in this context is inconsistent and sounds
  strange (even in English IMO).

Extract:
- "Skip" (Geometry nodes Simulation node output socket)
- "Bake" (Directory path to geometry nodes bake files in the modifier
  UI)
- " (Recovered)" (File information in title bar)

Pull Request: https://projects.blender.org/blender/blender/pulls/112974
2023-10-03 18:21:03 +02:00
Campbell Barton 41d62f36d5 Fix uninitialized variable use accessing the screen size under Wayland
It's possible for there to be no outputs under Wayland
(when unplugging monitors for e.g.) so this must be accounted for.

Also avoid calculating the window position when the GHOST backend
doesn't support window positions (which is the case for Wayland).

Add checks for the SDL backend too, where accessing the
screen & desktop size may fail.
2023-10-03 15:40:58 +11:00
Campbell Barton dea7a94e0c Cleanup: remove redundant call to GHOST_GetMainDisplayDimensions
A maximum window size was calculated but not used
(dating back to the first commit).
2023-10-03 15:09:53 +11:00
Harley Acheson e196f0a874 Fix #113044: Reset Fonts When Loading New Files
Close user-loaded fonts when loading a new blend file so that the
global_font slots are not taken up by the old file's fonts.

Pull Request: https://projects.blender.org/blender/blender/pulls/113104
2023-10-03 01:21:03 +02:00
Harley Acheson fef8b38acb UI: Less Cursor Changes While Loading Files
Less changes of mouse cursor while loading blend files. And no changes
to it while reading the homefile.

Pull Request: https://projects.blender.org/blender/blender/pulls/113123
2023-10-01 17:44:53 +02:00
Jeroen Bakker 2d864846e4 Fix #113002: Fix Crash When Loading Previous Settings
The default theme of blender has no `icon_border_intensity` and
therefore only loads the regular icons. When newly loaded theme has the
`icon_border_intensity` set it needs to reload the icon textures so both
icon maps would be loaded.

Without reloading the icons a GPU texture is missing and would crash
blender at first use. Starting Blender the second time it would load the
correct icons and would work as expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/113016
2023-09-28 20:44:15 +02:00
Harley Acheson 18fcb9b3fb UI: Show Waiting Mouse Cursor While File Loading
Change the mouse cursor to a "waiting" one during the majority of the
time that a blend file is loading.

Pull Request: https://projects.blender.org/blender/blender/pulls/112986
2023-09-28 17:19:52 +02:00
Campbell Barton be7c8fac6d Fix #112990: save pre/post/post/fail don't run for unwritable paths
When the destination path isn't writable - the save callbacks wouldn't
run. Supporting this can be useful so handlers can unlock a file
before saving, see #88493.
2023-09-28 14:13:05 +10:00
Campbell Barton 881bb81763 UI: don't access recent-search.txt when disabled or in background mode 2023-09-28 13:42:29 +10:00
Pratik Borhade cea02c15f8 Fix #112896: Search menu: First character remains in text field
Search menu (F3) displays character which was pressed to open a context
specific search. This also breaks the old behavior of showing last searched
operator in text field, instead shows the pressed character.
To fix this, first store the `g_search_text/but->poin` string in
temp_buffer (before pressed key char is copied to `g_search_text`).
Later, restore the g_search_text after invoking the search menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/112938
2023-09-27 12:07:12 +02:00
Julian Eisel ca2a8be15f Assets: Rename "Import Type" to "Import Method" in code/BPY
It was already called that way in the UI, since it's referring to a
behavior, not a type. Update the code to match that. Note that this is
a BPY compatibility breaking change for 4.0.
2023-09-26 16:48:47 +02:00
Hans Goudey 916d4c9d9b Cleanup: Move BKE_screen.h to C++
See #103343
2023-09-25 17:53:11 -04:00
Falk David 16e195a111 Cleanup: GPv3 layer tree manipulations
In preparation of https://projects.blender.org/blender/blender/pulls/112535, we need to make sure all layer tree manipulations are in functions on the `GreasePencil` struct so we can keep the `CustomData` for layers in sync with the layer tree.

 This PR makes sure that all the functions that change the layer tree in any way are `protected` on the `LayerGroup` class. The `GreasePencil` struct is declared `friend` with `LayerGroup`.

We also cleanup and remove a lot of code duplication between layers and layer groups and try to write functions in a generic way for `TreeNode` (both layers and layer groups are tree nodes).

Pull Request: https://projects.blender.org/blender/blender/pulls/112837
2023-09-25 12:11:18 +02: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
Campbell Barton d4dbbab5d9 Cleanup: locate break statements inside the case body
Follow the convention used almost everywhere in Blender's code.
2023-09-23 21:17:50 +10:00
Hans Goudey 70ffc7a2de Fix: Missing "Add Shortcut" for node group operator
The operator uses the relatively new "GEOMETRY_OT" prefix,
which wasn't handled in the function that finds a keymap for an
operator. To support this, choose the 3D View keymap depending
on the current mode for the geometry object types.
2023-09-22 14:28:35 -04:00
Pratik Borhade bb39f4fa41 Fix #112441: Restore Key Map Item does not restore the active property
`Restore item` button is not resetting `active` property when keyitem is registered
as `inctive` by default. To fix this, clear `inactive` flag then use default keyitem's
flag to correctly restore the keyitem.

Pull Request: https://projects.blender.org/blender/blender/pulls/112497
2023-09-22 12:58:02 +02:00
Campbell Barton 5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10: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
Campbell Barton 4e46803e04 Docs: add warning regarding WM_redraw_windows 2023-09-22 10:02:05 +10:00
Harley Acheson e7df63ca72 Revert "UI: File Loading Waiting Feedback"
This reverts commit 9173c142d6 as this can cause problems from scripts
and command-line.

Pull Request: https://projects.blender.org/blender/blender/pulls/112682
2023-09-21 18:48:07 +02:00
Harley Acheson 2c6f08ab16 Cleanup: Make format
Formatting changes resulting from Make Format
2023-09-20 11:21:25 -07:00
Harley Acheson 9173c142d6 UI: File Loading Waiting Feedback
When loading a blend file remove any open menus and show a "waiting"
mouse cursor during the process.

Pull Request: https://projects.blender.org/blender/blender/pulls/112636
2023-09-20 20:15:38 +02:00
Campbell Barton fb81c37077 Cleanup: avoid redundant strlen calls 2023-09-20 12:11:33 +10:00
Campbell Barton f8719abdf4 Cleanup: merge key-map clear & free into one loop 2023-09-20 12:11:28 +10:00
Campbell Barton 53cbdaaa8b WM: ensure wmEvent::utf8_buf isn't treated as a null terminated string
In debug mode, fill remaining bytes so functionality that relies
on null termination will alert developers to incorrect use early on.
2023-09-20 09:50:52 +10:00
Richard Antalik 264c3e7bd7 Revert "Fix: Box select not working with tweak took in VSE"
This reverts commit cabf935afb.

After more investigation I have realized, that this change introduces
another regression and more importantly it is not suited for RCS keymap.
2023-09-19 23:26:05 +02:00
Richard Antalik cabf935afb Fix: Box select not working with tweak took in VSE
Use Select Box tool by default.

After 618f39fca2 box select operator is not run with tweak tool. This
is regression for sequencer, but the new behavior is consistent with
other editors.
2023-09-19 17:59:16 +02:00
Julian Eisel ca58f97cda Refactor: Use asset representation for asset browser context query
There's no need to use the asset handle type here anymore, it can just
use the asset representation type that is supposed to replace it.

Part of #102877 and #108806.
2023-09-19 15:56:11 +02:00
Campbell Barton d8b8089630 Cleanup: spelling & typo in last commit 2023-09-19 15:53:51 +10:00
Campbell Barton e8df5cec83 PyAPI: free internal Python data using sys.exit(..)
Previously BPY_python_end wasn't called when scripts called sys.exit()
because BPY_python_end exited the Python interpreter.

Change this behavior to call BPY_python_end without exiting the Python
interpreter while freeing Blender/Python data.

While leaks in the context of sys.exit aren't especially important
it's generally preferable for sys.exit() to match Blender's code-paths
for exiting to avoid unexpected behavior.
2023-09-19 15:50:41 +10:00
Campbell Barton 085b094f18 Cleanup: use const arguments & variables 2023-09-19 11:09:20 +10:00
Campbell Barton ab4562738c Cleanup: add asserts, improve wmEvent::utf8_buf doc-string
- rna_Event_unicode_length would return -1 if utf8_buf wasn't a valid
  unicode sequence, while this shouldn't happen, assert and return zero
  instead of returning a bad length.
- Move comment on wmEvent::utf8_buf null termination to a doc-string.
2023-09-18 14:32:15 +10:00
Campbell Barton ed552e9e4f Cleanup: add suffix to clarify unicode functions that return an error
There were enough cases of callers ignoring a potential the error value,
using the column width for e.g. to calculate pixel sizes, or the size in
bytes to calculate buffer offsets.

Since text fields & labels can include characters that return an error
from BLI_str_utf8_as_unicode, add the suffix to make this explicit.
2023-09-18 13:41:03 +10:00
Campbell Barton 1cda66b911 WM: resolve transform triggering key-maps to be rebuilt
Since [0] modal transform in the 3D viewport caused key-maps to be
rebuilt by the event system. Creating a temporary copy for
ViewOpsData_Utility flagged the key-map as outdated.

This could crash (resolved by [1] - for the most-part), but would still
rebuild the whole key-map, adding unnecessary overhead.

This would also reset the KMI_EXPANDED flag, causing transform
to hide key-map items when using Blender with the key-map editor open.

Add a function to temporarily suppress key-map updates.
While not ideal, full support for temporary key-maps that behave
differently to user key-maps is a bigger project for something
that's only needed in one place.

[0]: 017d4912b2
[1]: 9a0eaa2062
2023-09-17 13:36:25 +10:00
Campbell Barton ad04167a7d Cleanup: avoid path copying & allocation setting the window title 2023-09-17 12:03:08 +10:00
Harley Acheson 636f3697ee UI: Window Title With Version
Include blender version information in title (including cycle), and
also indicate unsaved and dirty status better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111998
2023-09-16 02:37:06 +02:00
Leon Schittek 42f8b49581 Fix: Show modal keymap for operators called inside macros
Display the modal keymap in the status bar for modal operators that
are called within macros. Most notably, the keymap for the transform
operator is displayed when it's called as part of the duplicate,
extrude, or loopcut operators or when moving nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/108027
2023-09-15 19:33:20 +02:00
Campbell Barton 635a4eac05 Fix delete key setting a control character in wmEvent::utf8_buf
The check for control characters didn't account for delete (127).
This wasn't noticeable in most cases as delete is mapped to delete text.
Pressing Shift-Delete would enter 127 control character in the
text-editor, 3D text & Python console. This happened X11 & Wayland,
I didn't check other platforms.
2023-09-15 16:01:00 +10:00
Hans Goudey cc83951951 Geometry Nodes: Update node tool menus dynamically
See #101778

Remove the requirement of restarting Blender to refresh the
extended 3D view menus for node group changes. Also avoid
rebuilding the tree of relevant assets and catalogs on every
redraw, since parsing asset libraries, etc. could become more
expensive than we want. Those two goals combined mean we
have to be more rigorous in how we invalidate the cached
catalog tree.

The first main change required is to clear the tree as asset libraries
are being read, similar to other dynamic asset menus. This is done
with a 3D view header listener rather than a menu listener in this case.

However, that isn't enough, because there is an issue with the asset
system where the "all" library isn't updated when the current file library
changes. The solution is to explicitly rebuild the "all" library's catalogs
when other asset libraries are changed.

The other necessity for dynamic updates is clearing the catalog tree
to be rebuilt when the node group "asset traits" are changed. This is
done with a new notifier type (with the goal of being a bit selective
about when we re-read assets). This _also_ requires running the
"presave" callback that builds asset metadata when updating the
property. Otherwise saving the file and sending the notifier is
necessary, which is too confusing.

Pull Request: https://projects.blender.org/blender/blender/pulls/112166
2023-09-14 17:43:33 +02:00
Campbell Barton c7cd1c8d0b Cleanup: use enum literals for space_type & region_type arguments
Also remove unique names for grease pencil keymaps.
There was not advantage in having separate names for each grease pencil
key-map.
2023-09-14 13:36:34 +10:00
Campbell Barton fad72f6daa Cleanup: always run both RNA_STRUCT_BEGIN & END macros
In this case it didn't cause any problems however macros with a
BEGIN/END must always run both, not optionally run based on knowledge
of the iterator implementation cleanup requirement.
2023-09-14 10:28:55 +10:00
Campbell Barton 9a0eaa2062 Fix crash using the key-map editor after refreshing internal data
Any action that triggered the key-map to be rebuilt causes the key-map
UI to display freed data.

Recently key-map refreshing happens during transform, while this should
be resolved - it's still good to avoid a crash in this situation as it's
possible scripts perform actions that tag the key-map to be rebuilt
which is out of our control.
2023-09-13 16:46:59 +10:00
Campbell Barton ec58f3d4cd RNA: move the "contains" checks into the RNA API
C++ callers must ensure the arguments are valid,
reserve validity for the RNA API for raising errors.

This is already the case for most RNA API calls that wrap BKE API's.
2023-09-13 15:01:49 +10:00
Ray Molenkamp 5f8dfa231d CMake: Fix building with WITH_VULKAN_BACKEND
Ghost uses vulkan in its public headers but none of the projects that
depend on ghost had the vulkan headers in its includes nor did
bf_intern_ghost expose this vulkan dependency itself publicly yet.

bf_windowmanager also did not express its dependency on
bf_intern_ghost yet used its headers.

this change fixes both issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/112259
2023-09-12 15:07:41 +02:00
Hans Goudey c59d998ce5 Geometry Nodes: Skip redo panel for node tools without inputs
The operator system assumes that the `ot->ui` callback means
there will always be a redo panel. This situation where there is a
callback but sometimes no inputs hasn't been encountered before.

Resolve that by changing `WM_operator_check_ui_empty` into
a `WM_operator_ui_poll` that handles this case properly, with
a new operator type callback called `ui_poll`.

See #101778, #111346

Pull Request: https://projects.blender.org/blender/blender/pulls/112251
2023-09-12 13:24:05 +02:00
Bastien Montagne 8289c83dfe Cleanup: Add warning about current limitations of operators' `get_name` callback.
This callback is actually never excuted when e.g. defining operators
buttons through the layout API.

A design task has also been created to keep track of this issue: #112253
2023-09-11 20:37:03 +02:00
Hans Goudey 4caa2dddd9 Cleanup: Grammar and corrections in operator type documentation 2023-09-11 13:42:07 -04:00
Sybren A. Stüvel 9d65214d5b Anim: add notifier `ND_BONE_COLLECTION` for bone collection changes
Send nodifier `NC_OBJECT | ND_BONE_COLLECTION` on bone collection changes.
2023-09-08 15:53:35 +02:00
Campbell Barton 9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Harley Acheson 63e210895b UI: Proper Selection Highlight for Confirms
Operator Confirms get blue highlights since we use those like dialogs.

Pull Request: https://projects.blender.org/blender/blender/pulls/111949
2023-09-06 18:24:48 +02: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 bb31df1054 UI: Allow "New Window" While in Maximized Area
While an editor is in "Maximize Area" mode, allow Window / New Window.

Pull Request: https://projects.blender.org/blender/blender/pulls/111999
2023-09-06 17:50:19 +02:00
Philipp Oeser 2b5f97b8c4 Fix #111955: Animation player no longer responds to mouse input
Caused by C++ conversion in f07a112cb5.

Above commit was casting directly from event (instead of the event
data).

Pull Request: https://projects.blender.org/blender/blender/pulls/112010
2023-09-06 10:24:00 +02:00
Campbell Barton 48394561d7 Fix keyconfigs.remove(..) leaving dangling pointers
Removing key-configs that also had direct pointer access
left them pointing to freed memory.
2023-09-06 14:23:04 +10:00
Campbell Barton 1f285a5ec8 Cleanup: early return to reduce right shift 2023-09-06 12:05:19 +10: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
Campbell Barton 6de294a191 PyAPI: postpone loading add-ons until after key-maps have been defined
Loading add-ons after key-maps resolves a problem where add-ons would
setup shortcuts before Blender had created the key-maps.
Making add-ons have to declare the key-maps using region & window types
matching Blender's internal values.

This PR a pitfall pointed out in #110030.

Ref !110092
2023-09-05 11:35:14 +10:00
Julian Eisel ba03948dd2 Cleanup: Move BKE preview image code to separate file
Previously, BKE level preview image code was in `BKE_icons.h` and `icons.hh`.
While these types are related, I always found this quite hard to navigate since
preview image stuff was just in the middle of icon functions. Plus, people
don't expect preview image functions in icon files, the relationship is not
obvious.

Instead, use focused files that make it easy to quickly navigate them
and see what they are dealing with.

Pull Request: https://projects.blender.org/blender/blender/pulls/111709
2023-09-04 18:02:16 +02:00
Hans Goudey 840769d855 Cleanup: Small C++ changes to two tree view uses
- Use `this->` to access class methods.
- Follow style guide for class definition order.
- Avoid unnecessary namespace redefinition.
- Make data struct local to node interface file.
2023-09-01 23:07:51 -04:00
Campbell Barton f99c6c8785 Cleanup: rename wmTimer struct members for clarity 2023-09-01 11:40:07 +10:00
Campbell Barton 2a7b2e477f Fix potential non utf8 strings caused by truncation 2023-09-01 11:36:51 +10: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 feb14a4d38 Cleanup: Simplify bContextStore API with C++ concepts
Remove the need for `CTX_store_copy` and `CTX_store_free` by using
C++ copy constructors, unique pointers, and `std::optional`. A few types
are made non-trivial to support this.
2023-08-31 12:00:04 -04:00
Campbell Barton 54e2aaf9ad Cleanup: split WM_keyconfig_new into new/ensure functions
Use less ambiguous naming where new(..) always returns new data.
2023-08-31 17:45:39 +10:00
Campbell Barton 1ffc0a9e64 Fix key-maps being handled twice when reloading scripts 2023-08-31 12:04:28 +10:00
Campbell Barton 4a42f2b07c Cleanup: spelling 2023-08-31 10:38:13 +10:00
Lukas Tönne e071288ab2 Nodes: Panels integration with blend files and UI
Part 3/3 of #109135, #110272

Switch to new node group interfaces and deprecate old DNA and API.
This completes support for panels in node drawing and in node group
interface declarations in particular.

The new node group interface DNA and RNA code has been added in parts
1 and 2 (#110885, #110952) but has not be enabled yet. This commit
completes the integration by
* enabling the new RNA API
* using the new API in UI
* read/write new interfaces from blend files
* add versioning for backward compatibility
* add forward-compatible writing code to reconstruct old interfaces

All places accessing node group interface declarations should now be
using the new API. A runtime cache has been added that allows simple
linear access to socket inputs and outputs even when a panel hierarchy
is used.

Old DNA has been deprecated and should only be accessed for versioning
(inputs/outputs renamed to inputs_legacy/outputs_legacy to catch
errors). Versioning code ensures both backward and forward
compatibility of existing files.

The API for old interfaces is removed. The new API is very similar but
is defined on the `ntree.interface` instead of the `ntree` directly.
Breaking change notifications and detailed instructions for migrating
will be added.

A python test has been added for the node group API functions. This
includes new functionality such as creating panels and moving items
between different levels.

This patch does not yet contain panel representations in the modifier
UI. This has been tested in a separate branch and will be added with a
later PR (#108565).

Pull Request: https://projects.blender.org/blender/blender/pulls/111348
2023-08-30 12:37:21 +02:00
Campbell Barton 0db1664ba4 Cleanup: reduce right shift in wm_window_timers_process 2023-08-30 12:17:30 +10:00
Campbell Barton d7b9467f19 Cleanup: simplify wm_jobs_timer_end, wm_jobs_timer
The logic in wm_jobs_timer made it seem as if timers might be shared
between wmJob's however this is never the case.

Replace a loop on wmJob's with a lookup & NULL check.
2023-08-30 12:17:29 +10:00
Campbell Barton 09471c8636 Cleanup: simplify WM_event_timer_sleep
Use remove the inline loop as it was only used to check if the timer
is in wm->timers.
2023-08-30 11:11:20 +10:00
Campbell Barton 745f78f9f0 WM: improve timer precision for more precise playback
When a timer needs to execute during the idle time (currently 5ms), use
microsecond precision to ensure the timer isn't delayed by the idle
time.

This improves the precision of animation playback on systems that
support it
(WIN32, see note below).

In my tests FPS playback varied:

- 59.94 FPS would jitter between 58.13 & 63.11 FPS. 23.98 FPS would
- jitter between 23.68 & 24.31 FPS.

Using higher precision timers mostly resolves this issue although there
is still some jitter although it's now limited to ~0.01 FPS.

These values were measured with the FPS-Samples set to 1 to show the
real times between frames (without the values being smoothed out).

This is a continuation of a fix for #111579 which avoided the worst of
the jittering issues at higher frame rates.

It appears WIN32 doesn't support sleeping shorter than 1 millisecond via
`std::this_thread::sleep_for`, making this change have no benefit on
WIN32, from tests it also doesn't have any down sides, so avoid platform
specific logic. The WIN32 limitation is noted in code-comments. If a
method of higher precision method is available this can be investigated.
2023-08-30 10:57:20 +10:00
Bastien Montagne 5ba692898e I18N/UI messages fixes. 2023-08-28 18:02:31 +02:00
Hans Goudey 3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Campbell Barton 0e2f4046c6 Fix #111579: erratic viewport FPS at high frame rate
Setting the FPS to 120 caused the FPS to flicker erratically between
130 & 140 FPS.

This also impacted lower frame-rates with 23.98 playing back at 24.03
FPS on my system, 30 FPS played back at 30.13 FPS.
This problem was hidden by the FPS display rounding to an integer.

Regression in 2.5x series (worked in 2.49).

Resolve by clamping the sleep time in the main event loop so the 5ms
sleep doesn't result in sleeping when timers are scheduled to run.

There is still some visible FPS jitter that can be solved by using a
higher resolution sleep interval but that's out of scope for this fix.
2023-08-27 17:26:05 +10:00
Campbell Barton 09f61f6881 Cleanup: enforce documented convention for RNA enum naming
This was noted in code comments and checked in Python documentation
generation but not at build time.

Since these enums are identifiers that end up included in various places
enforce the `rna_enum_*_items` convention which was noted as
the convention but not followed strictly.

Partially reverts [0], avoids having to deal with multiple prefix types.

[0]: 3ea7117ed1
2023-08-25 13:35:58 +10:00
Bastien Montagne b53c7a804a Readfile: Replace the 'lib_link' specific code by generic usage of foreach_id.
The `lib_link` callback cannot always be fully replaced/removed, as in
some case it is also doing some validation checks, or data editing based
on the result of lib_linking internal ID pointers.

The callback has been renamed for that purpose, from `read_lib` to
`read_after_liblink`. It is now called after all ID pointers have been
fully lib-linked for the current ID, but still before the call to
`do_versions_after_linking`.

This change should not have any behavioral effect. Although in theory
the side-effect of this commit (to split lib linking itself, and the
validation/further processing code) into two completely separated steps
could have some effects, in practice none are expected, and tests did
not show any changes in behavior either..

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-24 16:33:31 +02:00
Bastien Montagne 8bb5916183 Readfile: Replace the 'expand' specific code by generic usage of foreach_id.
The `expand` callback is 'trivial' to replace, since it is only iterating
over ID pointers and calling a callback.

The only change in behavior here is that some pointers that were not
processed previously will now be.

In practice this is not expected to have any real effect (usually
the IDs used by these pointers would have been expanded through other
usages anyway). But it may solve a few corner cases, undocumented issues
though.

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-23 16:44:56 +02:00
Campbell Barton c52965e9c7 Cleanup: simplify struct declarations 2023-08-23 13:45:19 +10:00
Bastien Montagne 7a0a406ff8 Core: foreach_id: add optional support for deprecated ID pointers.
This commit adds a new option flag to the lib_query foreach_id code,
which will make deprecated ID pointers to be processed as well.

NOTE: Currently there is no report to the callbakcs about the fact that
it is processing a deprecated ID. This can be easily added later if it
becomes necessary.

Part of implementing #105134: Removal of readfile's lib_link & expand code.
2023-08-22 17:47:57 +02:00
Bastien Montagne b075c84ba3 Fix (unreported) invalid memory access in new 'newer blendfile version' code.
When choosing the new 'overwrite' option when trying to save a blendfile
from a newer version of Blender, it would cause invalid (use-after-free)
memory access.

Issue caused by the main commit (a1d7ec7139) of the new blendfile
compatibility handling. No idea how it was not detected earlier.

Many thanks to @weizhen for spotting the issue and doing some initial
investigation on it.
2023-08-22 17:26:37 +02:00
Campbell Barton e611ef4312 Cleanup: use term even_xy for window relative coordinates, not mval
The term `mval` is reserved for region-relative coordinates
(see wmEvent::mval).
2023-08-22 13:57:58 +10:00
Campbell Barton 5a8cb665e0 Cleanup: various non-functional C++ changes 2023-08-19 23:52:47 +10:00
Campbell Barton bc1ffdce5b Cleanup: spelling in comments 2023-08-18 08:56:12 +10:00
Bastien Montagne a99cccaff8 Fix (unreported) WM 'foreach_id' code skipping `unpinned_scene` pointer.
Previous code would not process that ID pointer in case the
`workspace_hook` pointer was null.
2023-08-17 10:57:58 +02:00
Harley Acheson d102536b1a Fix #93685: Allow Outliner Drag to Other Windows
Allow dragging items from Outliner to other windows. Disables EdgePan
operator when entering new window. Canceling the drop redraws target
area and resets all modal cursors. But this does not fix incorrect
mouse cursor during operations on the remote target window.

Pull Request: https://projects.blender.org/blender/blender/pulls/105196
2023-08-17 00:48:32 +02:00
Harley Acheson 5741a5d433 UI: Allow Eyedropper Outside of Blender
This adds a new Ghost function, GHOST_GetPixelAtCursor, that allows
picking colors from outside of Blender windows. This only has an
implementation for the Windows platform, but this should allow other
platforms to also do so if possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/105324
2023-08-16 01:14:36 +02: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
Jeroen Bakker dd4ab50065 GPU: Add Dummy Backend For Unsupported Platforms
With the introduction of metal and vulkan we use a different
GPU backend selection which broke the dialog box for unsupported
platforms.

Blender asserted and segfaulted before the dialog was being shown
to the user.

This patch solves this by introducing a dummy GPU backend in case no
GPU backend was supported by OpenGL, Metal and Vulkan Backend.

It also adds the showMessageBox to GHOST_SystemCocoa.

Related to #110335

Pull Request: https://projects.blender.org/blender/blender/pulls/110919
2023-08-15 14:15:12 +02: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
Campbell Barton 86c4ce66af Cleanup: pass ICON_NONE instead of zero to UI functions 2023-08-12 16:29:49 +10: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
Bastien Montagne 3f8416a1b2 Documentation: Add i18n info about operators' `get_name`/`get_description` callbacks. 2023-08-11 12:14: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
Jason Fielder 2367ed2ef2 macOS: Enable support for EDR rendering
Add a High Dynamic Range option in the Color Management > Display panel.
This enables display of extended color ranges above 1.0 for the 3D
viewport, image editor and render previews.

This requires a monitor that can display HDR colors, and a view
transform designed for HDR output. The Standard view transform works,
but Filmic does not as it was designed to bring values into the 0..1
range for SDR displays.

This patch is limited to allowing the display to visualize extended
colors, but does not include future looking work to better integrate HDR
into the full workflow.

It is implemented by rendering to high bit-depth texture formats for
the user interface, and uncapping the color range in color management.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/105662
2023-08-09 14:25:15 +02:00
Campbell Barton 31cb31d736 PyAPI: add-on name-spacing for extension repositories
Support name-spaced add-ons, exposed via user configurable extension
repositories.

Directories for add-ons can be added at run-time and are name-spaced to
avoid name-collisions with Python modules or add-ons from other
repositories.

This is exposed as an experimental feature "Extension Repositories".

Details:

- A `bUserExtensionRepo` type which represents a repository which is
  listed in the add-ons repository.

- `JunctionModuleHandle` class to manage a package with sub-modules
  which can point to arbitrary locations.

- `bpy.app.handlers._extension_repos_update_{pre/post}` internal
  callbacks run before/after changes to extension repositories,
  callbacks are used to sync the changes to the Python package that
  exposes these to add-ons.

- The size of an add-on name has been increased so a user-defined package
  prefix can be included without enforcing shorter add-on names.

- Functionality relating to package management has been left out of this
  change and will be developed separately.

Further work:

- While a repository can be renamed, enabled add-ons aren't renamed.
  Eventually we might want to support this although we could also
  disallow renaming repositories with add-ons enabled as the name isn't
  all that significant.

- Removing a repository should remove all the add-ons located in this
  repository.

- Sub-module names are currently restricted to `[A-Za-z]+[A-Za-z0-9_]*`
  we might want to relax this to allow unicode characters (we might
  still want to disallow `-` or any characters that would prevent
  attribute access in code).

Ref !110869.

Reviewed By: brecht
2023-08-09 20:24:24 +10:00
Campbell Barton 8198de0b0b Cleanup: format disabled code (missed in recent cleanup) 2023-08-09 11:13:55 +10:00
Campbell Barton 1a675d0c47 Cleanup: format disabled code 2023-08-09 10:49:53 +10:00
Campbell Barton bf2b1f7e01 Cleanup: simplify enum typedefs 2023-08-05 14:22:48 +10:00
Campbell Barton 7f34ad736a Cleanup: spelling in comments 2023-08-05 13:54:25 +10:00
Hans Goudey 07019e7ef5 Cleanup: Remove more struct keywords from C++ headers 2023-08-04 22:47:29 -04: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 c15d391e86 Cleanup: Various cleanups in newly C++ headers
Mostly remove unnecessary struct and typedef keywords.
Move a few more small wm headers to C++ as well.
2023-08-04 17:55:14 -04: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
Campbell Barton adf58a77ff Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros 2023-08-04 08:51:13 +10: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 0af370a62d Cleanup: use C++ style sizeof(struct::member) instead of casting nullptr 2023-08-03 20:23:01 +10:00
Campbell Barton de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton c6f3f19648 Cleanup: reduce variable scope when removing in a while loop 2023-08-03 19:17:43 +10:00
Hans Goudey 731d296f35 Cleanup: Move mesh related blenkernel headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110730
2023-08-02 22:14:18 +02:00
Bastien Montagne 4f673f18af Move `BKE_lib_override.h` header to be fully C++.
This implies using the `.hh` extension, and removing the `extern "C"`
blocks from it.

Pull Request: https://projects.blender.org/blender/blender/pulls/110718
2023-08-02 17:44:37 +02:00
Campbell Barton 6d2326dabf Cleanup: use function style casts 2023-07-31 19:57:32 +10:00
Campbell Barton 52acf6a6ec Cleanup: correct file names in comments after C -> C++ renaming
Use back-tick quotes to differentiate these from plain text.
2023-07-31 13:02:30 +10:00
Campbell Barton 724755879e Cleanup: spelling in comments, use doxygen doc-strings 2023-07-31 10:18:09 +10:00
Campbell Barton cfffd813c1 Cleanup: use typed enum for UI_ITEM_* flags
Using an int lead to confusion with other flags often used with buttons.
For e.g. these flags could be easily confused with uiItem::flag.
2023-07-29 15:32:45 +10:00
Campbell Barton ed01e16aa6 Cleanup: quiet uninitialized warnings 2023-07-29 13:47:57 +10:00
Julian Eisel d1e590eafa Refactor: Avoid evil context storage in drag data for asset import
Context is needed to import and instantiate assets correctly. Previously
the context was stored as "evil" pointer in the drag data. Since
77794b1a7b, context is passed to the dragging callbacks doing the asset
import, so the context doesn't need to be stored that way anymore and
can simply be passed to the import function.
2023-07-28 12:20:27 +02:00
Campbell Barton ea8d985db8 Cleanup: various C++ cleanups
- Use C++ headers.
- Use function style cast.
- Use boolean literals.
- Remove redundant struct, void.
- Remove redundant parenthesis.
2023-07-28 09:38:07 +10:00
Bastien Montagne a1d7ec7139 Core: Implement new blendfile compatibility handling.
This implements the main aspects of changes to blendfile compatibility
as designed in #109151:
* Blender files which file minversion is newer than current Blender
  executable won't be loaded at all.
* Blender files which file version is newer than current Blender will
  triger systematic warning to user:
  * In the status info bar (lower right corner in default UI).
  * When attempting to save (overwrite) them.

This means that the file minversion becomes a hard limit, and not a
soft, warning-only as it used to be. Further more, forward compatibility
warning is now systematic (instead of depending on file minversion),
and more visible for users.

See also https://wiki.blender.org/wiki/Process/Compatibility_Handling
for details over the new policy.

Technically:
* Opening any file with a minversion newer than current Blender file one
  now triggers an early abort, with an error message reported to the user.
  This is handled by a new utils called from `blo_decode_and_check`.
* Any file newer than current Blender version sets a new
  `has_forward_compatibility_issues` flag in Main struct at read time.
* Status bar info area is turned into a template, which uses this flag
  to display special warning UI and tooltip when set.
* A new confirmation popup appears when user tries to save (overwrite)
  such a 'newer' blendfile, stating potential loos of data, and
  proposing by default to 'save as' instead.
* The 'quit unsaved' popup has also been updated to 'save as' instead of
  'save' when the edited file is has potential forward compitibility
  issues.

Part of #109151 (PR !110109).
2023-07-27 16:21:38 +02:00
Campbell Barton cc892efcd4 Cleanup: use snake case, especially for structs that define callbacks
Use snake case for ShaderFxTypeInfo, ModifierTypeInfo,
GpencilModifierTypeInfo & bConstraintTypeInfo.
2023-07-27 12:21:06 +10:00
Ray molenkamp 4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Campbell Barton c6725b935c Fix #109720: load_post can't be used to initialize the driver namespace
Regression in [0] changed the order of execution for the load_post
handler which previously (in 3.5x) ran before driver evaluation.

Calling either load_post/load_post_fail handlers after loading was
changed intentionally to simplify the code-path for calling handlers
however it meant the handler couldn't be used to setup drivers,
so restore the original logic.

[0]: 46be42f6b1
2023-07-25 15:42:36 +10:00
Campbell Barton 5107fb6625 Cleanup: quiet ASAN warning initializing eWM_CapabilitiesFlag to -1
ASAN warns about this since moving wm_window.c to C++,
add an initialized flag instead of using an invalid value to
represent an uninitialized state.
2023-07-24 12:41:09 +10:00
Campbell Barton a82836b6c2 Cleanup: replace typdef with 'using'
Apply modernize-use-using with edits (as it strips out useful info).
2023-07-24 11:04:19 +10:00
Campbell Barton b8ea968929 Cleanup: simplify struct & enum declarations for C++ 2023-07-24 10:13:31 +10:00
Campbell Barton 3a3de9b674 Cleanup: spelling in comments 2023-07-22 11:46:41 +10:00
Campbell Barton 302887c619 Cleanup: use boolean literals in source/
Apply clang-tidy modernize-use-bool-literals to source/.
2023-07-22 11:43:01 +10:00
Ray molenkamp 19422044ed Cleanup: CMake: Modernize bf_bmesh dependencies
Pretty straightforward

- Remove any bmesh paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110363
2023-07-22 02:05:21 +02:00
Ray Molenkamp a670b53abe Cleanup: CMake: Modernize bf_blenfont dependencies
Pretty straightforward

- Remove any blenfont paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110351
2023-07-21 19:13:37 +02:00
Ray Molenkamp 0f541db97c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any clog paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110350
2023-07-21 18:37:30 +02:00
Ray molenkamp be516e8c81 Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward:

- Remove any blentranslation paths from INC
- Add a dependency though LIB when needed

Slightly different than usual:

blentranslation still had a dependency on imbuf, from a time long
gone, cleaned that up since I was in the area

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110324
2023-07-21 16:22:10 +02:00
Campbell Barton 495a198393 Cleanup: use C++ system headers 2023-07-21 16:07:33 +10:00
Campbell Barton b29a4cdcfc Cleanup: various non-functional changes for C++ (python, windowmanager)
- Remove redundant void, struct.
- Use function style casts.
2023-07-21 10:59:54 +10:00
Ray molenkamp 3e88a2f44c Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any depsgraph paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110317
2023-07-20 22:13:00 +02:00
Jacques Lucke f07a112cb5 WM: move to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110292
2023-07-20 22:12:29 +02:00
Ray molenkamp 4e64b772f5 Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any windowmanager paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109984
2023-07-20 18:52:52 +02:00
Campbell Barton d86e2b63a6 Cleanup: remove TIMERF define (set a define _TIMER_MAX) 2023-07-21 00:13:13 +10:00
Campbell Barton 486086d349 Fix logical error in window creation with an empty space
Resolve a crash in !104831, which exposed an error in window creation
with an empty space type.

Creating a new window with an empty space type would do the following:

- Create a new screen with a single empty area.
- Refresh the screen,
  - Initialize the area.
    - Convert the empty area into a 3D viewport.
    - Run SpaceType::init()

This doesn't cause any problems at the moment because `view3d_init`
isn't doing anything however !104831 accesses the View3D from
`area->spacedata.first` causing SCREEN_OT_area_dupli to crash.

Resolve by supporting an area setup callback for WM_window_open
so the area-data can be set before it's initialized.

The issue remains where an unknown/empty ScrArea::spacetype results in
a crash although it seems unlikely users run into this in practice.
Whatever the case, that can be resolved separately.
2023-07-20 17:06:13 +10:00
Campbell Barton ecd729433d Cleanup: pass rcti to WM_window_open & ED_screen_temp_space_open
Pass a single rcti instead of 4 int arguments.
2023-07-20 16:55:24 +10:00
Campbell Barton 246292f486 Cleanup: various non-functional changes (mainly for C++)
- Remove redundant void, struct.
- Remove redundant parenthesis.
- Use STR_ELEM(..)
- Use function style casts.
2023-07-20 11:55:34 +10:00
Sergey Sharybin ae543c01a4 Refactor: Make viewport to use ViewRender
This change replaces a bare RenderEngine owned by a viewport
with a VeiwRender. This unlocks a possibility of accessing
RenderResult for viewport renders. Currently it is not done,
but it will be needed for an upcoming work towards unification
of the render passes handling.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/110244
2023-07-19 12:12:09 +02:00
Philipp Oeser c275f4219f Fix #110204: Anim Player draws non-uniformly scaled when resizing window
Caused by fd3e44492e.

Images were drawn filling the entire window, now use available size/
offset inside the window and pass these as `rctf` to
`draw_display_buffer`.

Should be good for 3.6/3.3 LTS

Pull Request: https://projects.blender.org/blender/blender/pulls/110206
2023-07-18 14:10:11 +02:00
crabs 48e8d8f910 Fix #109875: The tooltip in "File > New > General" is misleading
File > New> General tooltip is misleading, as explained in issue #109875
Changes the tooltip from the current "Open the default file (doesn't save the current file)" to simply "Open the default file".

It could be argued that the note is still valid for when people have Preferences > Save & Load > Save Prompt disabled, but we don't have a similar note in any of the other cases that open a different file.

Pull Request: https://projects.blender.org/blender/blender/pulls/110086
2023-07-17 11:52:31 +02:00
Campbell Barton d82322f616 Cleanup: spelling in comments 2023-07-16 15:50:02 +10:00
Campbell Barton cf95198491 Cleanup: remove static WindowStateGlobal struct in wm_playanim.c
Make this part of the PlayState.
2023-07-15 15:54:45 +10:00
Campbell Barton e6609ecfda Cleanup: use a const ImBuf for UI image references 2023-07-13 10:10:44 +10:00
Harley Acheson b7a119c785 Fix #40059: Use Modifier Keys Between Windows on Win32
Use modifier keys that are pressed before activating a new window.
Allows call of `wm_window_update_eventstate_modifiers` on
`GHOST_kEventWindowActivate` by using `GetAsyncKeyState` instead of
`GetKeyState` in GHOST_SystemWin32::getModifierKeys, which retrieves
actual hardware state.

Pull Request: https://projects.blender.org/blender/blender/pulls/110020
2023-07-12 20:01:37 +02:00
Bastien Montagne 6f5f1737f3 Revert "LibOverride: Work around reset of system liboverrides on save."
This reverts commit 457b26aba3.

This change was not actually needed, actual issue was caused by
784d09a87c, and has been fixed by 1c0ffa1e18.
2023-07-12 17:26:13 +02:00
Jacques Lucke 3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Ray molenkamp 07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Bastien Montagne 457b26aba3 LibOverride: Work around reset of system liboverrides on save.
Now that liboverride process on save (the diffing + pruning unused
override operations + reset of non-overridable changes) works better. it
leads to a bad side-effect: all system overrides data indirectly
modified through animation or drivers get reset.

Since in current system e.g. most objects of a rigged asset are system
overrides, but their transform is modified by bones animation, this
leads to entire overrides of assets being reset to their linked state
until next depsgraph evaluation.

While this is the expected and correct behavior in absolute, this is
very bad from a user experience PoV.

This commit address the issue by simply re-running a 'frame change'
despgraph update, to ensure all drivers, animations etc. are properly
re-applied after liboverride diffing cleanup & reset.
2023-07-11 15:30:30 +02:00
Julian Eisel d31a0e8393 GPv3: Drag & drop reordering & inserting in the layer tree UI
Note: Change applies to Grease Pencil 3.0 only (experimental feature).

Enables use of drag & drop to reorder grease pencil layers through the layer
tree UI, as well as inserting layers into groups. This is an intuitive and
often requested method of managing such data-structures. Visual feedback should
be improved still, and the gap between items be removed, to reduce flickering
while dragging. These are general improvements for tree views however which
should be done separately.

There is no support yet for dragging layer groups, this requires further
changes in the internal grease pencil APIs.

#109825 introduced the necessary drag & drop support for tree views, #109824
prepared the internal grease pencil API for it.

Pull Request: https://projects.blender.org/blender/blender/pulls/109826
2023-07-11 15:05:17 +02:00
Clément Foucault 11e2ca4b70 GPU: Fix compilation warnings
Warnings caused by 1978b4fc92
2023-07-11 11:08:06 +02:00
Clément Foucault 1978b4fc92 GHOST: Replace WITH_OPENGL build option
Replaces it by WITH_OPENGL_BACKEND and cleanup its usage.
Limits visibility of opengl enums and cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/109947
2023-07-11 09:17:31 +02:00
Campbell Barton 4333051f4d WM: pass the window manager & window to WM_report_banner_show
Avoid potential problems when the active window is known but not
assigned to `wm->winactive`, where the first window would be used
as a fallback. Instead, take a window argument, a fallback is still
used as a last resort (when NULL).
2023-07-11 14:42:24 +10:00
Campbell Barton 36b2291610 Cleanup: spelling in comments 2023-07-11 14:40:47 +10:00
Campbell Barton 1ec1e783cc Cleanup: consistent naming for wmTimer API
Word ordering for wmTimer API wasn't consistent.

- Use "WM_event_timer_" / "WM_event_timers_" prefix.
- Rename "wm_window_timer" to "wm_window_timers_process"
  because it wasn't clear what the function did from its name.
- Rename "wm_window_process_events" to "wm_window_events_process"
  for consistency with "wm_window_timers_process".
2023-07-11 13:16:04 +10:00
Campbell Barton 6be0c90eab Fix #109953: Timers without an associated window leak memory on exit
Thanks to @mod_moder & @Harley for their investigation, see !109603.
2023-07-11 12:52:34 +10:00
Campbell Barton 8a73c36643 Fix #109952: Unknown engine warning only shown when loading from a popup
Displaying the warning on file load depended on `wm->winactive`
being set, and didn't work when loading a file from the file-open
window or when loading files using a command-line argument.

Resolve using the first window as a fallback.
This happens to resolve #109770, although not freeing timers on exit
is likely to be an issue under other circumstances.
2023-07-11 12:21:04 +10:00
Ray Molenkamp 04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp 57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Bastien Montagne fa29d28d73 Fix #109889: Trying to append/link from the current file does give proper error message.
Logic in FileBrowser and/or `BKE_blendfile_library_path_explode`
probably changed at some point, and the generic 'invalid filetype' error
message was reached before the path is compared to current blendfile path.
2023-07-10 15:58:36 +02:00
Ray Molenkamp 7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Campbell Barton 0b5eb86e2c Cleanup: check the result of BLI_findindex against -1 instead of < 0
There is only one error value, prefer a specific check.
2023-07-10 12:37:44 +10:00
Campbell Barton 6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Pratik Borhade b14435fd93 GPv3: Missing default tool for paint mode
This broke after introduction of new grease pencil
paint mode 3d99d05f00
Entry in `toolsystem_default_tool` was missing

Pull Request: https://projects.blender.org/blender/blender/pulls/109722
2023-07-05 12:03:51 +02:00
Campbell Barton 28c3a0a980 WM: quiet missing incremental properly warning for "Save As"
The incremental property doesn't exist for "Save As" so don't check
for it.
2023-07-05 14:30:17 +10:00
Campbell Barton 785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Hans Goudey 1b4b90f5f7 Cleanup: Remove unnecessary C API for asset representation
Now that almost all code is in C++, this is unnecessary and
just confuses things with multiple entry points to the same code.

Pull Request: https://projects.blender.org/blender/blender/pulls/109661
2023-07-04 14:46:19 +02:00
Falk David 3d99d05f00 GPv3: Add separate paint mode
This patch adds a separate paint mode for Grease Pencil 3.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/109453
2023-07-03 16:34:30 +02:00
Falk David de95539ced Cleanup: Rename grease pencil modes to legacy
Renames `OB_MODE_EDIT_GPENCIL`, `OB_MODE_PAINT_GPENCIL`,  `OB_MODE_SCULPT_GPENCIL`,  `OB_MODE_WEIGHT_GPENCIL`, `OB_MODE_VERTEX_GPENCIL, and the context modes` to `*_LEGACY`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109648
2023-07-03 15:15:54 +02:00
Campbell Barton 6fbe467021 Cleanup: replace BLI_dynstr with a call to BLI_vsprintfN 2023-07-03 14:15:07 +10:00
Campbell Barton 4f3e2ee857 Refactor: split the animation players image buffer display context
Image buffer display in the animation player was difficult to reason
about because it could potentially access the entire play-state on load
(frame-step, modifier keys... etc) even though these are are only
intended to be used interactively.

Add playanim_toscreen_ex which is called by both
playanim_toscreen & playanim_toscreen_on_load which doesn't use the
PlayState struct.
2023-07-02 19:54:27 +10:00
Campbell Barton f7d6b7973a Cleanup: minor C++ changes (use nullptr, correct parameter names) 2023-07-02 19:54:27 +10:00
Campbell Barton 69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Campbell Barton 345d1a4b44 Cleanup: simplify struct declarations in C++
Replace `typedef struct X {} X;` with `struct X {};`

In some cases the first and last name didn't match although this
is rarely useful, even a typo in some cases, e.g. TrachPathPoint.
2023-07-02 19:54:26 +10:00
Bastien Montagne f3c131adfe Fix #109422: Assertion triggered when opening a new file and "Load UI" is disabled in settings.
Small inconsistency leftover from ebb5643e59, 32bbfbb06e and 7ef8389dad
commits.

Weirdly enough that was not a problem on Linux X11, but did cause
issues at leaast on Windows and Linux Wayland.
2023-06-30 10:26:47 +02:00
Hans Goudey f89b32382a Point Cloud: Add initial edit mode support
Similar to 5f16e24cc9, this adds support for edit mode
to the point cloud object type, which is currently hidden behind an
experimental option. No interaction is possible yet, for now this
can be used as a testing for a node-group-operator-only mode.
2023-06-28 12:52:55 -04:00
Campbell Barton 3ab8e9b144 PlayAnim: only load the built-in mono-space font
There is no need to load all fonts on startup when only the mono-spaced
font is used.
2023-06-28 13:46:26 +10:00
Campbell Barton d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Campbell Barton 0fdc84fcdd Cleanup: remove incorrect/unhelpful comments 2023-06-28 12:17:06 +10:00
Damien Picard 9b4749e7c7 UI: replace "x" with multiplication sign when displaying calculations
The multiplication sign looks like an "x" but should be used in its
stead to display calculations and dimensions such as "1920x1080". It
is supported in many fonts including DejaVu Sans, the font currently
used for the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/106388
2023-06-27 21:03:05 +02:00
Campbell Barton 562aca75d3 Cleanup: split anim/sequence loading into two functions
Also simplify image sequence reading loop.
2023-06-27 10:42:18 +10:00
Campbell Barton c761f5b6fb PlayAnim: scale the font by the window DPI 2023-06-27 10:08:17 +10:00
Campbell Barton 4bbbf9007b Refactor: split out buffer loading for the animation player
- Simplify freeing resources on error.
- Correct check for failure to access the file size.
- Print the `errno` on failure.
- Use logging.
2023-06-27 10:06:34 +10:00
Julian Eisel adb370e6ba UI: Use new C++ button apply function
No user visible changes expected.

This function was added in 86b2cf4574 as a more type safe and more
convenient way of setting button callbacks. So use it for simple cases.
2023-06-26 16:56:05 +02:00
Harley Acheson 4a80d0b6d5 Refactor: UTF-8 Character Defines
Use defined UTF-8 Universal character names in place of byte escape
sequences and literals.

Pull Request: https://projects.blender.org/blender/blender/pulls/109163
2023-06-26 06:05:18 +02:00
Campbell Barton b9bf639ba4 BLI_string: remove BLI_strcpy_rlen
Avoid BLI_strcpy_rlen use as this has the same problems as strcpy
(it just returned the length which is useful at times).
Use memcpy instead when the size is calculated immediately beforehand.

Other uses of have been replaced by BLI_string_join_array that prevents
buffer overruns by taking the destination buffer length.
2023-06-24 18:49:29 +10:00
Brecht Van Lommel 711fb3e386 Realtime Compositor: cache render compositor for repeated executions
This is cached in Render, and gets cleared along with render pass GPU
textures when there is no editor open using it, or a new final render is
started.

The context and texture pool are cached. But the evaluator is re-created
every time as this only runs on compositing node changes, which require
recreating it anyway (unlike the viewport where e.g. camera navigation
does not need a new evaluator).

Pull Request: https://projects.blender.org/blender/blender/pulls/108909
2023-06-23 20:13:21 +02:00
Sergey Sharybin d8cc8fcf7f Refactor: Move color space information to ImBuf buffers
Before this change the ImBuf struct had dedicated fields for the
buffer data. Now the color space is stored inside of the struct
which wraps around the buffer information.

This only changes the field placement, without changing the way
it is handled. In the future one might imagine that operations
like stealing buffer data should null-ify the buffer colorspace
pointer. Such changes would need to have more accurate thinking
before implementation.

Should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109291
2023-06-23 15:55:42 +02:00
Falk David bb041b3f48 Fix #109207: Can't select in gpencil edit mode
This was due to a wrong mapping of tools in the toolbar.

The fix makes sure that the correct selection tools are used for the
old grease pencil objects.
In order to accomplish this properly, the new grease pencil objects
use their own edit mode context.
This way the two objects are cleanly seperated.
2023-06-21 16:49:18 +02:00
Campbell Barton 8bcad285de Cleanup: remove strcpy usage 2023-06-19 20:40:49 +10:00
Hans Goudey 0b71a1f054 Cleanup: Move UI RNA files to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/109090
2023-06-18 01:39:21 +02:00
Hans Goudey 7d935f94f3 Cleanup: Grammar: it's vs its 2023-06-13 14:51:49 -04:00
Brecht Van Lommel a88114b35e Realtime Compositor: cache render pass GPU textures
* Store per RenderPass in RenderResult.
* Caches are cleared when starting rendering, to make more memory available
  to GPU rendering.
* Caches are cleared on UI changes, when no compositing node editor and no
  image editor with a render result or viewer node image is visible.
* Store 3 channel RGB passes as such, and set alpha 1 in shader.

This is an intermediate step before implementing GPU backed ImBuf, to
improve performance and figure out cache eviction.

Pull Request: https://projects.blender.org/blender/blender/pulls/108818
2023-06-12 19:49:18 +02:00
Julian Eisel e5dd515da8 Cleanup: Remove unnecessary asset handle forward declaration 2023-06-09 15:19:41 +02:00
Julian Eisel 92ff750bbf Refactor: Get rid of asset handle for drag & drop
`AssetHandle` is meant as temporary design and should be replaced by
`AssetRepresentation`. This moves us another step closer to that.

Rather than taking data from the volatile asset handle and storing that
in the drag data, store the (more persistent) asset representation there
and access data from it where needed.
2023-06-09 15:19:41 +02:00