45 Commits

Author SHA1 Message Date
Campbell Barton
7a249222be Cleanup: tweak multi-line parenthesis for Python scripts
Reduce right shift, moving closing parenthesis onto own line
for clarity & reducing diff noise in some cases.

Ref !147857
2025-10-12 03:31:31 +00:00
Nika Kutsniashvili
efa8d942b8 Refactor: Remove grid and compact UI list layout in Python scripts
The grid layout type for UI list is planned for removal in 5.0, see
blender/blender#110461.

In previous UI meetings, we talked about deprecating the Grid mode of
the UI list, which is not actually accessible in UI and was never used.
Nowadays, there is a new grid view that can be exposed in the API in
the future.

Initially, I wanted to remove references to layout_type in UI templates
in the text editor, because a lot of add-on developers on the
extensions platform base their lists on that code, and a lot of them
are therefore including soon to be deprecated code in their add-ons,
which I want to avoid in the future. But I thought we might as well
remove it from our python scripts as well, since it's just basically
redundant code that doesn't do anything. And also because many add-on
developers use bundled python scripts for references as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/138395
2025-06-18 13:45:06 +02:00
Nika Kutsniashvili
5dd53fdb29 Fix: Avoid relative imports in UI code
Relative imports are intentionally avoided in UI code (`scripts/startup/bl_ui`) because it makes it impossible to run individual files in isolation.

Common workflow for making mock-ups and quick UI edits is to load the UI file in Blender's text editor with "Edit Source" operator, make changes, and run the script to see the changes. But in the current version it's impossible because files include relative imports, which don't allow Python to run scripts individually.

Pull Request: https://projects.blender.org/blender/blender/pulls/138246
2025-05-04 13:26:03 +02:00
Pratik Borhade
3aea40b8cd Anim: Bone collection UI changes
Allow assign/select operators to execute when armature tab is pinned.
For assign operators, pinned armature should be active in 3D view
because we cannot assign bones of one armature to the bone collection of
different armature. Added extra condition in poll function to control
the above case.
For select operators, use `ED_armature_context` to obtain pinned Armature.
These operators are now hidden in object modes.

Pull Request: https://projects.blender.org/blender/blender/pulls/137587
2025-05-02 11:52:33 +02:00
Campbell Barton
be0c9174aa Cleanup: argument wrapping for Python scripts
- Wrap the closing parenthesis onto it's own line
  which makes assignments to the return value
  read better.
- Reduce right-shift with multi-line function calls.
2025-01-14 12:53:32 +11:00
Campbell Barton
c7fb01ff91 Cleanup: use static sets for "contains" checks 2025-01-03 14:47:57 +11:00
Christoph Lendenfeld
7e1db7de19 Fix #129416: Wrong Bone Selection Set used for selection
The issue was that when using a specific selection set,
the property `selection_set_index` is set to a specific index.
That index would persist to the next call of the operator
when trying to call it from the selection set list. The fix is to explicitly reset the
index to -1 when calling the operator from the list, because
that means the active selection set will be used.

Pull Request: https://projects.blender.org/blender/blender/pulls/131675
2024-12-12 11:19:55 +01:00
Campbell Barton
a7bc3e3418 Cleanup: quiet Python linter warnings 2024-12-11 11:26:24 +11:00
Campbell Barton
49242a6b68 Cleanup: remove unused "COMPAT_ENGINES" in panels
Their existence was misleading making it seem as if would hidden unless
they were listed here.
2024-10-30 12:05:25 +11:00
Campbell Barton
c3b067dc80 Cleanup: single/double quote use in scripts 2024-10-16 14:45:08 +11:00
Campbell Barton
0b69e1d6f5 Cleanup: double quotes for strings, replace f-string with str.format 2024-10-02 15:46:11 +10:00
Sybren A. Stüvel
383c3c8253 Anim: Add Action+Slot selectors to Property editor tabs
Add Action + Action Slot selectors to various Property Editor tabs.
This follows the pattern established in
f917b60036.

Support for `CacheFile` data-blocks is not included here. That needs
some discussion, as currently its interface is part of the Modifier
stack (and thus implemented in C++ and not Python, and using a
different layout).

Since this PR is about adding to the Property Editor, some data-blocks
that have no representation there are thus excluded (like `Mask`).
Even when they could actually use an Action+Slot selector somewhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/127074
2024-09-05 12:11:35 +02:00
Leon Schittek
d30d8b4bfa UI: Add padding to items in ui lists and tree views
Add a utility function to add horizontal padding to the left and right
of items in UI lists and tree views to make them more consistent with
other buttons like menu entries.

Pull Request: https://projects.blender.org/blender/blender/pulls/125498
2024-07-29 23:52:38 +02:00
Sybren A. Stüvel
9d3dc77e05 Anim: move Bone Selection Sets add-on into Blender
The functionality of the Bone Selection Sets add-on is now integrated
into Blender itself. Rigify has been updated to no longer check for the
add-on, but just assume that the functionality is available.

The keymap is still the same, and so are all the class names. This
ensures that there are no conflicts when people still have the old
add-on enabled somehow. And there is versioning code to remove the
'add-on enabled' state so that Blender won't complain it cannot find it
any more.

Compared to the add-on, the following changes are made:

- The 'bone' icon has been removed from the list of available selection
  sets. It was the same for each entry anyway, and thus didn't provide
  any information.
- The code has been split up into multiple files, with the UI elements
  in `scripts/startup/bl_ui/properties_data_armature.py` and the
  operators in `scripts/startup/bl_operators/bone_selection_sets.py`.
- Helper functions and classes are prefixed with `_` to indicate that
  they are not part of any public API.
- The `Operator` helper subclasses have been transformed to mix-in
  classes. This way the only subclasses of `Operator` are the actual
  operators.
- Comments & descriptions have been updated for clarity & consistency.

This commit contains code by the following authors, ordered by number of
commits in the original add-on repository, highest first:

Co-Authored By: Ines Almeida <britalmeida@gmail.com>
Co-Authored By: Sybren A. Stüvel <sybren@stuvel.eu>
Co-Authored By: Campbell Barton <ideasman42@gmail.com>
Co-Authored By: meta-androcto <meta.androcto1@gmail.com>
Co-Authored By: Demeter Dzadik <Mets>
Co-Authored By: lijenstina <lijenstina@gmail.com>
Co-Authored By: Brecht Van Lommel <brechtvanlommel@gmail.com>
Co-Authored By: Aaron Carlisle <carlisle.b3d@gmail.com>

For the full history see the original add-on at:
https://projects.blender.org/blender/blender-addons/commits/branch/main/bone_selection_sets.py

Reviewed On: https://projects.blender.org/blender/blender/pulls/124343
2024-07-08 16:28:42 +02:00
Hans Goudey
86bde1b58b Cleanup: Make format 2024-04-10 08:01:58 -04:00
Pratik Borhade
5bc033b4d7 UI: Add Rename operator in bone collection context menu
Operator to rename tree view item already exists: `UI_OT_view_item_rename`
Add this in context menu as discussed in !120003

Pull Request: https://projects.blender.org/blender/blender/pulls/120086
2024-04-10 13:09:32 +02:00
Jun Mizutani
378d37ed3d Fix #119812: 'Add Child Collection' adds a brother bone collection
Change label from "Add Child Collection" to "Add Bone Collection", as the
newly added collection becomes a sibling, not a child, of the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/119845
2024-03-25 09:25:24 +01:00
Campbell Barton
d07d6f1c10 Cleanup: un-wrap lines that fit within 120 width for Python scripts 2024-03-15 10:04:03 +11:00
Pablo Vazquez
0e706c9699 UI: Move Bone Collection specials menu up
So it's consistent with other lists where the order of buttons is:

1. Add/Remove
2. Specials menu
3. Move up/down
2024-02-06 14:26:43 +01:00
Sybren A. Stüvel
848f83e210 Anim: bone collections, add 'un-solo all' operator
Add an operator that clears the 'solo' flag from all bone collections.
2024-01-26 11:09:06 +01:00
Sybren A. Stüvel
f623c8f7bc Anim: remove 'Solo Visibility' bone collections operator
Remove the 'Solo Visibility' operator that singles out a bone collection.
It was a workaround for not having a true 'solo' flag, which is there
now.
2024-01-26 11:05:00 +01:00
Sybren A. Stüvel
a7354fb2af Anim: add operator to remove unused bone collections
Add an operator to remove all unused bone collections. This is added to
the bone collections "specials" menu and the tree view context menu.

A bone collection is considered "unused" when it has no bones assigned,
and also no child collection that has bones assigned.
2024-01-22 13:34:25 +01:00
Sybren A. Stüvel
6b8c64fc69 Anim: create new bone collections as next sibling of active one
Bone collections created via the `bpy.ops.armature.collection_new`
operator now always become the next sibling of the active bone
collection. If there is no active one, the new one is added at the end
of the list as root.

This removes the `.parent_index` property of the operator, as it is now
always created relative to the active bone collection.
2024-01-22 10:34:30 +01:00
Sybren A. Stüvel
5b8207fa97 Anim: bone collection context menu, prevent operations on linked
Prevent operating on linked bone collections via the tree view context
menu.
2024-01-09 12:50:48 +01:00
Sybren A. Stüvel
129fb2eab8 Anim: make bone collections hierarchical
Make it possible to nest bone collections. The data structure on the
armature is still a flat array. It is organised as follows:

- Sibling collections (i.e. ones with the same parent) are stored
  sequentially in the array.
- Each bone collection keep track of the number of children, and the
  index of the first child.
- Root collections (i.e. ones without parent) are stored as the first
  elements in the array.
- The number of root collections is stored on the Armature.

This commit also contains the following:

- Replaced the flat UIList of bone collections with a tree view.
- Updated the M/Shift+M operators (move/assign to collection) to work
  with hierarchical bone collections.
- Updated RNA interface to expose only root collections at
  `armature.collections`. All collections are available on
  `armature.collections.all`, and children at `bonecollection.children`.
- Library override support. Only new roots + their subtrees can be added
  via overrides.

See https://projects.blender.org/blender/blender/issues/115934

Co-authored with @nathanvegdahl and @nrupsis.

Pull Request: https://projects.blender.org/blender/blender/pulls/115945
2023-12-28 18:14:55 +01:00
Sybren A. Stüvel
007cea4653 Anim: rename the 'Skeleton' panel to 'Pose'
In the Armature properties, rename the 'Skeleton' panel to 'Pose'. This
panel used to house the armature layers, but they have been transformed
into bone collections, which have their own panel. Also the term 'skeleton'
is not used in Blender, so having that as title here felt out of place.

There are some ideas to introduce different 'poses', to disconnect the
mesh binding pose from the animation reference pose. This rename sets
things up for exposing such functionality.
2023-09-28 16:32:02 +02:00
Sybren A. Stüvel
f2bda4ab3a Anim: move 'solo bone collection' operator to menu and add 'show all'
Move operators that act on the active bone collection to a 'specials'
context menu, just like other UILists.

The menu now contains:
- Solo the active bone collection (i.e. make it visible and hide others).
- Show all bone collections.
2023-09-28 14:38:54 +02:00
Sybren A. Stüvel
2d04919a82 Anim: Add operator to 'solo' the active bone collection
With armature layers it was possible to, with one click, show a single
layer and hide all the others. This is now possible with bone collections
as well.

For that I added a new operator `armature.bone_collection_solo_visibility`,
with a button next to the list of bone collections. The icon is
`SOLO_ON`, which is also used in the NLA.
2023-09-28 14:20:24 +02:00
Sybren A. Stüvel
ea360ffc12 Anim: hide bone collection customprop editor on overrides
Blender's generic custom property panel doesn't support operating on
overridden data yet, so it's better to just hide the panel altogether.
Before this commit, the 'Custom Properties' panel was shown but empty.
2023-09-15 14:54:04 +02:00
Sybren A. Stüvel
347ffd6262 Anim: add support for renaming bone collections added by overrides
Add a flag `BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL` that's only set on
bone collections that have been overridden locally.
2023-09-15 14:54:03 +02:00
Sybren A. Stüvel
f78ed7b900 Anim: rename Armature show_group_colors to show_bone_colors
There are no more bone groups, and the colors have been moved to the
bones themselves (042c5347f4). Now the
armature property that controls whether they're shown or not also refers
to 'bone colors' instead of 'group colors'.
2023-09-08 12:12:39 +02:00
Sybren A. Stüvel
a6bb302f9f Anim: show Bone Collections panel when armature is pinned
Show the Bone Collections panel when the Armature is pinned in the
properties editor.
2023-09-07 17:09:17 +02:00
Sybren A. Stüvel
e6bb1374f9 Anim: add bone collection custom properties sub-panel
Add a 'Custom Properties' sub-panel to the Bone Collections panel.

Custom properties for bone collections were introduced in 9eee076a29,
this just adds the GUI.

Ref: #108941
2023-09-07 16:52:08 +02:00
Miguel Pozo
2aa7961e6f Workbench: Remove old implementation 2023-09-06 15:54:48 +02:00
Sybren A. Stüvel
998136f7a7 Anim: replace Bone Groups & Armature Layers with Bone Collections
Armature layers (the 32 little dots) and bone groups are replaced with
Bone Collections:

- Bone collections are stored on the armature, and have a name that is
  unique within that armature.
- An armature can have an arbitrary number of bone collections (instead
  of the fixed 32 layers).
- Bones can be assigned to zero or more bone collections.
- Bone collections have a visibility setting, just like objects in scene
  collections.
- When a bone is in at least one collection, and all its collections in
  are hidden, the bone is hidden. In other cases (in any visible
  collection, or in no collection at all), the bone visibility is
  determined by its own 'hidden' flag.
- For now, bone collections cannot be nested; they are a flat list just
  like bone groups were. Nestability of bone collections is intended to
  be implemented in a later 4.x release.
- Since bone collections are defined on the armature, they can be used
  from both pose mode and edit mode.

Versioning converts bone groups and armature layers to new bone
collections. Layers that do not contain any bones are skipped. The old
data structures remain in DNA and are unaltered, for limited forward
compatibility. That way at least a save with Blender 4.0 will not
immediately erase the bone group and armature layers and their bone
assignments.

Shortcuts:

- M/Shift+M in pose/edit mode: move to collection (M) and add to
  collection (shift+M). This works similar to the M/Shift+M menus for
  objects & scene collections.
- Ctrl+G in pose mode shows a port of the old 'bone groups' menu. This
  is likely to be removed in the near future, as the functionality
  overlaps with the M/Shift+M menus.

This is the first commit of a series; the bone collections feature will
be improved before the Blender 4.0 release. See #108941 for more info.

Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +02:00
Sybren A. Stüvel
042c5347f4 Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:

- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
  `ob.pose.bones['bone_name'].color`).

When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.

Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.

The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.

This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.

Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-29 14:31:18 +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
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Campbell Barton
a85ad2d0eb Cleanup: remove f-string use, single quote enums 2023-05-15 20:58:00 +10:00
Sybren A. Stüvel
51c2a0f816 Fix #104606: iTaSC solver moves root bone to origin and imobilizes it
Add a new flag that determines whether root bones (i.e. bones without a
parent) should be translated to the armature object's origin. This can
be found in the Armature's IK properties panel.

By default this flag is disabled, so new rigs will not see this 'locking
to the origin' behaviour. Versioning code ensures that the flag is
enabled on older files, to preserve the behaviour of existing rigs.

This also bumps the Blender subversion and at the same time fixes an
incorrect bump in ee08b2ddff (where the
'minimum compatible version' was updated instead of the current Blender
version).

Pull request: https://projects.blender.org/blender/blender/pulls/107869
2023-05-15 10:46:26 +02:00
Campbell Barton
2bb4abdc27 Cleanup: assign variables & use 'match' to avoid redundant lookups
Also use more verbose names for RNA subtype enum variables.
2023-04-28 16:56:34 +10:00
Sybren A. Stüvel
45c1deac4f Bone relation lines: optionally draw between bone heads
Add control over how bone relation lines are drawn. Instead of always
drawing from the head of the child to the tail of the parent, give users
a choice for the parent side of the line. This can now be toggled
between the head and the tail of the bone, where the tail is Blender's
original behaviour and is retained as default value.

Pull request: https://projects.blender.org/blender/blender/pulls/105427
2023-03-21 15:16:13 +01:00
Campbell Barton
e1ab9e352c Cleanup: autopep8 2023-03-01 22:12:18 +11:00
Pablo Vazquez
cbb4f8a9ba UI: Add color selector to Bone Groups list
Expose the color selector on each item in the list, so it's easier to see
at a glance the Bone Groups color theme and change it.

Also avoids having color widgets grayed out when not in Custom Colors mode.

Pull Request #105036
2023-02-22 17:34:44 +01:00
Sergey Sharybin
03806d0b67 Re-design of submodules used in blender.git
This commit implements described in the #104573.

The goal is to fix the confusion of the submodule hashes change, which are not
ideal for any of the supported git-module configuration (they are either always
visible causing confusion, or silently staged and committed, also causing
confusion).

This commit replaces submodules with a checkout of addons and addons_contrib,
covered by the .gitignore, and locale and developer tools are moved to the
main repository.

This also changes the paths:
- /release/scripts are moved to the /scripts
- /source/tools are moved to the /tools
- /release/datafiles/locale is moved to /locale

This is done to avoid conflicts when using bisect, and also allow buildbot to
automatically "recover" wgen building older or newer branches/patches.

Running `make update` will initialize the local checkout to the changed
repository configuration.

Another aspect of the change is that the make update will support Github style
of remote organization (origin remote pointing to thy fork, upstream remote
pointing to the upstream blender/blender.git).

Pull Request #104755
2023-02-21 16:39:58 +01:00