2025-07-01

This commit is contained in:
2026-03-17 14:30:01 -06:00
parent f9a22056dd
commit 62b5978595
4579 changed files with 1257472 additions and 0 deletions
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
@@ -0,0 +1,674 @@
After-Creation-Menu-Template GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -0,0 +1,279 @@
# Bone Widget
Video explanation:
[https://www.youtube.com/watch?v=6L3ejWUZ1tg](https://youtu.be/6L3ejWUZ1tg)
## Description:
Bone Widget is a blender add-on to assist with making custom bone shapes. It has an editable library of shapes that make it easy to apply to any rig.
It ships with many shapes pre-made but you can also add your own to the library to make rigging easier.
## Installation:
1. Download the zipped code here from Github. (Check in the release tab for the latest stable release)
2. In Blender, open Preferences->Addons->Install. Navigate to where you saved the zip file and click install.
3. Enable the Addon with the checkbox.
4. The UI will appear in the properties panel (n panel) in the 3d viewport.
## UI Panel
<img src="images/bone_widget_UI.png" alt="drawing" width="700"/>
### Preview Panel Checkbox:
This will show/hide the large widget preview panel. It's also possible to set your preferred option for this in the preferences. (The default is enabled)
### Preview Panel:
This is the large preview panel that displays the currently selected widget. Click on this panel to open the selection menu.
### Shape Drop Down:
This is the active shape from Bone Widget Library.
## BW Specials Menu:
![alt text](images/bone_widget_specials_menu.png)
### Add to Widget library
To add a mesh object to the library, select a mesh object and click this button.
Give the mesh object an appropriate name and then confirm. Your widget will be added to the library.
(User widgets are stored in a separate json file to the shapes that come with the addon.)
### Remove from Widget Library
This will remove the active shape from the library.
Select the shape you want to remove from the list. And click this. Boom, it is gone (forever!).
This will work on any widget in the list.
### Import/Export Widget Libray
It is possible to inport and export all the custom widgets that you have added to/from a zipped json file. This will let you more easily share them with another computer.
> [!CAUTION]
>
> A note on updating the addon:
>Version 2.1 is the first version to support importing/exporting. Versions prior to this have a slightly different structure that are not compatible with 2.1 onwards. If you already have widgets that you'd like to reuse, the easist way would be to open the rig file that uses them and then 'add to library' in the newer version.
>
>Also before you update to a version after 2.1, make sure you export your custom widgets so it's possible to import them easily. This is the easist way to keep your existing work for the moment.
### Add Custom Image to Widget
This function will let you assign an image from you hard drive to use as the widget preview.
## Creating a Widget:
### Create:
Select a bone (or bones), choose the shape from the drop down menu, then press create.
This will create a widget object for each of the selected bones. The widget objects will be placed in the collection that is specified in the user preferences.
### Redo panel
<img src="images/bone_widget_redo_panel.png" alt="drawing" width="400">
#### Scale to bone length:
When enabled the Global Size will be multiplied by the bone length. (ie - the widget will be relative size to the size of the bone)
With this disabled, the Global Size will be in Blender units.
#### Use Face Data:
If the widget that has been added has faces, you can choose to show them with this setting. This will either include or exclude them when the widget is built.
#### Global size:
This will be the size of the widget, relative to the size of the bone if 'Scale to bone length' is enabled. Or in Blender units if that setting is disabled.
#### Global Size XYZ: (Advanced Option only)
When the advanced options is enabled you can access the individual scale channels of the created widget, rather that 1 scale value for all 3 axes
#### Slide:
This will slide the position of the widget along the Y axis (or length) of the bone. 0.0 is at the head of the bone and 1.0 is the tail. (negative values are possible too)
#### Slide X/Y/Z (Advanced Option Only)
When advanced mode is enabled, the slide property is split into 3 axies rather than just the defalt y axis.
#### Rotation X/Y/Z
You can rotate the widget by these values at the time of creation. This can save you from having to jump into edit mode to rotate a widget to better align with your situation.
#### Wire Width:
This will let you set the wireframe thickness. The default setting is 2.0 but Blender will allow any float between 1 and 16.
#### Advanced Options:
This checkbox will switch the slide value into 3 axes rather than just the default Y axis. This will enable the user to position the widget in some situations without having to jump into edit mode.
### Edit/To Bone:
When in pose mode, this will jump into edit mode for the custom bone shape and allow you to edit it.
When you have the shape selected (object or edit mode), this button will display as "To Bone". That will take you back to pose mode, if that mesh object is in face a custom shape.
<b>Note on Creating and Editing Shapes:</b><br>
When you 'Create' a shape, it will always be placed in the collection set in the user preferences.<br>
If you 'Edit' a shape, it will stay in whatever collection that widget was already located.
### Match bone Transforms:
If the widgets get out of alignment with the location of the bone itself, this operator will snap the selected widget to the matrix of the bone. It works if you have the bone(s) selected or if you have the widget object(s) selected.
#### Resync Widget Names:
Sometimes you might rename a bone/or a widget. This operator will loop through all the custom bone shapes and make sure they match the name of the bone they are assigned to.
<b>Note:</b>
Currently the add-on is designed to have one widget per bone, if you have multiple users of the same widget, it will be renamed to the last user it finds.
### Clear Bone Widget:
This will clear the custom bone shapes from all the selected bones.
### Delete Unused Widgets:
This operator will loop through the widget collection and delete anything that isn't being used. This helps keep things tidy.
### Use Selected Object:
If you want to apply a mesh object that is already in your scene as a custom shape, you can use this option.
First select the mesh shape you want to use (object mode), then shift select the armature, switch into pose mode and make sure you select any bone(s) you want this shape to be applied to. Then press the button.
### Hide/Show Collection:
As the name would suggest this will toggle the visibility of the widget collection.
<blockquote>
<b>Note:</b>
This will only toggle the visibility of the designated widget collection (set in the preferences). If your character has widgets outside of this collection, it will not toggle the visibilty of that.
</blockquote>
</br></br>
## User Preferences:
![alt text](images/bone_widget_user_prefs.png)
### Use Rifigy Defaults
With this enabled the addon will use the same naming convention for the widget prefix and collection name as Rifigy. If this setting is disabled you can set them to your preference.
### Widget Prefix
If the "Use Rigify Deafaults" is disabled, the addon will append this text to the start of every new widget created.
### Collection name:
If the "Use Rigify Deafaults" is disabled, the addon will use this as the collection to place all the newly created widgets. If a widget already exists when you edit it, it will stay in the collection it already belongs to. The addon will not move existing widgets.
### Symmetry Suffix:
This will let you set the suffix that is appended to the end of the symetrical widgets.
### Panel Category:
This is the name of the panel the addon will be displayed in.
### Display previews by Default
This boolean will let you set the default state of the Preview Panel.
You will still be able to turn in on/off with the checkbox in the main ui, but advanced users probably don't need to see the large preview all the time.
### Preview Panel Size:
You can set the size of the Preview window with this setting.
### Preview Popup Size:
This will set the size of the images when you activate the popup widget panel.
### Reset Default Widget Thumbnails:
If you have accidentally (or purposefully) changed the images for any of the widgets that the addon ships with, this operator will reset them back to their original images.
---
---
## v2.1 Release Notes:
- [Added] Markus Berg added functionality to display images of the widgets. What a flippin' legend.
- [Added] Markus split the scale and slide into 3 axies and implemented toggle to show simple/advanced mode
- [Added] Popup added for name input when adding a widget to the library
- [Added] import/export user library of shapes
- [Added] you can now add custom images to the widgets (or use the in-built image place holders)
- [Added] added wire width option when the widgets are created
- [change] remove the "_old" functionality of the code (just delete the old widget)
- [fix] the match bone transforms now takes the custom shape transforms into account
- [fix] if the collection didn't exist when you tried to delete unused widgets it would throw an error. You now get a message that hints at the problem.
- [fixed] If there is no active object the panel.py would throw an error
- [fixed] If you Symmetrized the Shape in pose mode with no widget added, it will throw an error.
## v2.0 Release Notes:
- changed the default name of the n panel to 'Rigging' rather than 'Rig Tools'
- [fixed Bug] if the bone was using an override transform, it will use this bone mirror the widget to rather than just taking that bone's matrix
- [Enhancement] Added setting in the user preferences so it can optionally use the Rigify naming convention for widget creation (collection and widget names).
## v1.9 Release Notes:
- [Fix] widget collection no longer needs to be in the master scene for the addon to find it.
- [Fix] All the related functions now search for the collection recursively so the structure of the Widget Collection location doesn't matter.
- [Fix] change the mirrorShape function to only display in pose mode to avoid errors.
## v1.8 Release Notes:
* Fix: updated to work with Blender 2.93/3.0
* Functionality change: If you are editing a Widget that already exists, it now will use the collection where it is actually located rather than trying to find it in the user preferences settings (fixes error if the collection was called something different)
* changed the default collection name and widget names to better match with Rigify (not my preferred naming convention but its better to have more consistency)
* Removed PayPal funding links
* Removed Logger
* Functionality change: I rewrote the way to add the selected object as a widget without having to read and write to a text file
* Fix: If collection is 'excluded' in the outliner it now re-enables it.
## v1.7 Release Notes
* Fix: Allow rename of Addons-Folder
* Fix: Fixed the symmetrize error if the .L or the .R didn't have a widget
* Fix: Symmetrize Operator caused Error when clicking in Object mode
* Fix: Return to Armature: Didn't unselect widget-object before returning to armature
* Fix: Edit Widget: Show only if active bone has a widget
* Feature: Widgets renamed: Gear --> Gear_complex, Root --> Root_1
* Feature: New Widgets: 3 Axes, 6 Axes, Arrow_double_sided, Arrow_head, Chest, Clavicle, Eyes_Target, FK_Limb, Gear_simple,
Roll, Root_2, Torso
* Feature: New Property: Panel Category
* Feature: New Property: Bone Widget symmetry suffix
* Feature: Add selected Mesh as widget-shape
* Feature: Added Logger
### Widget Edits (from v1.7)
* Resized '3 Axes' widget to better match a default size of 1 blender unit (and sits over the 6 axes nicely)
* Renamed 'FK_Limb' to 'FK Limb 1'
* Renamed 'Arm' widget to 'FK Limb 2'
* Renamed widgets to exclude the underscore (for consistency)
* Lowered the resolution of the 'Chest' widget (makes it difficult to edit when it was so high poly). Resized it to 1 blender unit in the Y and aligned it to the +y axis by default
* Lowered the resolution of "Arrow Double Curved"
* Added a thicker version if the arrow called "Roll 3"
* Lowered the resolution of "Torso"
* Added "Torso 1" shape
* Aligned "Eye Target" to the Y axis, renamed to "Eye Target 1", resized.
* Added "Eye Target 2" shape
* Straightened the "Clavicle" shape (makes it more flexible)
* Gear Complex/Gear Simple - aligned to world space
* Rename Finger to "Paddle (square)"
* Added a variation of "Paddle (rounded)" with a round end
* Aligned "Plane" with the Y axis (will 'slide' in a logical direction out of the box)
* Added a "Plane (rounded)" which has rounded corners
* Rotated "Roll" slightly so it looks symmetrical, Renamed to "Roll 1"
* Added "Roll 2"
* Added "Arrow Single Straight" and "Arrow Double Straight"
* Added "Saddle" shape - useful for chests and head controls as a starting point
* Added "Rhomboid" shape
* Flipped "Arrow Head" and renamed to "Pyramid"
## v1.6 Release Notes
* Fixed the "DELETE UNUSED WIDGETS" function (was crashing because the context was wrong)
## v1.5 Release notes
* fixed the symmetrize error if the .L and .R were sharing the same shape and you tried to symmetrize
## v1.4 Release notes
* add function to clear widget from bone
* add operator to show/hide the collections
* add operator that will resync the names of the wdgts to the bones
* add operator to delete unused widgets
* add property to be able to rotate the widgets
* improve the ui
* add some default widgets (line, cube, half cube, circle, gear, triangle)
* fixed bug when 'custom bone transform' is enabled, size is incorrect
## v1.3 Release Notes:
* updated to work with latest 2.8 api
* added user preferences for the widget prefix and the collection name
* doesn't delete old widget when replacing with a new version [resolved]
* it will only match the bone matrix when the armature is at a scale of 1.0 This is because the old id_data used to point to the object, but now it points to the data object. [resolved]
* also doesn't match bone transforms if armature not at 0,0,0 [resolved]
* doesn't work correctly when there is a "custom shape transforms" [resolved]
* match Bone Transforms works when bone is selected but not when the widget is selected [resolved]
* if the widget names end with .001 etc it will throw an error [resolved]
* if no objects are selected it will throw an error [resolved]
@@ -0,0 +1,98 @@
'''
Copyright (C) 2020 Manuel Rais
manu@g-lul.com
Created by Manuel Rais and Christophe Seux
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
bl_info = {
"name": "Bone Widget",
"author": "Manuel Rais, Christophe Seux, Bassam Kurdali, Wayne Dixon, Blender Defender, Max Nadolny, Markus Berg",
"version": (2, 1),
"blender": (4, 1, 0),
"location": "UI > Properties Panel",
"description": "Easily Create Bone Widgets",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Rigging"}
if "bpy" in locals():
import importlib
bl_class_registry.BlClassRegistry.cleanup()
importlib.reload(prefs)
importlib.reload(panels)
importlib.reload(menus)
else:
import bpy
from . import bl_class_registry
from . import operators
from . import panels
from . import prefs
from . import menus
import bpy
def get_user_preferences(context):
if hasattr(context, "user_preferences"):
return context.user_preferences
return context.preferences
def check_version(major, minor, _):
"""
Check blender version
"""
if bpy.app.version[0] == major and bpy.app.version[1] == minor:
return 0
if bpy.app.version[0] > major:
return 1
if bpy.app.version[1] > minor:
return 1
return -1
def register():
operators.register()
menus.register()
bl_class_registry.BlClassRegistry.register()
# Apply preferences of the panel location.
context = bpy.context
pref = get_user_preferences(context).addons[__package__].preferences
# Only default panel location is available in < 2.80
if check_version(2, 80, 0) < 0:
pref.panel_category = "Rigging"
prefs.BoneWidgetPreferences.panel_category_update_fn(pref, context)
panels.register()
def unregister():
operators.unregister()
menus.unregister()
# TODO: Unregister by BlClassRegistry
bl_class_registry.BlClassRegistry.unregister()
panels.unregister()
if __name__ == "__main__":
register()
@@ -0,0 +1,67 @@
# <pep8-80 compliant>
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
class BlClassRegistry:
class_list = []
def __init__(self, *_, **kwargs):
self.legacy = kwargs.get('legacy', False)
def __call__(self, cls):
if hasattr(cls, "bl_idname"):
BlClassRegistry.add_class(cls.bl_idname, cls, self.legacy)
else:
bl_idname = "{}{}{}{}".format(cls.bl_space_type,
cls.bl_region_type,
cls.bl_context, cls.bl_label)
BlClassRegistry.add_class(bl_idname, cls, self.legacy)
return cls
@classmethod
def add_class(cls, bl_idname, op_class, legacy):
for class_ in cls.class_list:
if (class_["bl_idname"] == bl_idname) and \
(class_["legacy"] == legacy):
raise RuntimeError("{} is already registered"
.format(bl_idname))
new_op = {
"bl_idname": bl_idname,
"class": op_class,
"legacy": legacy,
}
cls.class_list.append(new_op)
@classmethod
def register(cls):
for class_ in cls.class_list:
bpy.utils.register_class(class_["class"])
@classmethod
def unregister(cls):
for class_ in cls.class_list:
bpy.utils.unregister_class(class_["class"])
@classmethod
def cleanup(cls):
cls.class_list = []
@@ -0,0 +1,3 @@
from .mainFunctions import *
from .jsonFunctions import *
from .previewFunctions import *
@@ -0,0 +1,291 @@
import bpy
import os
import json
import numpy
from .. import __package__
JSON_DEFAULT_WIDGETS = "widgets.json"
JSON_USER_WIDGETS = "user_widgets.json"
widget_data = {}
def objectDataToDico(object, custom_image):
verts = []
depsgraph = bpy.context.evaluated_depsgraph_get()
mesh = object.evaluated_get(depsgraph).to_mesh()
for v in mesh.vertices:
verts.append(tuple(numpy.array(tuple(v.co)) *
(object.scale[0], object.scale[1], object.scale[2])))
polygons = []
for p in mesh.polygons:
polygons.append(tuple(p.vertices))
edges = []
for e in mesh.edges:
edges.append(e.key)
custom_image = custom_image if custom_image != "" else "user_defined.png"
wgts = {"vertices": verts, "edges": edges, "faces": polygons, "image": custom_image}
return(wgts)
def readWidgets(filename = ""):
global widget_data
wgts = {}
if not filename:
files = [JSON_DEFAULT_WIDGETS, JSON_USER_WIDGETS]
else:
files = [filename]
for file in files:
jsonFile = os.path.join(os.path.dirname(os.path.dirname(__file__)), file)
if os.path.exists(jsonFile):
f = open(jsonFile, 'r')
wgts.update(json.load(f))
f.close()
if not filename: # if both files have been read
widget_data = wgts.copy()
return (wgts)
def getWidgetData(widget):
return widget_data[widget]
def writeWidgets(wgts, file):
jsonFile = os.path.join(os.path.dirname(os.path.dirname(__file__)), file)
#if os.path.exists(jsonFile):
f = open(jsonFile, 'w')
f.write(json.dumps(wgts))
f.close()
def addRemoveWidgets(context, addOrRemove, items, widgets, widget_name="", custom_image=""):
wgts = {}
# file from where the widget should be read or written to
file = JSON_USER_WIDGETS
widget_items = []
for widget_item in items:
widget_items.append(widget_item[1])
activeShape = None
ob_name = None
return_message = ""
if addOrRemove == 'add':
wgts = readWidgets(file)
bw_widget_prefix = bpy.context.preferences.addons[__package__].preferences.widget_prefix
for ob in widgets:
if not widget_name:
if ob.name.startswith(bw_widget_prefix):
ob_name = ob.name[len(bw_widget_prefix):]
else:
ob_name = ob.name
else:
ob_name = widget_name
if (ob_name) not in widget_items:
widget_items.append(ob_name)
wgts[ob_name] = objectDataToDico(ob, custom_image)
activeShape = ob_name
return_message = "Widget - " + ob_name + " has been added!"
elif addOrRemove == 'remove':
user_widgets = readWidgets(file)
if widgets in user_widgets:
wgts = user_widgets
else:
file = JSON_DEFAULT_WIDGETS
wgts = readWidgets(file)
del wgts[widgets]
if widgets in widget_items:
widget_index = widget_items.index(widgets)
activeShape = widget_items[widget_index + 1] if widget_index == 0 else widget_items[widget_index - 1]
widget_items.remove(widgets)
return_message = "Widget - " + widgets + " has been removed!"
if activeShape is not None:
writeWidgets(wgts, file)
# to handle circular import error
from .functions import createPreviewCollection
createPreviewCollection()
# trigger an update and display widget
bpy.context.window_manager.widget_list = activeShape
return 'INFO', return_message
elif ob_name is not None:
return 'WARNING', "Widget - " + ob_name + " already exists!"
def exportWidgetLibrary(filepath):
wgts = readWidgets(JSON_USER_WIDGETS)
if wgts:
# variables needed for exporting widgets
dest_dir = os.path.dirname(filepath)
json_dir = os.path.dirname(os.path.dirname(__file__))
image_folder = 'custom_thumbnails'
custom_image_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', image_folder))
filename = os.path.basename(filepath)
if not filename: filename = "widgetLibrary.zip"
elif not filename.endswith('.zip'): filename += ".zip"
# start the zipping process
from zipfile import ZipFile
with ZipFile(os.path.join(dest_dir, filename), "w") as zip:
# write the json file
file = os.path.join(json_dir, JSON_USER_WIDGETS)
arcname = os.path.basename(file)
zip.write(file, arcname=arcname)
# write the custom images if present
if os.path.exists(custom_image_dir):
from pathlib import Path
for filepath in Path(custom_image_dir).iterdir():
arcname = os.path.join(image_folder, os.path.basename(filepath))
zip.write(filepath, arcname=arcname)
return len(wgts)
class WidgetImportStats:
def __init__(self):
self.new_widgets = 0
self.failed_widgets = {}
self.skipped_widgets = [] # to make sure the data won't change order
self.widgets = {}
def skipped(self):
return len(self.skipped_widgets)
def failed(self):
return len(self.failed_widgets)
def importWidgetLibrary(filepath, action=""):
wgts = {}
from zipfile import ZipFile
dest_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
if os.path.exists(filepath) and action:
try:
with ZipFile(filepath, 'r') as zip_file:
# extract images
for file in zip_file.namelist():
if file.startswith('custom_thumbnails/'):
zip_file.extract(file, dest_dir)
elif file.endswith('.json'): # extract data from the .json file
f = zip_file.read(file)
json_data = f.decode('utf8').replace("'", '"')
wgts = json.loads(json_data)
current_wgts = readWidgets(JSON_USER_WIDGETS)
widgetImport = WidgetImportStats()
# check for duplicate names
for name, data in sorted(wgts.items()): # sorting by keys
if action == "ASK":
widgetImport.skipped_widgets.append({name : data})
elif action == "OVERWRITE":
widgetImport.widgets.update({name : data})
widgetImport.new_widgets += 1
elif action == "SKIP":
if not name in current_wgts:
widgetImport.widgets.update({name : data})
widgetImport.new_widgets += 1
else:
widgetImport.skipped_widgets.append({name : data})
else:
widgetImport.failed_widgets.update({name : data})
except:
pass
return widgetImport
def updateWidgetLibrary(new_widgets, new_images, zip_filepath):
current_widget = bpy.context.window_manager.widget_list
wgts = readWidgets(JSON_USER_WIDGETS)
wgts.update(new_widgets)
writeWidgets(wgts, JSON_USER_WIDGETS)
# extract any images needed from zip library
if new_images:
from zipfile import ZipFile
dest_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
if os.path.exists(zip_filepath):
try:
with ZipFile(zip_filepath, 'r') as zip_file:
for file in zip_file.namelist():
if file.startswith('custom_thumbnails/') and file.split("/")[1] in new_images:
zip_file.extract(file, dest_dir)
except:
pass
# update the preview panel
from .functions import createPreviewCollection
createPreviewCollection()
# trigger an update and display original but updated widget
bpy.context.window_manager.widget_list = current_widget
def updateCustomImage(image_name):
current_widget = bpy.context.window_manager.widget_list
current_widget_data = getWidgetData(current_widget)
# swap out the image
current_widget_data['image'] = image_name
# update and write the new data
wgts = readWidgets(JSON_USER_WIDGETS)
if current_widget in wgts:
wgts[current_widget] = current_widget_data
writeWidgets(wgts, JSON_USER_WIDGETS)
else:
wgts = readWidgets(JSON_DEFAULT_WIDGETS)
wgts[current_widget] = current_widget_data
writeWidgets(wgts, JSON_DEFAULT_WIDGETS)
# update the preview panel
from .functions import createPreviewCollection
createPreviewCollection()
# trigger an update and display original but updated widget
bpy.context.window_manager.widget_list = current_widget
def resetDefaultImages():
current_widget = bpy.context.window_manager.widget_list
wgts = readWidgets(JSON_DEFAULT_WIDGETS)
for name, data in wgts.items():
image = f"{name}.png"
data["image"] = image
writeWidgets(wgts, JSON_DEFAULT_WIDGETS)
# update the preview panel
from .functions import createPreviewCollection
createPreviewCollection()
# trigger an update and display original but updated widget
bpy.context.window_manager.widget_list = current_widget
@@ -0,0 +1,482 @@
import bpy
import numpy
from mathutils import Matrix
from .. import __package__
def getCollection(context):
#check user preferences for the name of the collection
if not context.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_collection_name = context.preferences.addons[__package__].preferences.bonewidget_collection_name
else:
bw_collection_name = "WGTS_" + context.active_object.name
collection = recurLayerCollection(context.scene.collection, bw_collection_name)
if collection: # if it already exists
return collection
collection = bpy.data.collections.get(bw_collection_name)
if collection: # if it exists but not linked to scene
context.scene.collection.children.link(collection)
return collection
else: # create a new collection
collection = bpy.data.collections.new(bw_collection_name)
context.scene.collection.children.link(collection)
# hide new collection
viewlayer_collection = context.view_layer.layer_collection.children[collection.name]
viewlayer_collection.hide_viewport = True
return collection
def recurLayerCollection(layer_collection, collection_name):
found = None
if (layer_collection.name == collection_name):
return layer_collection
for layer in layer_collection.children:
found = recurLayerCollection(layer, collection_name)
if found:
return found
def getViewLayerCollection(context, widget = None):
widget_collection = bpy.data.collections[bpy.data.objects[widget.name].users_collection[0].name]
#save current active layer_collection
saved_layer_collection = bpy.context.view_layer.layer_collection
# actually find the view_layer we want
layer_collection = recurLayerCollection(saved_layer_collection, widget_collection.name)
# make sure the collection (data level) is not hidden
widget_collection.hide_viewport = False
# change the active view layer
bpy.context.view_layer.active_layer_collection = layer_collection
# make sure it isn't excluded so it can be edited
layer_collection.exclude = False
#return the active view layer to what it was
bpy.context.view_layer.active_layer_collection = saved_layer_collection
return layer_collection
def boneMatrix(widget, matchBone):
if widget == None:
return
widget.matrix_local = matchBone.bone.matrix_local
widget.matrix_world = matchBone.id_data.matrix_world @ matchBone.bone.matrix_local
if matchBone.custom_shape_transform:
#if it has a tranform override, apply this to the widget loc and rot
org_scale = widget.matrix_world.to_scale()
org_scale_mat = Matrix.Scale(1, 4, org_scale)
target_matrix = matchBone.custom_shape_transform.id_data.matrix_world @ matchBone.custom_shape_transform.bone.matrix_local
loc = target_matrix.to_translation()
loc_mat = Matrix.Translation(loc)
rot = target_matrix.to_euler().to_matrix()
widget.matrix_world = loc_mat @ rot.to_4x4() @ org_scale_mat
if matchBone.use_custom_shape_bone_size:
ob_scale = bpy.context.scene.objects[matchBone.id_data.name].scale
widget.scale = [matchBone.bone.length * ob_scale[0], matchBone.bone.length * ob_scale[1], matchBone.bone.length * ob_scale[2]]
# if the user has added any custom transforms to the bone widget display - calculate this too
loc = matchBone.custom_shape_translation
rot = matchBone.custom_shape_rotation_euler
scale = matchBone.custom_shape_scale_xyz
widget.scale *= scale
widget.matrix_world = widget.matrix_world @ Matrix.LocRotScale(loc , rot, widget.scale)
widget.data.update()
def fromWidgetFindBone(widget):
matchBone = None
for ob in bpy.context.scene.objects:
if ob.type == "ARMATURE":
for bone in ob.pose.bones:
if bone.custom_shape == widget:
matchBone = bone
return matchBone
def createWidget(bone, widget, relative, size, scale, slide, rotation, collection, use_face_data, wireframe_width):
C = bpy.context
D = bpy.data
if not C.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_widget_prefix = C.preferences.addons[__package__].preferences.widget_prefix
else:
bw_widget_prefix = "WGT-" + C.active_object.name + "_"
matrixBone = bone
# delete the existing shape
if bone.custom_shape:
bpy.data.objects.remove(bpy.data.objects[bone.custom_shape.name], do_unlink=True)
# make the data name include the prefix
newData = D.meshes.new(bw_widget_prefix + bone.name)
bone.use_custom_shape_bone_size = relative
# deal with face data
faces = widget['faces'] if use_face_data else []
# add the verts
newData.from_pydata(numpy.array(widget['vertices']) * [size[0] * scale[0], size[1] * scale[2],
size[2] * scale[1]], widget['edges'], faces)
# Create tranform matrices (slide vector and rotation)
widget_matrix = Matrix()
trans = Matrix.Translation(slide)
rot = rotation.to_matrix().to_4x4()
# Translate then rotate the matrix
widget_matrix = widget_matrix @ trans
widget_matrix = widget_matrix @ rot
# transform the widget with this matrix
newData.transform(widget_matrix)
newData.update(calc_edges=True)
newObject = D.objects.new(bw_widget_prefix + bone.name, newData)
newObject.data = newData
newObject.name = bw_widget_prefix + bone.name
collection.objects.link(newObject)
newObject.matrix_world = bpy.context.active_object.matrix_world @ matrixBone.bone.matrix_local
newObject.scale = [matrixBone.bone.length, matrixBone.bone.length, matrixBone.bone.length]
layer = bpy.context.view_layer
layer.update()
bone.custom_shape = newObject
bone.bone.show_wire = not use_face_data # show faces if use face data is enabled
if bpy.app.version >= (4,2,0):
bone.custom_shape_wire_width = wireframe_width
def symmetrizeWidget(bone, collection):
C = bpy.context
D = bpy.data
if not C.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_widget_prefix = C.preferences.addons[__package__].preferences.widget_prefix
rigify_object_name = ''
else:
bw_widget_prefix = "WGT-"
rigify_object_name = C.active_object.name + "_"
widget = bone.custom_shape
if findMirrorObject(bone):
mirrorBone = findMirrorObject(bone)
mirrorWidget = mirrorBone.custom_shape
if mirrorWidget is not None:
if mirrorWidget != widget:
if C.scene.objects.get(mirrorWidget.name):
D.objects.remove(mirrorWidget)
newData = widget.data.copy()
for vert in newData.vertices:
vert.co = numpy.array(vert.co) * (-1, 1, 1)
newObject = widget.copy()
newObject.data = newData
newData.update()
newObject.name = bw_widget_prefix + rigify_object_name + findMirrorObject(bone).name
D.collections[collection.name].objects.link(newObject)
#if there is a override transform, use that bone matrix in the next step
if findMirrorObject(bone).custom_shape_transform:
mirrorBone = findMirrorObject(bone).custom_shape_transform
newObject.matrix_local = mirrorBone.bone.matrix_local
newObject.scale = [mirrorBone.bone.length, mirrorBone.bone.length, mirrorBone.bone.length]
newObject.data.flip_normals()
layer = bpy.context.view_layer
layer.update()
findMirrorObject(bone).custom_shape = newObject
mirrorBone.bone.show_wire = bone.bone.show_wire
if bpy.app.version >= (4,2,0):
mirrorBone.custom_shape_wire_width = bone.custom_shape_wire_width
else:
pass
def symmetrizeWidget_helper(bone, collection, activeObject, widgetsAndBones):
C = bpy.context
bw_symmetry_suffix = C.preferences.addons[__package__].preferences.symmetry_suffix
bw_symmetry_suffix = bw_symmetry_suffix.split(";")
suffix_1 = bw_symmetry_suffix[0].replace(" ", "")
suffix_2 = bw_symmetry_suffix[1].replace(" ", "")
if activeObject.name.endswith(suffix_1):
if bone.name.endswith(suffix_1) and widgetsAndBones[bone]:
symmetrizeWidget(bone, collection)
elif activeObject.name.endswith(suffix_2):
if bone.name.endswith(suffix_2) and widgetsAndBones[bone]:
symmetrizeWidget(bone, collection)
def deleteUnusedWidgets():
C = bpy.context
D = bpy.data
if not C.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_collection_name = C.preferences.addons[__package__].preferences.bonewidget_collection_name
else:
bw_collection_name = 'WGTS_' + C.active_object.name
collection = recurLayerCollection(C.scene.collection, bw_collection_name)
widgetList = []
for ob in D.objects:
if ob.type == 'ARMATURE':
for bone in ob.pose.bones:
if bone.custom_shape:
widgetList.append(bone.custom_shape)
unwantedList = [
ob for ob in collection.all_objects if ob not in widgetList]
# save the current context mode
mode = C.mode
# jump into object mode
bpy.ops.object.mode_set(mode='OBJECT')
# delete unwanted widgets
for ob in unwantedList:
bpy.data.objects.remove(bpy.data.objects[ob.name], do_unlink=True)
# jump back to current mode
bpy.ops.object.mode_set(mode=mode)
return
def editWidget(active_bone):
C = bpy.context
D = bpy.data
widget = active_bone.custom_shape
collection = getViewLayerCollection(C, widget)
collection.hide_viewport = False
# hide all other objects in collection
for obj in collection.collection.all_objects:
if obj.name != widget.name:
obj.hide_set(True)
else:
obj.hide_set(False) # in case user manually hid it
armature = active_bone.id_data
bpy.ops.object.mode_set(mode='OBJECT')
C.active_object.select_set(False)
if C.space_data.local_view:
bpy.ops.view3d.localview()
# select object and make it active
widget.select_set(True)
bpy.context.view_layer.objects.active = widget
bpy.ops.object.mode_set(mode='EDIT')
bpy.context.tool_settings.mesh_select_mode = (True, False, False) # enter vertex mode
def returnToArmature(widget):
C = bpy.context
D = bpy.data
bone = fromWidgetFindBone(widget)
armature = bone.id_data
if C.active_object.mode == 'EDIT':
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
collection = getViewLayerCollection(C, widget)
collection.hide_viewport = True
# unhide all objects in the collection
for obj in collection.collection.all_objects:
obj.hide_set(False)
if C.space_data.local_view:
bpy.ops.view3d.localview()
bpy.context.view_layer.objects.active = armature
armature.select_set(True)
bpy.ops.object.mode_set(mode='POSE')
armature.data.bones[bone.name].select = True
armature.data.bones.active = armature.data.bones[bone.name]
def findMirrorObject(object):
C = bpy.context
D = bpy.data
bw_symmetry_suffix = C.preferences.addons[__package__].preferences.symmetry_suffix
bw_symmetry_suffix = bw_symmetry_suffix.split(";")
suffix_1 = bw_symmetry_suffix[0].replace(" ", "")
suffix_2 = bw_symmetry_suffix[1].replace(" ", "")
if object.name.endswith(suffix_1):
suffix = suffix_2
suffix_length = len(suffix_1)
elif object.name.endswith(suffix_2):
suffix = suffix_1
suffix_length = len(suffix_2)
elif object.name.endswith(suffix_1.lower()):
suffix = suffix_2.lower()
suffix_length = len(suffix_1)
elif object.name.endswith(suffix_2.lower()):
suffix = suffix_1.lower()
suffix_length = len(suffix_2)
else: # what if the widget ends in .001?
print('Object suffix unknown, using blank')
suffix = ''
objectName = list(object.name)
objectBaseName = objectName[:-suffix_length]
mirroredObjectName = "".join(objectBaseName) + suffix
if object.id_data.type == 'ARMATURE':
return object.id_data.pose.bones.get(mirroredObjectName)
else:
return bpy.context.scene.objects.get(mirroredObjectName)
def findMatchBones():
C = bpy.context
D = bpy.data
bw_symmetry_suffix = C.preferences.addons[__package__].preferences.symmetry_suffix
bw_symmetry_suffix = bw_symmetry_suffix.split(";")
suffix_1 = bw_symmetry_suffix[0].replace(" ", "")
suffix_2 = bw_symmetry_suffix[1].replace(" ", "")
widgetsAndBones = {}
if bpy.context.object.type == 'ARMATURE':
for bone in C.selected_pose_bones:
if bone.name.endswith(suffix_1) or bone.name.endswith(suffix_2):
widgetsAndBones[bone] = bone.custom_shape
mirrorBone = findMirrorObject(bone)
if mirrorBone:
widgetsAndBones[mirrorBone] = mirrorBone.custom_shape
armature = bpy.context.object
activeObject = C.active_pose_bone
else:
for shape in C.selected_objects:
bone = fromWidgetFindBone(shape)
if bone.name.endswith(("L","R")):
widgetsAndBones[fromWidgetFindBone(shape)] = shape
mirrorShape = findMirrorObject(shape)
if mirrorShape:
widgetsAndBones[mirrorShape] = mirrorShape
activeObject = fromWidgetFindBone(C.object)
armature = activeObject.id_data
return (widgetsAndBones, activeObject, armature)
def resyncWidgetNames():
C = bpy.context
D = bpy.data
if not C.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_collection_name = C.preferences.addons[__package__].preferences.bonewidget_collection_name
bw_widget_prefix = C.preferences.addons[__package__].preferences.widget_prefix
else:
bw_collection_name = 'WGTS_' + C.active_object.name
bw_widget_prefix = 'WGT-' + C.active_object.name + '_'
widgetsAndBones = {}
if bpy.context.object.type == 'ARMATURE':
for bone in C.active_object.pose.bones:
if bone.custom_shape:
widgetsAndBones[bone] = bone.custom_shape
for k, v in widgetsAndBones.items():
if k.name != (bw_widget_prefix + k.name):
D.objects[v.name].name = str(bw_widget_prefix + k.name)
def clearBoneWidgets():
C = bpy.context
D = bpy.data
if bpy.context.object.type == 'ARMATURE':
for bone in C.selected_pose_bones:
if bone.custom_shape:
bone.custom_shape = None
bone.custom_shape_transform = None
def addObjectAsWidget(context, collection):
selected_objects = bpy.context.selected_objects
if len(selected_objects) != 2:
print('Only a widget object and the pose bone(s)')
return{'FINISHED'}
allowed_object_types = ['MESH','CURVE']
widget_object = None
for ob in selected_objects:
if ob.type in allowed_object_types:
widget_object = ob
if widget_object:
active_bone = context.active_pose_bone
# deal with any existing shape
if active_bone.custom_shape:
bpy.data.objects.remove(bpy.data.objects[active_bone.custom_shape.name], do_unlink=True)
#duplicate shape
widget = widget_object.copy()
widget.data = widget.data.copy()
# reamame it
bw_widget_prefix = context.preferences.addons[__package__].preferences.widget_prefix
widget_name = bw_widget_prefix + active_bone.name
widget.name = widget_name
widget.data.name = widget_name
# link it
collection.objects.link(widget)
# match transforms
widget.matrix_world = bpy.context.active_object.matrix_world @ active_bone.bone.matrix_local
widget.scale = [active_bone.bone.length, active_bone.bone.length, active_bone.bone.length]
layer = bpy.context.view_layer
layer.update()
active_bone.custom_shape = widget
active_bone.bone.show_wire = True
#deselect original object
widget_object.select_set(False)
def advanced_options_toggled(self, context):
if self.advanced_options:
self.global_size_advanced = (self.global_size_simple,) * 3
self.slide_advanced[1] = self.slide_simple
else:
self.global_size_simple = self.global_size_advanced[1]
self.slide_simple = self.slide_advanced[1]
@@ -0,0 +1,108 @@
import bpy
import bpy.utils.previews
from .jsonFunctions import readWidgets, JSON_USER_WIDGETS
import os
from .. import __package__
preview_collections = {}
def createPreviewCollection():
if preview_collections:
del bpy.types.WindowManager.widget_list
for pcoll in preview_collections.values():
bpy.utils.previews.remove(pcoll)
preview_collections.clear()
pcoll = bpy.utils.previews.new()
pcoll.widget_list = ()
preview_collections["widgets"] = pcoll
bpy.types.WindowManager.widget_list = bpy.props.EnumProperty(
items=generate_previews(), name="Shape", description="Shape", update=preview_update
)
def generate_previews():
enum_items = []
pcoll = preview_collections["widgets"]
if pcoll.widget_list:
return pcoll.widget_list
#directory = os.path.join(os.path.dirname(__file__), "thumbnails")
directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'thumbnails'))
custom_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'custom_thumbnails'))
if directory and os.path.exists(directory):
widget_data = {item[0]: item[1].get("image", "missing_image.png") for item in readWidgets().items()}
widget_names = sorted(widget_data.keys())
for i, name in enumerate(widget_names):
image = widget_data.get(name, "")
filepath = os.path.join(directory, image)
# try in custom_thumbnails if above failed
if not os.path.exists(filepath):
filepath = os.path.join(custom_directory, image)
# if image still not found, let the user know
if not os.path.exists(filepath):
filepath = os.path.join(directory, "missing_image.png")
icon = pcoll.get(name)
if not icon:
thumb = pcoll.load(name, filepath, 'IMAGE')
else:
thumb = pcoll[name]
enum_items.append((name, name, "", thumb.icon_id, i))
pcoll.widget_list = enum_items
return enum_items
def preview_update(self, context):
generate_previews()
def get_preview_default():
return bpy.context.preferences.addons[__package__].preferences.preview_default
def copyCustomImage(filepath, filename):
if os.path.exists(filepath):
image_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'custom_thumbnails'))
destination_path = os.path.join(image_directory, filename)
try:
# create custom thumbnail folder if not existing
if not os.path.exists(image_directory):
os.makedirs(image_directory)
import shutil
shutil.copyfile(filepath, destination_path)
return True
except:
pass
return False
def removeCustomImage(filename):
image_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'custom_thumbnails'))
destination_path = os.path.join(image_directory, filename)
if os.path.isfile(destination_path):
# make sure the image is only used once - else stop
count = 0
for v in readWidgets(JSON_USER_WIDGETS).values():
if v.get("image") == filename:
count += 1
if count > 1:
return False
try:
os.remove(destination_path)
return True
except:
pass
return False
@@ -0,0 +1,32 @@
from bpy.types import Menu
class BONEWIDGET_MT_bw_specials(Menu):
bl_label = "Bone Widget Specials"
def draw(self, context):
layout = self.layout
layout.operator("bonewidget.add_widgets", icon="ADD", text="Add Widget to library")
layout.operator("bonewidget.remove_widgets", icon="REMOVE",
text="Remove Widget from library")
layout.operator("bonewidget.add_custom_image", icon="FILE_IMAGE",
text="Add Custom Image to Widget")
layout.separator()
layout.operator("bonewidget.import_library", icon="IMPORT", text="Import Widget Library")
layout.operator("bonewidget.export_library", icon="EXPORT", text="Export Widget Library")
classes = (
BONEWIDGET_MT_bw_specials,
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in classes:
unregister_class(cls)
@@ -0,0 +1,784 @@
import bpy
from .functions import (
findMatchBones,
fromWidgetFindBone,
symmetrizeWidget_helper,
boneMatrix,
createWidget,
editWidget,
returnToArmature,
addRemoveWidgets,
getWidgetData,
getCollection,
getViewLayerCollection,
recurLayerCollection,
deleteUnusedWidgets,
clearBoneWidgets,
resyncWidgetNames,
addObjectAsWidget,
importWidgetLibrary,
exportWidgetLibrary,
advanced_options_toggled,
removeCustomImage,
copyCustomImage,
getWidgetData,
updateCustomImage,
resetDefaultImages,
updateWidgetLibrary,
)
from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty, StringProperty
class BONEWIDGET_OT_sharedPropertyGroup(bpy.types.PropertyGroup):
"""Storage class for Shared Attribute Properties"""
custom_image_data = ("", "")
import_library_filepath = ""
class BONEWIDGET_OT_createWidget(bpy.types.Operator):
"""Creates a widget for selected bone"""
bl_idname = "bonewidget.create_widget"
bl_label = "Create"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return (context.object and context.object.mode == 'POSE')
relative_size: BoolProperty(
name="Scale to Bone length",
default=True,
description="Scale Widget to bone length"
)
use_face_data: BoolProperty(
name="Use Face Data",
default=False,
description="When enabled this option will include the widget's face data (if available)"
)
advanced_options: BoolProperty(
name="Advanced options",
default=False,
description="Show advanced options",
update=advanced_options_toggled
)
global_size_simple: FloatProperty(
name="Global Size",
default=1.0,
description="Global Size"
)
global_size_advanced: FloatVectorProperty(
name="Global Size",
default=(1.0, 1.0, 1.0),
subtype='XYZ',
description="Global Size"
)
slide_simple: FloatProperty(
name="Slide",
default=0.0,
subtype='NONE',
unit='NONE',
description="Slide widget along bone y axis"
)
slide_advanced: FloatVectorProperty(
name="Slide",
default=(0.0, 0.0, 0.0),
subtype='XYZ',
unit='NONE',
description="Slide widget along bone xyz axes"
)
rotation: FloatVectorProperty(
name="Rotation",
description="Rotate the widget",
default=(0.0, 0.0, 0.0),
subtype='EULER',
unit='ROTATION',
precision=1,
)
wireframe_width: FloatProperty(
name="Wire Width",
default=2.0,
min=1.0,
max=16,
soft_max = 10,
description="Set the thickness of a wireframe widget"
)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
col = layout.column()
row = col.row(align=True)
row.prop(self, "relative_size")
row = col.row(align=True)
if self.advanced_options:
row.prop(self, "use_face_data")
row = col.row(align=True)
row.prop(self, "global_size_advanced" if self.advanced_options else "global_size_simple", expand=False)
row = col.row(align=True)
row.prop(self, "slide_advanced" if self.advanced_options else "slide_simple", text="Slide")
row = col.row(align=True)
row.prop(self, "rotation", text="Rotation")
row = col.row(align=True)
if bpy.app.version >= (4,2,0):
row.prop(self, "wireframe_width", text="Wire Width")
row = col.row(align=True)
row.prop(self, "advanced_options")
def execute(self, context):
widget_data = getWidgetData(context.window_manager.widget_list)
slide = self.slide_advanced if self.advanced_options else (0.0, self.slide_simple, 0.0)
global_size = self.global_size_advanced if self.advanced_options else (self.global_size_simple,) * 3
for bone in bpy.context.selected_pose_bones:
createWidget(bone, widget_data, self.relative_size, global_size, [
1, 1, 1], slide, self.rotation, getCollection(context), self.use_face_data, self.wireframe_width)
return {'FINISHED'}
class BONEWIDGET_OT_editWidget(bpy.types.Operator):
"""Edit the widget for selected bone"""
bl_idname = "bonewidget.edit_widget"
bl_label = "Edit"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.mode == 'POSE'
and context.active_pose_bone.custom_shape is not None)
def execute(self, context):
active_bone = context.active_pose_bone
try:
editWidget(active_bone)
except KeyError:
self.report({'INFO'}, 'This widget is the Widget Collection')
return {'FINISHED'}
class BONEWIDGET_OT_returnToArmature(bpy.types.Operator):
"""Switch back to the armature"""
bl_idname = "bonewidget.return_to_armature"
bl_label = "Return to armature"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'MESH'
and context.object.mode in ['EDIT', 'OBJECT'])
def execute(self, context):
b = bpy.context.object
if fromWidgetFindBone(bpy.context.object):
returnToArmature(bpy.context.object)
else:
self.report({'INFO'}, 'Object is not a bone widget')
return {'FINISHED'}
class BONEWIDGET_OT_matchBoneTransforms(bpy.types.Operator):
"""Match the widget to the bone transforms"""
bl_idname = "bonewidget.match_bone_transforms"
bl_label = "Match bone transforms"
def execute(self, context):
if bpy.context.mode == "POSE":
for bone in bpy.context.selected_pose_bones:
boneMatrix(bone.custom_shape, bone)
else:
for ob in bpy.context.selected_objects:
if ob.type == 'MESH':
matchBone = fromWidgetFindBone(ob)
if matchBone:
boneMatrix(ob, matchBone)
return {'FINISHED'}
class BONEWIDGET_OT_matchSymmetrizeShape(bpy.types.Operator):
"""Symmetrize to the opposite side ONLY if it is named with a .L or .R (default settings)"""
bl_idname = "bonewidget.symmetrize_shape"
bl_label = "Symmetrize"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE'
and context.object.mode in ['POSE'])
def execute(self, context):
widget = bpy.context.active_pose_bone.custom_shape
if widget is None:
self.report({"INFO"}, "There is no widget on this bone.")
return {'FINISHED'}
collection = getViewLayerCollection(context, widget)
widgetsAndBones = findMatchBones()[0]
activeObject = findMatchBones()[1]
widgetsAndBones = findMatchBones()[0]
if not activeObject:
self.report({"INFO"}, "No active bone or object")
return {'FINISHED'}
for bone in widgetsAndBones:
symmetrizeWidget_helper(bone, collection, activeObject, widgetsAndBones)
return {'FINISHED'}
class BONEWIDGET_OT_imageSelect(bpy.types.Operator):
"""Open a Fileselect browser and get the image location"""
bl_idname = "bonewidget.image_select"
bl_label = "Select Image"
filter_glob: StringProperty(
default='*.jpg;*.jpeg;*.png;*.tif;',
options={'HIDDEN'}
)
filename: StringProperty(
name='Filename',
description='Name of custom image',
)
filepath: StringProperty(
subtype="FILE_PATH"
)
def invoke(self, context, event):
self.filename = ""
context.window_manager.fileselect_add(self)
if context.area:
context.area.tag_redraw()
return {'RUNNING_MODAL'}
def execute(self, context):
bpy.context.window_manager.prop_grp.custom_image_name = self.filename
setattr(BONEWIDGET_OT_sharedPropertyGroup, "custom_image_data", (self.filepath, self.filename))
context.area.tag_redraw()
return {'FINISHED'}
class BONEWIDGET_OT_addCustomImage(bpy.types.Operator):
"""Add a custom image to selected preview panel widget"""
bl_idname = "bonewidget.add_custom_image"
bl_label = "Select Image"
filter_glob: StringProperty(
default='*.jpg;*.jpeg;*.png;*.tif;',
options={'HIDDEN'}
)
filename: StringProperty(
name='Filename',
description='Name of custom image',
)
filepath: StringProperty(
subtype="FILE_PATH"
)
def invoke(self, context, event):
self.filename = ""
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def execute(self, context):
if self.filepath:
# first remove previous custom image if present
current_widget = context.window_manager.widget_list
removeCustomImage(getWidgetData(current_widget).get("image"))
# copy over the image to custom folder
copyCustomImage(self.filepath, self.filename)
# update the json files with new image data
updateCustomImage(self.filename)
self.report({'INFO'}, "Custom image has been added!")
return {'FINISHED'}
class BONEWIDGET_OT_addWidgets(bpy.types.Operator):
"""Add selected mesh object to Bone Widget Library"""
bl_idname = "bonewidget.add_widgets"
bl_label = "Add New Widget to Library"
widget_name: StringProperty(
name="Widget Name",
default="",
description="The name of the new widget",
options={"TEXTEDIT_UPDATE"},
)
custom_image: BoolProperty(
name="Custom Image",
default=False,
description="Use a custom image for the new widget"
)
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'MESH' and context.object.mode == 'OBJECT'
and context.active_object is not None)
def draw(self, context):
layout = self.layout
row = layout.row()
row.label(text="Widget Name:")
row.prop(self, "widget_name", text="")
row = layout.row()
# adding custom image this way doesn't work in blender 3.6
if bpy.app.version > (3, 7, 0):
row.prop(self, "custom_image", text="Custom Image")
if self.custom_image:
row = layout.row()
if bpy.app.version >= (4,1,0):
row.prop(bpy.context.window_manager.prop_grp, "custom_image_name", text="", placeholder="Choose an image...", icon="FILE_IMAGE")
else:
row.prop(bpy.context.window_manager.prop_grp, "custom_image_name", text="", icon="FILE_IMAGE")
row.operator('bonewidget.image_select', icon='FILEBROWSER', text="")
def invoke(self, context, event):
if bpy.context.selected_objects:
self.widget_name = context.active_object.name
setattr(BONEWIDGET_OT_sharedPropertyGroup, "custom_image_name", StringProperty(name="Image Name"))
return context.window_manager.invoke_props_dialog(self)
self.report({'WARNING'}, 'Please select an object first!')
return {'CANCELLED'}
def execute(self, context):
objects = []
if bpy.context.mode == "POSE":
for bone in bpy.context.selected_pose_bones:
objects.append(bone.custom_shape)
else:
for ob in bpy.context.selected_objects:
if ob.type == 'MESH':
objects.append(ob)
if not objects:
self.report({'WARNING'}, 'Select Meshes or Pose bones')
return {'CANCELLED'}
# make sure widget name isn't empty
if not self.widget_name:
self.report({'WARNING'}, "Widget name can't be empty!")
return {'CANCELLED'}
# get filepath to custom image if specified and transfer to custom image folder
custom_image_name = ""
custom_image_path = ""
message_extra = ""
if self.custom_image:
custom_image_path, custom_image_name = bpy.context.window_manager.prop_grp.custom_image_data #context.window_manager.custom_image
# no image path found
if not custom_image_path:
# check if user pasted an image path into text field
text_field = bpy.context.window_manager.prop_grp.custom_image_name
import os
if os.path.isfile(text_field) and text_field.endswith((".jpg", ".jpeg" ".png", ".tif")):
custom_image_name = os.path.basename(text_field)
custom_image_path = text_field
else:
message_extra = " - WARNING - No custom image specified!"
if custom_image_name and custom_image_path:
copyCustomImage(custom_image_path, custom_image_name)
bpy.context.window_manager.prop_grp.custom_image_name = "" # make sure the field is empty for next time
message_type, return_message = addRemoveWidgets(context, "add", bpy.types.WindowManager.widget_list.keywords['items'],
objects, self.widget_name, custom_image_name)
if return_message:
self.report({message_type}, return_message + message_extra)
return {'FINISHED'}
class BONEWIDGET_OT_removeWidgets(bpy.types.Operator):
"""Remove selected widget object from the Bone Widget Library"""
bl_idname = "bonewidget.remove_widgets"
bl_label = "Remove Widgets"
def execute(self, context):
objects = bpy.context.window_manager.widget_list
# try and remove the image - will abort if no custom image assigned or if missing
removeCustomImage(getWidgetData(objects).get("image"))
message_type, return_message = addRemoveWidgets(context, "remove", bpy.types.WindowManager.widget_list.keywords['items'], objects)
if return_message:
self.report({message_type}, return_message)
return {'FINISHED'}
class BONEWIDGET_OT_importWidgetsSummaryPopup(bpy.types.Operator):
"""Display summary of imported Widget Library"""
bl_idname = "bonewidget.widget_summary_popup"
bl_label = "Imported Widget Summary"
def draw(self, context):
layout = self.layout
layout.scale_x = 1.2
layout.separator()
row = layout.row()
row.label(text=f"Imported Widgets: {context.window_manager.custom_data.new_widgets}")
row = layout.row()
row.label(text=f"Skipped Widgets: {context.window_manager.custom_data.skipped()}")
row = layout.row()
row.label(text=f"Failed Widgets: {context.window_manager.custom_data.failed()}")
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def execute(self, context):
return {'FINISHED'}
class BONEWIDGET_OT_importWidgetsAskPopup(bpy.types.Operator):
"""Ask user how to handle name collisions from the imported Widget Library"""
bl_idname = "bonewidget.widget_ask_popup"
bl_label = "Imported Widget Choice Popup"
widgetImportData = None
import_options = [
("OVERWRITE", "Overwrite", "Overwrite existing widget"),
("SKIP", "Skip", "Skip widget"),
("RENAME", "Rename", "Rename widget"),
]
def draw(self, context):
layout = self.layout
layout.scale_x = 1.2
layout.separator()
row = layout.row()
row.label(text="Choose an action:")
row = layout.row()
for i, _ in enumerate(self.widgetImportData.skipped_widgets):
if getattr(context.window_manager.prop_grp, f"ImportOptions{i}") == self.import_options[2][0]: # Rename
row.prop(context.window_manager.prop_grp, f"EditName{i}", text="")
else:
row.label(text=str(getattr(context.window_manager.prop_grp, f"EditName{i}")))
row.prop(context.window_manager.prop_grp, f"ImportOptions{i}", text=" ")
row = layout.row()
def invoke(self, context, event):
self.widgetImportData = bpy.context.window_manager.custom_data
# generate the x number of drop down lists and widget names needed
for n, widget in enumerate(self.widgetImportData.skipped_widgets):
widget_name = next(iter(widget.keys()))
setattr(BONEWIDGET_OT_sharedPropertyGroup, f"ImportOptions{n}", bpy.props.EnumProperty(
name=f"ImportOptions{n}",
description="Choose an option",
items=self.import_options,
default="SKIP"
))
setattr(bpy.context.window_manager.prop_grp, f"ImportOptions{n}", "SKIP")
setattr(BONEWIDGET_OT_sharedPropertyGroup, f"EditName{n}", StringProperty(
name=f"EditName{n}",
default=widget_name,
description="The name of the widget",
))
setattr(bpy.context.window_manager.prop_grp, f"EditName{n}", widget_name)
return context.window_manager.invoke_props_dialog(self)
def execute(self, context):
widget_results = {}
widget_images = set()
for i, widget in enumerate(self.widgetImportData.skipped_widgets):
widget_name, widget_data = next(iter(widget.items()))
widget_image = widget_data.get('image')
widget_image = widget_image if widget_image != "user_defined.png" else "" # only append custom images
action = getattr(bpy.context.window_manager.prop_grp, f"ImportOptions{i}")
new_widget_name = getattr(bpy.context.window_manager.prop_grp, f"EditName{i}")
# error check before proceeding - widget renamed to empty string
if widget_name != new_widget_name and new_widget_name.strip() == "":
self.widgetImportData.failed_widgets.update(widget)
continue
if action == self.import_options[0][0]: # overwrite
widget_results.update(widget)
if widget_image: widget_images.add(widget_image)
self.widgetImportData.new_widgets += 1
self.widgetImportData.skipped_widgets.remove(widget)
elif action == self.import_options[2][0]: # Rename
widget_results.update({new_widget_name: widget_data})
if widget_image: widget_images.add(widget_image)
self.widgetImportData.new_widgets += 1
self.widgetImportData.skipped_widgets.remove(widget)
updateWidgetLibrary(widget_results, widget_images, bpy.context.window_manager.prop_grp.import_library_filepath)
# clean up the data from the property group
for i in range(self.widgetImportData.skipped()):
delattr(BONEWIDGET_OT_sharedPropertyGroup, f"ImportOptions{i}")
delattr(BONEWIDGET_OT_sharedPropertyGroup, f"EditName{i}")
#del bpy.types.WindowManager.custom_data
self.widgetImportData = None
# display summary of imported widgets
bpy.ops.bonewidget.widget_summary_popup('INVOKE_DEFAULT')
return {'FINISHED'}
class BONEWIDGET_OT_importLibrary(bpy.types.Operator):
"""Import User Defined Widgets"""
bl_idname = "bonewidget.import_library"
bl_label = "Import Library"
filter_glob: StringProperty(
default='*.zip',
options={'HIDDEN'}
)
filename: StringProperty(
name='Filename',
description='Name of file to be imported',
)
filepath: StringProperty(
subtype="FILE_PATH"
)
import_option : bpy.props.EnumProperty(
name="Import Option",
items=[
("OVERWRITE", "Overwrite", "Overwrite existing widget"),
("SKIP", "Skip", "Skip widget"),
("ASK", "Ask", "Ask user what to do")],
default="ASK",
)
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.label(text="If duplicates are found:")
row = layout.row(align=True)
row.prop(self, "import_option", expand=True)
def execute(self, context):
if self.filepath and self.import_option:
importLibraryData = importWidgetLibrary(self.filepath, self.import_option)
bpy.context.window_manager.prop_grp.import_library_filepath = self.filepath
bpy.types.WindowManager.custom_data = importLibraryData
if self.import_option == "ASK":
bpy.types.WindowManager.custom_data = importLibraryData
bpy.ops.bonewidget.widget_ask_popup('INVOKE_DEFAULT')
elif self.import_option == "OVERWRITE" or self.import_option == "SKIP":
widget_images = set()
# extract image names if any
for _, value in importLibraryData.widgets.items():
widget_images.add(value['image'])
updateWidgetLibrary(importLibraryData.widgets, widget_images, self.filepath)
bpy.ops.bonewidget.widget_summary_popup('INVOKE_DEFAULT')
else:
bpy.ops.bonewidget.widget_summary_popup('INVOKE_DEFAULT')
return {'FINISHED'}
def invoke(self, context, event):
self.filename = ""
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
class BONEWIDGET_OT_exportLibrary(bpy.types.Operator):
"""Export User Defined Widgets"""
bl_idname = "bonewidget.export_library"
bl_label = "Export Library"
filter_glob: StringProperty(
default='*.zip',
options={'HIDDEN'}
)
filename: StringProperty(
name='Filename',
description='Name of file to be exported',
)
filepath: StringProperty(
subtype="FILE_PATH"
)
def execute(self, context):
if self.filepath and self.filename:
num_widgets = exportWidgetLibrary(self.filepath)
self.report({'INFO'}, f"{num_widgets} user defined widgets exported successfully!")
return {'FINISHED'}
def invoke(self, context, event):
self.filename = "widgetLibrary.zip"
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
class BONEWIDGET_OT_toggleCollectionVisibility(bpy.types.Operator):
"""Show/hide the bone widget collection"""
bl_idname = "bonewidget.toggle_collection_visibilty"
bl_label = "Collection Visibilty"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.mode == 'POSE')
def execute(self, context):
if not context.preferences.addons[__package__].preferences.use_rigify_defaults:
bw_collection_name = context.preferences.addons[__package__].preferences.bonewidget_collection_name
else:
bw_collection_name = 'WGTS_' + context.active_object.name
bw_collection = recurLayerCollection(bpy.context.view_layer.layer_collection, bw_collection_name)
bw_collection.hide_viewport = not bw_collection.hide_viewport
#need to recursivly search for the view_layer
bw_collection.exclude = False
return {'FINISHED'}
class BONEWIDGET_OT_deleteUnusedWidgets(bpy.types.Operator):
"""Delete unused objects in the WGT collection"""
bl_idname = "bonewidget.delete_unused_widgets"
bl_label = "Delete Unused Widgets"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.mode == 'POSE')
def execute(self, context):
try:
deleteUnusedWidgets()
except:
self.report({'INFO'}, "Can't find the Widget Collection. Does it exist?")
return {'FINISHED'}
class BONEWIDGET_OT_clearBoneWidgets(bpy.types.Operator):
"""Clears widgets from selected pose bones but doesn't remove them from the scene."""
bl_idname = "bonewidget.clear_widgets"
bl_label = "Clear Widgets"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.mode == 'POSE')
def execute(self, context):
clearBoneWidgets()
return {'FINISHED'}
class BONEWIDGET_OT_resyncWidgetNames(bpy.types.Operator):
"""Clear widgets from selected pose bones"""
bl_idname = "bonewidget.resync_widget_names"
bl_label = "Resync Widget Names"
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.mode == 'POSE')
def execute(self, context):
resyncWidgetNames()
return {'FINISHED'}
class BONEWIDGET_OT_addObjectAsWidget(bpy.types.Operator):
"""Add selected object as widget for active bone."""
bl_idname = "bonewidget.add_as_widget"
bl_label = "Confirm selected Object as widget shape"
@classmethod
def poll(cls, context):
return (len(context.selected_objects) == 2 and context.object.mode == 'POSE')
def execute(self, context):
addObjectAsWidget(context, getCollection(context))
return {'FINISHED'}
class BONEWIDGET_OT_resetDefaultImages(bpy.types.Operator):
"""Resets the thumbnails for all default widgets"""
bl_idname = "bonewidget.reset_default_images"
bl_label = "Reset"
def execute(self, context):
resetDefaultImages()
return {'FINISHED'}
classes = (
BONEWIDGET_OT_removeWidgets,
BONEWIDGET_OT_addWidgets,
BONEWIDGET_OT_importLibrary,
BONEWIDGET_OT_exportLibrary,
BONEWIDGET_OT_matchSymmetrizeShape,
BONEWIDGET_OT_matchBoneTransforms,
BONEWIDGET_OT_returnToArmature,
BONEWIDGET_OT_editWidget,
BONEWIDGET_OT_createWidget,
BONEWIDGET_OT_toggleCollectionVisibility,
BONEWIDGET_OT_deleteUnusedWidgets,
BONEWIDGET_OT_clearBoneWidgets,
BONEWIDGET_OT_resyncWidgetNames,
BONEWIDGET_OT_addObjectAsWidget,
BONEWIDGET_OT_importWidgetsSummaryPopup,
BONEWIDGET_OT_importWidgetsAskPopup,
BONEWIDGET_OT_sharedPropertyGroup,
BONEWIDGET_OT_imageSelect,
BONEWIDGET_OT_addCustomImage,
BONEWIDGET_OT_resetDefaultImages,
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.WindowManager.prop_grp = bpy.props.PointerProperty(type=BONEWIDGET_OT_sharedPropertyGroup)
def unregister():
del bpy.types.WindowManager.prop_grp
from bpy.utils import unregister_class
for cls in classes:
unregister_class(cls)
@@ -0,0 +1,131 @@
import bpy
import bpy.utils.previews
from .functions import (
recurLayerCollection,
preview_collections,
createPreviewCollection,
get_preview_default,
)
from .menus import BONEWIDGET_MT_bw_specials
class BONEWIDGET_PT_bw_panel:
"""BoneWidget Addon UI"""
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Rigging"
bl_label = "Bone Widget"
class BONEWIDGET_PT_bw_panel_main(BONEWIDGET_PT_bw_panel, bpy.types.Panel):
bl_idname = 'BONEWIDGET_PT_bw_panel_main'
bl_label = "Bone Widget"
createPreviewCollection()
def draw(self, context):
layout = self.layout
# preview toggle checkbox
row = layout.row(align=True)
row.prop(context.window_manager, "toggle_preview")
# preview view
if context.window_manager.toggle_preview:
row = layout.row(align=True)
preview_panel_size = context.preferences.addons[__package__].preferences.preview_panel_size
preview_popup_size = context.preferences.addons[__package__].preferences.preview_popup_size
row.template_icon_view(context.window_manager, "widget_list", show_labels=True,
scale=preview_panel_size, scale_popup=preview_popup_size)
# dropdown list
row = layout.row(align=True)
row.prop(context.window_manager, "widget_list", expand=False, text="")
row = layout.row(align=True)
row.menu("BONEWIDGET_MT_bw_specials", icon='DOWNARROW_HLT', text="")
row.operator("bonewidget.create_widget", icon="OBJECT_DATAMODE")
if bpy.context.mode == "POSE":
row.operator("bonewidget.edit_widget", icon="OUTLINER_DATA_MESH")
else:
row.operator("bonewidget.return_to_armature", icon="LOOP_BACK", text='To bone')
layout = self.layout
layout.separator()
layout.operator("bonewidget.symmetrize_shape", icon='MOD_MIRROR', text="Symmetrize Shape")
layout.operator("bonewidget.match_bone_transforms",
icon='GROUP_BONE', text="Match Bone Transforms")
layout.operator("bonewidget.resync_widget_names",
icon='FILE_REFRESH', text="Resync Widget Names")
layout.separator()
layout.operator("bonewidget.clear_widgets",
icon='X', text="Clear Bone Widget")
layout.operator("bonewidget.delete_unused_widgets",
icon='TRASH', text="Delete Unused Widgets")
if bpy.context.mode == 'POSE':
layout.operator("bonewidget.add_as_widget",
text="Use Selected Object",
icon='RESTRICT_SELECT_OFF')
# if the bw collection exists, show the visibility toggle
if not context.preferences.addons[__package__].preferences.use_rigify_defaults: #rigify
bw_collection_name = context.preferences.addons[__package__].preferences.bonewidget_collection_name
elif context.active_object: # active object
bw_collection_name = 'WGTS_' + context.active_object.name
else: # this is needed because sometimes there is no active object
bw_collection_name = None
bw_collection = recurLayerCollection(bpy.context.view_layer.layer_collection, bw_collection_name)
if bw_collection is not None:
if bw_collection.hide_viewport:
icon = "HIDE_ON"
text = "Show Collection"
else:
icon = "HIDE_OFF"
text = "Hide Collection"
row = layout.row()
row.separator()
row = layout.row()
row.operator("bonewidget.toggle_collection_visibilty",
icon=icon, text=text)
classes = (
BONEWIDGET_PT_bw_panel_main,
)
def register():
bpy.types.WindowManager.toggle_preview = bpy.props.BoolProperty(
name="Preview Panel",
default=get_preview_default(),
description="Show thumbnail previews"
)
from bpy.utils import register_class
for cls in classes:
try:
register_class(cls)
except:
pass
def unregister():
del bpy.types.WindowManager.widget_list
del bpy.types.WindowManager.toggle_preview
for pcoll in preview_collections.values():
bpy.utils.previews.remove(pcoll)
preview_collections.clear()
from bpy.utils import unregister_class
for cls in classes:
try:
unregister_class(cls)
except:
pass
@@ -0,0 +1,129 @@
import bpy
from bpy.types import AddonPreferences
from bpy.props import StringProperty, BoolProperty, FloatProperty
from .bl_class_registry import BlClassRegistry
from .panels import BONEWIDGET_PT_bw_panel_main
from .operators import BONEWIDGET_OT_resetDefaultImages
@BlClassRegistry()
class BoneWidgetPreferences(AddonPreferences):
bl_idname = __package__
#Use Rigify Defaults
use_rigify_defaults: BoolProperty(
name="Use Rigify Defaults",
description="Use the same naming convention for widget creation (disable if you prefer your naming convention)",
default=True,
)
# widget prefix
widget_prefix: StringProperty(
name="Bone Widget prefix",
description="Choose a prefix for the widget objects",
default="WGT-",
)
# symmetry suffix
symmetry_suffix: StringProperty(
name="Bone Widget symmetry suffix",
description="Choose a naming convention for the symmetrical widgets, seperate by semicolon.",
default="L; R",
)
# collection name
bonewidget_collection_name: StringProperty(
name="Bone Widget collection name",
description="Choose a name for the collection the widgets will appear",
default="WGTS",
)
def panel_category_update_fn(self, context):
has_panel = hasattr(bpy.types, BONEWIDGET_PT_bw_panel_main.bl_idname)
if has_panel:
try:
bpy.utils.unregister_class(BONEWIDGET_PT_bw_panel_main)
except:
pass
BONEWIDGET_PT_bw_panel_main.bl_category = self.panel_category
bpy.utils.register_class(BONEWIDGET_PT_bw_panel_main)
panel_category: StringProperty(
name="Panel Category",
description="Category to show Bone-Widgets panel",
default="Rigging",
update=panel_category_update_fn,
)
preview_panel_size: FloatProperty(
name="Preview Panel Size",
description="Size of the Preview Panel",
default=6.0,
min=1.0,
max=10.0,
precision=1,
)
preview_popup_size: FloatProperty(
name="Preview Popup Size",
description="Size of the Preview Popup Thumbnails",
default=3.5,
min=1.0,
max=10.0,
precision=1,
)
preview_default: BoolProperty(
name="Default Preview State",
description="Default state of preview panel",
default=True,
)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(self, "use_rigify_defaults", text="Use Rigify Defaults")
row = layout.row()
col = row.column()
col.prop(self, "widget_prefix", text="Widget Prefix")
col.prop(self, "bonewidget_collection_name", text="Collection name")
row.enabled = not self.use_rigify_defaults
row = layout.row()
row = layout.row()
row.prop(self, "symmetry_suffix", text="Symmetry suffix")
row = layout.row()
row = layout.row()
col = row.column()
col.label(text="Set the name of the tab where the Bone-Widget addon will show:")
col.prop(self, "panel_category")
# preview area
row = layout.row()
row = layout.row()
row.label(text="Thumbnail Previews:")
row = layout.row()
row.prop(self, "preview_default", text="Display Previews by Default")
row = layout.row()
col = row.column()
col.label(text="Preview Panel Size:")
row.prop(self, "preview_panel_size", text="")
row = layout.row()
col = row.column()
col.label(text="Preview Popup Size:")
row.prop(self, "preview_popup_size", text="")
row = layout.row()
layout.separator()
row = layout.row()
row = row.split(factor=.75)
row.label(text="Reset Default Widget Thumbnails")
row.operator("bonewidget.reset_default_images", icon="ERROR")
File diff suppressed because one or more lines are too long