Commit Graph

6985 Commits

Author SHA1 Message Date
Falk David
f2f0426980 GPv3: Refactor root_group to be a pointer in DNA
This turns the embedded group into a pointer.

Note: Older files will not load the grease pencil v3 object properly after this.
The objects will not have any layers in them.

Pull Request: https://projects.blender.org/blender/blender/pulls/110007
2023-07-13 18:24:19 +02:00
Julian Eisel
80cc0dfef2 Fix grid view sometimes dropping last row
As an important optimization, grid views skip items that are not in
view, and instead add empty space to the layout still has the right
dimensions (for scrolling). Calculations were off though, leading to the
last row being dropped when it had too few items to fill it completely.
2023-07-13 14:03:12 +02:00
Campbell Barton
e6609ecfda Cleanup: use a const ImBuf for UI image references 2023-07-13 10:10:44 +10:00
Campbell Barton
4e7ea8bf70 Cleanup: use const rect argument for immDrawPixelsTex functions 2023-07-13 10:09:16 +10:00
Pratik Borhade
861931101c Fix #109994: Layer unlinks from the list when drop location is same
For drag-drop, drag node is first unlinked from existing position then
linked above or below the drop layer.

When drag and drop layers are same, layer is unlinked from listbase and
further linking fails because layer is not found in the listbase.

Pull Request: https://projects.blender.org/blender/blender/pulls/110009
2023-07-12 17:12:23 +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
Jacques Lucke
19d4cafb12 Cleanup: move more editors code to c++
This moves the remaining `.c` files in the following `editors` folders to C++:
`physics`, `screen`, `sound`, `space_buttons`, `space_file`, `space_graph` and `space_image`.

One exception is `fsmenu.c` which has platform specific issues on macos and
windows. E.g. the `Carbon/Carbon.h` include also declares a `Collection` type that collides
with ours.

Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/109918
2023-07-12 13:43:00 +02:00
Harley Acheson
c6adafd8ef UI: add progress indicator variations & RNA API
Add pie and ring styles of progress indicators. Exposes progress bar to
the Python API and adds a "type" property to allow style variation.

This can be used for scripts & add-ons to show progress in the UI.

Ref !109882.

Co-authored-by: Campbell Barton <campbell@blender.org>
2023-07-12 14:00:39 +10:00
Campbell Barton
e63a77eeb8 Cleanup: rename uiButProgressbar to uiButProgress
Prepare for other types of progress to be added.
2023-07-12 13:31:46 +10:00
Jacques Lucke
3d73b71a97 Geometry Nodes: new Repeat Zone
This adds support for running a set of nodes repeatedly. The number
of iterations can be controlled dynamically as an input of the repeat
zone. The repeat zone can be added in via the search or from the
Add > Utilities menu.

The main use case is to replace long repetitive node chains with a more
flexible alternative. Technically, repeat zones can also be used for
many other use cases. However, due to their serial nature, performance
is very  sub-optimal when they are used to solve problems that could
be processed in parallel. Better solutions for such use cases will
be worked on separately.

Repeat zones are similar to simulation zones. The major difference is
that they have no concept of time and are always evaluated entirely in
the current frame, while in simulations only a single iteration is
evaluated per frame.

Stopping the repetition early using a dynamic condition is not yet
supported. "Break" functionality can be implemented manually using
Switch nodes in the  loop for now. It's likely that this functionality
will be built into the repeat zone in the future.
For now, things are kept more simple.

Remaining Todos after this first version:
* Improve socket inspection and viewer node support. Currently, only
  the first iteration is taken into account for socket inspection
  and the viewer.
* Make loop evaluation more lazy. Currently, the evaluation is eager,
  meaning that it evaluates some nodes even though their output may not
  be required.

Pull Request: https://projects.blender.org/blender/blender/pulls/109164
2023-07-11 22:36:10 +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
Hans Goudey
f3f05daf11 Cleanup: Remove unused "Simulation" data-block
This data-block was originally added in eb4e3bbe68.
However, that original plan wasn't fully implemented, with simulations
now integrated with geometry nodes and modifiers instead of a separate
data-block. We kept the data-block around anyway since we have the
loose plan of using a similar data-block to make global simulations
connected between multiple objects. But it may be a while before we
implement that, and in the meantime having this just causes confusion.
2023-07-11 10:53:15 -04:00
Julian Eisel
efbca8d660 Cleanup: Remove unnecessary tree view function override, add comment
`AbstractTreeViewItem::supports_collapsing()` returns true in the
default implementation, so no need to override that to do the same.
Notes the default behavior in a comment now.
2023-07-11 15:33:26 +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
Julian Eisel
4525527852 UI: Basic tree-view drag & drop reordering and inserting support
No user visible changes expected, these are just the internal API preparations.

Modifies the Drop API for views so that tree-views can choose to insert items
before, after and into other items.

Note: While there is support for drag-tooltips that can explain how an item
will be inserted, there is no drawing yet like in the Outliner, that indicates
if an item is inserted before, after or into. There is some work on that but
that can be done separately.

Changes:
- Removes `AbstractViewDropTarget` that was shared between tree- and
  grid-views, and adds `AbstractTreeViewDropTarget` and
  `AbstractGridViewDropTarget`. The tree-view needs specialized handling now,
  and although they could share some code still, it's not worth having another
  level of inheritance.
- Modifies the drop-target API to use `DragInfo` which contains more info about
  the dragging operation than just the `wmDrag`.
- Adds `determine_drop_location()` to the `DropTargetInterface` which drop
  targets can use to determine when dropping means inserting before, after or
  into.
- Store the block and region in the view. This is needed unfortunately but
  shouldn't be an issue since the tree view is recreated on redraws, together
  with the block.
- Various smaller tweaks and additions to views as needed.

TODO (outside scope of this change): Increase row height so there is no gap
between tree view items, but keep things visually the same otherwise. This
reduces flickering while dragging.

Pull Request: https://projects.blender.org/blender/blender/pulls/109825
2023-07-11 14:30:26 +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
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
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
Sergey Sharybin
d579ac2b3f Refactor: Use ImBuf to store passes in RenderResult
Doing so avoids having duplicated logic for working with pixel
data which is being passed throughout the render pipeline.

Notable changes:

- ImBug can now store GPU texture.
  This is not very finished part of the API, which will be
  worked further to support tiling for very-high-res images.

- Implicit sharing is removed from the image buffer, as it is
  no longer needed.

There should be no functional changes on user level with this
change.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109788
2023-07-10 16:33:32 +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
Julian Eisel
71273df2d5 UI: Draw hierarchy lines for tree-views
Hierarchy lines (like we also have in the Outliner) make it easier to
visually parse the hierarchy, and avoid confusion about nesting level.
Especially when some items have icons and/or collapse chevrons and some
not (thus different levels of visual indentation).
They were planned for #93582 and #107881, also see
https://code.blender.org/2023/05/the-next-big-step-grease-pencil-3-0/#layer-groups.

The drawing is implemented as a general tree-view feature, so all
tree-views with collapsable items (which excludes the spreadsheet
data-set tree view) will get them without further setup.
2023-07-06 17:09:32 +02: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
Julian Eisel
ed38ef31f7 UI: Fix view item context menu not using context from button
Needed for the asset shelf context menu to work, see #104831.

Ensures the view item button's context is passed on to the context menu.
Otherwise it cannot display operators relying on this context.
2023-07-03 15:55:34 +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
Julian Eisel
0d1f3f445a UI: Support page based scrolling in View2D
No user visible changes expected. The feature is not exposed yet.

For the asset shelf (#102879), design is to use a paginated scrolling
style. That means, that any scrolling will always snap to a multiple of
the page size (the size used when pressing the Page Up/Down keys).
Together with strict region size snapping (implemented in the asset
shelf patch, #104831), this gives a clean scrolling experience where
partially visible rows are avoided (impossible even).

Introduces:
- `View2D.flag` value `V2D_SNAP_TO_PAGESIZE_Y`, which will cause any
  scrolling to only use multiples of the page size.
- A custom page size via `View2D.page_size_y` for when the full region
  size is not the appropriate page size value.
- API function `UI_view2d_offset_y_snap_to_closest_page()` to enforce
  the snapping from outside View2D. The asset shelf uses this to keep
  strict scrolling over DPI changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109154
2023-07-03 15:15:18 +02: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
d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Falk David
eb856f6fbb GPv3: Build group hierarchy for layer tree UI
This commit implements building of the layer tree hierarchy in the
layer tree UI.
Layer Groups that contain layers are now collapsible and visibility as well
as locking can be toggled.
2023-06-27 15:48:07 +02:00
Falk David
bf4e9ffbd9 GPv3: Add rename function for layer groups
This adds core functions to rename layer groups while preserving
name uniqueness.
2023-06-27 15:48:07 +02: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
Julian Eisel
0b19ab2cde UI: Add type-safe C++ button apply function object
No user visible changes expected.

Rather than relying on a C-style function pointer with void pointer
arguments, allow storing a `std::function` object, which can hold
arbitrary data in a type safe way. This can be conveniently used with
lambdas for example.

This is not used yet, but will be with #104831 merged. Replacing the
existing C-style callback uses with this can be done separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/109016
2023-06-26 16:39:51 +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
82d9eb09db Cleanup: use term SIZE instead of LEN for defines for buffer sizes
Reserve "LEN" for lengths that don't include the null byte.
2023-06-26 10:09:57 +10:00
Campbell Barton
ec428c3f7f CMake: sort file lists, add missing header 2023-06-24 19:05:09 +10:00
Campbell Barton
b06afe575e UI: resolve inconsistency with modifier labels while assigning shortcuts
Reuse WM_keymap_item_to_string to ensure labels match
(would show Cmd on Linux, then refresh to OS once set).
2023-06-23 10:08:58 +10:00
Julian Eisel
b1f7c87b99 Cleanup: Use const for UI coordinate conversion functions 2023-06-22 20:30:46 +02:00
Falk David
a4ef0ac05a GPv3: Add hide and lock buttons to layer UI
This adds two buttons to the items for hiding and locking the layer.
2023-06-22 14:12:08 +02:00
Falk David
16e187778b Fix compiler warnings 2023-06-22 11:11:55 +02:00
Falk David
b3f3b41d09 GPv3: Initial Layer Tree UI
Adds a new UI template to view the current layer tree of the active Grease Pencil object.

This UI tree view implements the following features (for now):
 - Displaying all the layers with their names and highlighting the active layer.
 - Changing the active layer by clicking on an item.
 - Adding new layers (using a new operator).
 - Removing the active layer (using a new operator).
 - Renaming a layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/109197
2023-06-22 10:51:43 +02:00
Julian Eisel
167c5c6b53 Fix UI views not refreshing properly in popovers
No UI views are used inside popups in the main branch yet, #104831 does
this so this issue became apparent. For example tree-view items would
not change their collapsed state.

UI views require the block to be attached to a region when drawing, so
that the matching to previous versions of the tree works. Before this
commit the block was attached just after.

The `BLI_findindex()` check before attaching the block was already done
for other kinds of popups, so this is more in sync now.
2023-06-20 17:23:25 +02:00
Campbell Barton
cf29e011be Cleanup: remove all strcpy calls in source/blender/editors/
Replace with STRNCPY or BLI_strncpy, while many cases were safe,
translated source strings could cause buffer overflows, see: #108917.
2023-06-19 11:58:33 +10:00
Campbell Barton
fde76c8b4d Cleanup: prefer the term 'len' over 'size' for storing string lengths
The Python API uses the term size for string lengths for
PyUnicode_AsUTF8AndSize and related API's, causing Blender's return
arguments to use the term `size` too in some cases.

This is error prone since Blender includes space from the the null byte
when the term size is used (by convention).
2023-06-19 10:21:59 +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
Julian Eisel
79eebf8aad UI: Add assert for single active view item
No user visible changes expected.

Adds an assert to check that only one item returns true in its
`should_be_active()` method. This can help find some errors.
2023-06-16 14:08:20 +02:00
Julian Eisel
1d4fac0cda Fix tree-view item ignoring custom matches() method override
No user visible change expected (this isn't used in existing code yet).

Users of the tree-view API should be able to write their own `matches()`
method to compare tree-view elements after tree reconstruction. Part of
the tree-view matching process wouldn't use this though, and use the
`matches_single()` method instead, causing issues like multiple items
sharing the same state. This was initially done for an optimization
(the default `matches()` compares parents as well, which seems redundant
here), but it backfires and actually isn't needed. The default
`matches()` only compares the parents when `matches_single()` returns
true anyway, so the redundancy is really minor and not a performance
concern.
2023-06-16 12:37:32 +02:00
Julian Eisel
6868a9503f Fix UI view item without drag support still consuming drag event
UI view items that don't support dragging should pass on the mouse
event.
2023-06-16 11:56:22 +02:00
Julian Eisel
e76d2a241c Fix missing mouse hover highlight for UI view items in menus
The hover highlight is done with some special handling that wasn't
called for buttons in menus. There's actually no case where this happens
in the main branch but it's needed for #104831.
2023-06-16 11:49:04 +02:00
Julian Eisel
962fca47d9 UI: Draw tree-view hover highlight even when emboss is disabled
No user visible changes expected.

It makes sense to disable embossing for drawing the tree view (so it
doesn't have to be disabled for every item individually), but then the
mouse hover highlight should still work.
2023-06-16 11:42:11 +02:00