1
1

Compare commits

...

349 Commits

Author SHA1 Message Date
13de8b171e Changes from D7978 and D7499 2020-06-10 11:48:57 -04:00
fcbd53c3b0 Merge branch 'master' into modifier-panels-ui 2020-06-10 11:46:00 -04:00
9e76a641af Apply changes from constraints patch and modifiers patch 2020-06-09 17:52:57 -04:00
5ecc239c0a Merge branch 'master' into modifier-panels-ui 2020-06-09 17:31:59 -04:00
b6764b9a31 Update for latest master, small cleanup and renaming 2020-06-05 12:46:24 -04:00
76e9cdc90a Merge branch 'master' into modifier-panels-ui 2020-06-05 11:34:10 -04:00
8a971c9d91 Cleanup: Remove unused variables 2020-05-21 23:15:33 -04:00
09feff781c Gpencil build modifier: Re-label panel 2020-05-21 23:15:22 -04:00
fb7cc1d275 Fix another crash when built without cycles 2020-05-21 23:15:02 -04:00
0e18ea5b9c Attempt at warning for Gpencil material problem 2020-05-21 21:00:02 -04:00
e7076c6d95 Add recently added gpencil build property 2020-05-21 20:03:17 -04:00
7961d27fdf Match recent renaming of modifier functions 2020-05-21 19:50:37 -04:00
bda924385f Fix errors with last merge 2020-05-21 19:45:42 -04:00
8eca2b4a1b Merge branch 'panel-list-patch-3' into modifier-panels-ui-local 2020-05-21 19:25:53 -04:00
686eaad84c Fix error with merge 2020-05-21 19:07:21 -04:00
5094397dab Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-05-21 18:59:57 -04:00
e57458470d Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-21 18:57:45 -04:00
dde592e622 Merge branch 'master' into panel-list-patch 2020-05-21 18:57:34 -04:00
1d8b4e4023 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-21 11:05:40 -04:00
8b9ae6bc91 Fix instanced panel list order when loading existing files
This just requires a small change to solve this situation: the panel
sort order needs to be set to the max sort order when it's added.

We recently got rid of similar behavior, but it turns out it's necessary
when loading existing files, and it doesn't hurt in other cases.
2020-05-21 10:07:09 -04:00
56e40dd168 Fix crash in subsurf modifier UI when built without cycles 2020-05-21 09:35:10 -04:00
e0efec00db Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-20 19:01:15 -04:00
d91adcf8b7 Merge branch 'master' into panel-list-patch 2020-05-20 19:00:57 -04:00
60a14bd8ef Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-15 17:58:12 -04:00
eefbd92981 Fix previous commit 2020-05-15 17:57:38 -04:00
6e577f8236 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-15 17:55:24 -04:00
d86e97c757 Fix box ymax changing when panel opens 2020-05-15 17:55:04 -04:00
49a5422500 Remove flag in python as well 2020-05-15 17:47:22 -04:00
deef89c17c Add new simulation modifier UI 2020-05-15 17:37:26 -04:00
1359bd34ce Add new mirror UDIM property 2020-05-15 17:32:47 -04:00
9063269462 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-15 17:32:12 -04:00
1784982498 Remove instanced list start flag 2020-05-15 17:26:29 -04:00
c14878923b Merge branch 'master' into panel-list-patch 2020-05-15 17:16:54 -04:00
cbc380d252 Two small fixes in interface_panel, slightly increase margin 2020-05-08 17:41:58 -04:00
caae7fe9ef Update for naming changes in master, various small changes 2020-05-08 17:40:09 -04:00
cf261540e6 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-08 17:39:26 -04:00
7969a3384e Merge branch 'master' into panel-list-patch 2020-05-08 16:44:50 -04:00
bedf3550b1 Merge branch 'master' into panel-list-patch 2020-05-08 11:09:03 -04:00
a9e822484c Review feedback 2020-05-08 11:06:53 -04:00
d1b2dd6492 Merge branch 'master' into panel-list-patch 2020-05-07 14:57:03 -04:00
e8d028c0af Use "Duplicate" Instead of "Copy" 2020-05-05 10:26:12 -04:00
6d3af8e647 Merge branch 'master' into modifier-panels-ui 2020-05-05 10:25:53 -04:00
37b3f18fec Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-04 17:43:17 -04:00
6a32b744b4 Merge branch 'master' into panel-list-patch 2020-05-04 17:41:54 -04:00
c7bc1e7778 Merge changes from patches and master 2020-05-01 15:58:07 -05:00
9867d84628 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-05-01 15:20:52 -05:00
6222f6a22c Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-01 15:20:31 -05:00
2e4d8aea50 Merge branch 'master' into panel-list-patch 2020-05-01 15:20:19 -05:00
75d676a089 Merge branch 'master' into modifier-panels-ui 2020-05-01 15:19:28 -05:00
d8f9baa063 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-05-01 11:14:27 -05:00
342ef4e678 Finish last changes 2020-05-01 11:09:29 -05:00
81b7dbc0a7 Simplify subpanel registration arguments 2020-05-01 11:04:21 -05:00
deed16e4b6 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-05-01 10:22:53 -05:00
ab6afef863 Merge branch 'master' into panel-list-patch 2020-05-01 10:22:34 -05:00
17f03611ac Avoid redundant label 2020-05-01 10:19:40 -05:00
91877e71df Merge changes from patch review 2020-04-30 18:24:04 -05:00
917d7a6cea Merge branch 'master' into modifier-panels-ui 2020-04-30 16:19:06 -05:00
29d40872c3 - Merge changes from patch 2
- Move panel type lookup to constraints.c
2020-04-30 16:14:05 -05:00
2beed7cbf7 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-04-30 15:08:01 -05:00
ecb4861a78 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-30 15:03:36 -05:00
b13e9f8147 Merge branch 'master' into panel-list-patch 2020-04-30 15:00:44 -05:00
7a2cd6f14b Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-04-30 13:20:19 -05:00
42cbeca9ec Review update 2020-04-30 13:12:23 -05:00
f33ed9b0b4 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-30 11:51:34 -05:00
481315be8b Merge branch 'master' into panel-list-patch 2020-04-30 11:50:30 -05:00
b7cd5ffe84 Use "instanced" naming 2020-04-30 11:48:03 -05:00
71962eb62e Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-30 11:24:22 -05:00
2c88153ba6 Cleanup: Naming 2020-04-30 11:24:10 -05:00
d4de4ae278 Use void * for uiListPanelIDFromDataFunc 2020-04-30 11:21:09 -05:00
a41c86bdce Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-30 11:12:22 -05:00
1de1dc4fe4 Naming: list panel to recreate list panel 2020-04-30 11:11:24 -05:00
07237c9b7f Fix shaderFX panel default expansion 2020-04-30 10:52:08 -05:00
1429fc674d ShaderFX UI updates 2020-04-30 10:48:43 -05:00
c62aa8c0e7 Correct horizonal size offset 2020-04-29 18:43:27 -05:00
4469d44ea2 Adjust from review for part 1 2020-04-29 18:39:03 -05:00
02036767f2 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-29 18:34:20 -05:00
d30f334e9b Remove unecessary argument, change variable name 2020-04-29 18:33:37 -05:00
405180192a Fix returning local variable 2020-04-29 18:29:03 -05:00
098b43769e Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-29 18:24:41 -05:00
faed15c2be Finish review changes 2020-04-29 18:24:27 -05:00
2ba8002b36 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-29 18:15:10 -05:00
57e8e174ff Cleanup: Address various review comments 2020-04-29 18:14:26 -05:00
c5aa7f2c6e Use wt->wcol directly 2020-04-29 18:12:37 -05:00
cf87438414 Revert unrelated change 2020-04-29 18:12:19 -05:00
ec07b2f496 Fix comment 2020-04-29 18:11:25 -05:00
da0f59f55a Merge branch 'master' into panel-list-patch 2020-04-29 16:34:26 -05:00
6d49335137 Array: Avoid redundant label 2020-04-29 16:03:16 -05:00
391b4dfd37 ShaderFX UI Panels 2020-04-29 14:35:29 -05:00
33edd753dc Gpencil modifier: copy expand flag 2020-04-29 14:35:00 -05:00
57fc9ef717 Fix location of gpencil color mode selector 2020-04-29 10:15:58 -05:00
8ef0a9fdea Layouts for great pencil modifiers
Worked out the layouts with Matias Mendiola and implemented them here.
2020-04-28 14:52:59 -05:00
4464b99465 Grease pencil modifier drag and drop, expansion saving 2020-04-27 19:06:53 -05:00
854461002c Naming of modifier move to index operator 2020-04-27 18:52:32 -05:00
eac08d6562 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-04-27 18:44:48 -05:00
c055fbf557 Naming of move to index operator 2020-04-27 18:42:51 -05:00
24da365d1c Empty grease pencil modifier panels 2020-04-27 18:41:26 -05:00
4f1aa83683 Merge branch 'panel-list-patch-3' into modifier-panels-ui 2020-04-27 16:35:34 -05:00
65ab18bc59 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-04-27 16:32:24 -05:00
2972b185a5 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-27 16:30:14 -05:00
45e46267a8 Merge branch 'master' into panel-list-patch 2020-04-27 16:28:42 -05:00
2000c3ed7a "Axis" instead of "Use" 2020-04-27 10:57:27 -05:00
f9744e1153 Merge branch 'panel-list-patch-2' into panel-list-patch-3 2020-04-26 19:35:50 -05:00
f45d7e3fee Array Modifier: Move relative offset subpanel upRelative offset is on by default, so it makes more sense for it to beat the top. Also add XYZ labels to the relative offset and label theproperty "factor" instead. 2020-04-26 19:35:02 -05:00
e55a870430 Merge branch 'panel-list-patch' into panel-list-patch-2 2020-04-26 19:08:20 -05:00
25898b9799 Merge branch 'master' into panel-list-patch 2020-04-26 19:06:19 -05:00
4571ea1bdd Cleanup: Synchronize more changes with patches 2020-04-23 09:41:44 -05:00
5c19f23635 Patch 3 2020-04-22 17:22:31 -05:00
1fb95a08f9 Remove print statement 2020-04-22 16:59:53 -05:00
07c55e2543 More cleanup, versioning 2020-04-22 16:58:21 -05:00
2c34d44d28 Add versioning code 2020-04-22 15:53:33 -05:00
e9d8259d13 Patch 2 2020-04-22 15:39:35 -05:00
c4cbb499d5 Pre-review cleanup
- Remove the idea of "active modifier"
- Remove UIList. This can always be added later easily
- Cleanup various comments, unused headers, and unrelated changes
2020-04-22 15:14:47 -05:00
a7e3bbabd2 Cleanup: Rearrange code 2020-04-22 14:34:59 -05:00
726585cb37 Only draw modifier name when panels are wide 2020-04-22 13:27:25 -05:00
6c05aa60c4 Finish subsurf modifier UI 2020-04-22 12:54:32 -05:00
4c7c8efd0b Patch 1 2020-04-21 21:59:36 -05:00
909d497107 Merge branch 'master' into modifier-panels-ui 2020-04-21 17:27:15 -05:00
39555526ae Remove panel-grid snapping
Makes draggin feel unresponsive, there's no need for this really.
Was there since before 2.5 I think. Maybe to avoid too many redraws or
make stacked panels (removed in 2.5) work better.
2020-04-21 22:22:22 +02:00
d882ec322a Constraints UI: Add separator after the X to match modifiers 2020-04-21 20:50:21 +02:00
7229f9a99e Make buttons in constraint headers extpand to full layout width 2020-04-21 12:32:36 +02:00
20da3ae1c5 Fix typo in previous commit.... 2020-04-21 12:31:31 +02:00
a81b558d48 Cleanup: Rename panel type flag from extend to expand
Not sure why I used extend, probably just because of brain dead
programming :)
Also, expose the flag to python panel options.
2020-04-21 12:28:33 +02:00
18cc24ded7 Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-20 12:44:01 -05:00
b3f7eb4a07 Deduplicate code, fix crash moving panels quickly
The method to check if the panel list represents data is now generalized.
Also actate EXIT panel state when freeing list panels when there is still
a handler attached.
2020-04-20 12:43:55 -05:00
80446f237b Constraints UI: Layout tweaks
Increase consistency between constraints layouts.
2020-04-20 10:53:28 +02:00
b5a46211f4 First pass of layout updates for remaining constraints 2020-04-19 18:47:06 -05:00
f12a66817d Implement expansion saving, drag drop for constraints
The move constraint to index operator still needs a proper poll function.
2020-04-19 12:44:35 -05:00
f787b7f1ca Rework UI layouts for Transform Constraints
Update layouts to 2.8 style, which is generally a huge improvement
for legibility and consistency. Doesn't touch decorators, there are still
issues there.

Also deduplicate some code by using a class for all parent
constraint panel and all constraint subpanels.
2020-04-19 00:45:09 -05:00
aa369d9e4f Cleanup: Fix mispelled "constraints" 2020-04-19 00:41:31 -05:00
f4636b0965 Add list subpanel to UI 2020-04-19 00:41:16 -05:00
c45e1ef21b Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-18 15:12:04 -05:00
d9f542bbb0 Initial implementation of constraint panels
The layouts are still defined in python, but they are each in a separate
panel. They are named and searched for with the constraint type info
struct names.

This commit does not change the layout for any of the constraints.
2020-04-18 15:11:57 -05:00
94fb309372 Add list panel index to RNA
Needed to support creating list panel layouts in python.

Also check for unimplemented list panel functions before calling.
2020-04-18 15:01:46 -05:00
dec9349a75 UI: Rename Cast Type to Shape
Clearer naming
2020-04-18 19:25:29 +02:00
110c148773 Merge branch 'master' into modifier-panels-ui 2020-04-17 17:20:57 -05:00
3aef74bc1f Merge branch 'panel-drag-scroll-region' into modifier-panels-ui 2020-04-17 17:16:45 -05:00
6fa3e4151e Fix, add comments 2020-04-17 16:56:00 -05:00
e8a6759c1d Initial implementation, not quite working 2020-04-17 16:30:44 -05:00
1a2bca63ef Use simpler solution 2020-04-17 12:52:35 -05:00
54ac90625f UI: Fix last panel dragging affecting region scroll
When finding the total height of the region's panels for scrolling, we
should use starting position of the drag, because a drag and drop doesn't
change the resulting height of the region.
2020-04-17 12:01:50 -05:00
460318257c Use expanding buttons layout for modifier box headers
Had to fix a crash in the alignment code for too small areas.
Also changed panel type flag defines to use an enum.
2020-04-17 16:36:16 +02:00
330300659c Remove redundant leading 'Bevel' header in Bevel Geometry sub-panel 2020-04-17 13:05:16 +02:00
bd5f7f7429 Bevel modifier: Group Profile and Custom Profile together 2020-04-17 10:17:49 +02:00
84eb739a0e Fix layout issue in Bevel modifier Limit Method 2020-04-17 07:13:12 +02:00
55a385620e Cleanup: Consistent code formatting 2020-04-16 17:33:34 -05:00
e46f4a7e45 Merge branch 'master' into modifier-panels-ui 2020-04-16 17:08:11 -05:00
ac943796d4 Draw list panels with box widget colors and code
This solves the transparency and theming issues by reusing the theming
from the box widget. This requires a new drawing function in order to
use box drawing with an opaque inner color, alpha blended with the
region's background color.
2020-04-16 17:04:22 -05:00
87ef42419d Minor tweaks to decimate modifier layout code
Should not have any visible impact.
2020-04-16 21:29:38 +02:00
66eee8ca6e Fix expanded enums using columns within split layout 2020-04-16 21:29:38 +02:00
187c65becb UI: Remove old hacks for dynamic scrollbar hiding
Although we still dynamically hide scrollbars, they don't change the
region size anymore. They are simply drawn on top of the region content.
Because of this, some hacks introduced by fa28e50ac2 are no longer
necessary.
Without these hacks, the scrollbar visibility is evaluated much more
often (cheap operation) which should be more reliable and possibly solve
some glitches.

Also replaces integers passed as booleans.

Fixes T75782.
2020-04-16 21:29:38 +02:00
bc252b3b1a Fix T75675: Unlinking [with setting users to zero] not clearing
LIB_TAG_EXTRAUSER_SET flag

For example in the Image Editor, an assert would be triggered after
unlinking an image [with setting users to zero] and then setting the
image for the Image Editor again.

Whenever we set an Image for Image Editor, the Image ID is flagged
LIB_TAG_EXTRAUSER_SET, when we unlink [with setting users to zero] this
flag was not cleared.

quote @mont29: "a proper fix would be to move this to modern code, and
actually delete the ID..." but that is for later.

Maniphest Tasks: T75675

Differential Revision: https://developer.blender.org/D7452
2020-04-16 21:29:38 +02:00
bdeb0c310b Fix T75680: Nodegroup user count increased when file saved in edit group mode.
This editor's code was a bit schizophrenic, some parts considering its
nodetree usages as real refcounted ones, others, as shallow 'user one'
ones...

Editors should not be real ID users anyway, unless there are *very* good
reasons for it, so swich it to fully 'shallow' usage now.
2020-04-16 21:29:38 +02:00
6b44e0e71a Fix T74964 Stereo 3D anaglyph and interlace not working
Caused by framebuffer initialized in the wrong context.
2020-04-16 21:29:38 +02:00
86309bd7f8 Fix Memory Leak in Shader Interface 2020-04-16 21:29:38 +02:00
04111faf67 Fix T75730: Properly remove unused override properties/operations.
While code is supposed to handle gracefully invalid override operations,
it is much cleaner to avoid those completely.
2020-04-16 21:29:38 +02:00
38031a4a24 Fix (unreported) crash on use-after-free in liboverride deletion code. 2020-04-16 21:29:38 +02:00
d83b93c1e1 Refactor/strengthen a bit invalid operands checks when applying an override operation. 2020-04-16 21:29:38 +02:00
df7407e451 Fix T75730: Crash on read of liboverride data when missing source modifier.
While this should not happen, we still want to handle those errors
gracefully from user perspective (i.e. assert for devs, no crash for
users).

Actual fix of root cause of the issue will come later.
2020-04-16 21:29:38 +02:00
Brecht Van Lommel
1d4411d1fd Fix T73977, T73825: ignore Python user site-packages directory by default
This goes along with the existing changes to ignore PYTHONPATH by default.
--python-use-system-env now controls both.

Differential Revision: https://developer.blender.org/D6962
2020-04-16 21:29:38 +02:00
16a350cd49 GPU: Fix Negative Shift
glAttributes also include `gl_` names. These don't have a location and
should be ignored during shader interface creation. Those internal names
received a location of -1 and therefore the bitmasking was undefined.

Users wouldn't notice this, but ASAN warned developers of this situation.
ASAN could quit making ASAN un-usable as most shaders have this issue.

Reviewed By: Clément Foucault`

Differential Revision: https://developer.blender.org/D7448
2020-04-16 21:29:38 +02:00
a22a7f78a4 Fix T75780: Gpencil Sculpt brushes not working with old files
The patching of brushes was not done.
2020-04-16 21:29:38 +02:00
47b85fb664 Fix T75785: "Extrude Faces Along Normals" throws error 2020-04-16 21:29:38 +02:00
e7fcfe7d64 Fix memcpy overlapping buffers
This crashes with ASAN enabled.
```
==39366==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x6230000ae848,0x6230000ae85a) and [0x6230000ae851, 0x6230000ae863) overlap
```
2020-04-16 21:29:38 +02:00
6fe7bb5754 UI: Move node socket icons to the left of node input buttons
Node input buttons (e.g. in the material properties) used to draw their
icons on the right of the buttons. However since they represent inputs,
it makes more sense conceptually to have them on the left.
Further, we might want to add the usual decorator buttons (to control
keyframes or display other states) to the material properties as well.
Having two circle icons next to each other would be confusing.

Differential Revision: https://developer.blender.org/D7409

Reviewed by: Brecht Van Lommel, William Reynish
2020-04-16 21:29:38 +02:00
5ede1bea5e UI: Draw real node sockets for node input buttons
For buttons representing node inputs (e.g. in the material properties)
rather than drawing some generic socket icon, the actual sockets are
drawn now. That includes color, shape and the selection outline.

This should make it easier to understand what these buttons relate to.

Screenshots: {F8469252}, {F8469248} (The left alignment will be done in
a follow-up commit.)

Differential Revision: https://developer.blender.org/D7409

Reviewed by: Brecht Van Lommel, Clément Foucault, William Reynish
2020-04-16 21:29:38 +02:00
cc24695be7 Cleanup: typo in comment 2020-04-16 21:28:08 +02:00
ce8808ec07 Cleanup: unused variable warning
Not needed since rB1685f5824d91.
2020-04-16 21:28:08 +02:00
b36e8b0d55 Fix (unreported) Image Editor UI drawing too dark
Caused by rBf0221ff6674f.

Only draw the Image buffer itself in display space.

Differential Revision: https://developer.blender.org/D7449
2020-04-16 21:28:08 +02:00
352b72791a Cleanup: Deduplicate getting node tree from id
Differential Revision: https://developer.blender.org/D7438

Reviewers: mont29
2020-04-16 21:28:08 +02:00
c9feac0afb Theme: adjust active UV face color in the theme
This color had it's alpha reduced in the drawing code,
as the active face is no longer stippled.

Now the color is used from the theme without adjusting the alpha.
2020-04-16 21:28:08 +02:00
77a8f89a50 UV: support changing the opacity of the UV overlay
Add this option as it's useful to adjust how much UV's
cover the image when UV mapping.

D5348 by @EitanSomething with edits
2020-04-16 21:28:08 +02:00
Jeroen Bakker
2909c0e56f GPUImmediate: Use 2 Buffers For (Un)Strict
We used to have a single buffer that was shared between strict and
unstrict draw calls. This leads to many recreation events for the draw
buffers. This patch separates the Unstrict draw buffer from the strict
draw buffer.

This improves performance on Windows Intel 10th gen platform.
On a reference platfor before the patch I got 10 FPS, after this patch
it became 34fps. Note that the same test normally on a low end GPU can
get to 60fps so this does not solve all teh bottlenecks yet.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D7421
2020-04-16 21:28:08 +02:00
Jeroen Bakker
02caa87e52 GPUViewport: Use GPUBatch for viewport drawing
When drawing the viewport to the screen the draw calls were not batched.
This resulted in measurable slowdown on Windows Intel 10th gen
platforms.

This patch would cache the last draw calls per viewport. Our API does
support partial redrawing of the viewport, but that isn't used anywhere.

This patch does not include stereoscopy rendering. This still uses the
imm approach and would still be slow on certain hardware.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D7357
2020-04-16 21:28:08 +02:00
4bbfa924ad Fix T75567: Paint Mode Wireframe Incorrect
The loop normal VBO is used in two manners. In edit mode to draw the
edge normals. And in paint mode to draw the wireframe. This commit
checks which VBO is needed and build the correct one.

This allows show the wireframe correct in paint mode, when the object is
subdivided.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D7419
2020-04-16 21:28:08 +02:00
7f9131bcc5 Fix T75455: High World Space Cavity Samples Crash
When setting the number of cavity samples to a high number blender could
write out of bounds.

This patch will harmonize the number of iterations in the same way how
it is done during execution.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D7425
2020-04-16 21:28:08 +02:00
4566f08679 Fix T75620: Lamp gizmo flips direction for negative scaled objects 2020-04-16 21:28:08 +02:00
25f854552e UI: disable shade flat/smooth in sculpt mode 2020-04-16 21:28:08 +02:00
c392903942 Object: only apply smooth/flat to the active object in paint modes
Also some minor improvements:

- Only run once per object data instance.
- Correction for mesh smooth flag being used on curves.
- Move curve operation into utility function.
2020-04-16 21:28:08 +02:00
01ef0eba9a Cleanup: remove unused scene argument 2020-04-16 21:28:08 +02:00
3679a1f601 Cleanup: use sections for object_edit.c 2020-04-16 21:28:08 +02:00
f8b6a2faad Logging: log warnings which had been disabled since 2.4x 2020-04-16 21:28:08 +02:00
062d7c8e96 Fix T75750 Image Editor: Rendered result is much brighter than in viewport 2020-04-16 21:28:08 +02:00
b05dadea6b Fix T75751 Overlay: Clipping Region crashes Blender 2020-04-16 21:28:08 +02:00
b39e9bfca0 Fix T75443 Color Management: Use after free crash when using curve mapping
The root cause is that viewport can draw cached version of themself but
the scene can have been updated and the pointed curvemapping could have
been freed.

To workaround this we just keep a copy of the curvemap at the viewport
level.
2020-04-16 21:28:08 +02:00
7a9aa8ad27 Mantaflow: Change Defaults to Improve Instantaneous Playback
- Change the default cache method to replay
- Change the default resolution to 32 (The same as old smoke)
  which have a speedup of about 4x (~4 FPS vs. ~16 FPS on initial 
playback)

Peformance was tested with 3700x and RTX 2070

Differential Revision: https://developer.blender.org/D6853

Fixes T73799
2020-04-16 21:28:08 +02:00
b2a4eb75ab Update RNA Manual References 2020-04-16 21:28:08 +02:00
202bdf1e99 Operator: Add 'dissolve_and_intersect' option for 'Extrude and Move on Normals'
This allows easy choice of operators when editing keymaps
2020-04-16 21:28:08 +02:00
57cbedf602 Cleanup: Remove unused operator 2020-04-16 21:28:08 +02:00
759da271df Cleanup: PEP8 for python changes 2020-04-16 21:28:08 +02:00
1e7e94588d Cleanup: PEP8 for python changes 2020-04-16 21:28:08 +02:00
00b45c3dce Don't use split layout for operator properties if all are checkboxes
Having a split layout looks broken if all items are checkboxes and there
is no heading text, because it only uses half the width then.
So this checks if all visible properties are booleans and if so,
disables the split layout. A bit hacky but this should generally work.
If needed we can add more control in future (e.g. default layout hints
for operators).
2020-04-16 21:28:08 +02:00
0af8fcee76 Support using property split for menu items & use for output FPS setting
We could add an extra parameter for the label string, for now we can
just use the headings. So if a layout heading is available (set and not
already added) use that to enable the split layout.
2020-04-16 21:28:08 +02:00
0dc1873477 UI: Draw real node sockets for node-input buttons and left-align them
Couple of reasons for this:
* Makes it easier to understand that and how these buttons map to nodes.
* These buttons represent node inputs, so it makes more sense to have the icons
  on the left.
* We'd like to show the usual decorators on the right, but having two circles
  for different purposes next to each other would be confusing.

Also respects the socket shape. So if a diamond shape is used for example, the
properties show that too.

I'm not sure if the previous icon textures were cached, either way this method
doesn't use the caching. So this adds a draw call for every socket icon which
is a bit annoying, but probably neglectable. Would be better if we'd use proper
icon textures or batches, but that's a separate change.

Differential Revision: https://developer.blender.org/D7409
2020-04-16 21:28:08 +02:00
17db2e69e9 Draw node socket icons in properties using real node socket shape/color 2020-04-16 21:28:08 +02:00
93f8363516 Fix wrong use of heading in Preferences 2020-04-16 21:28:08 +02:00
9ced07fa76 Use row headings and correct alignment for more Symmetry panels 2020-04-16 21:28:08 +02:00
c3475ebe61 Use column header for Armature Viewport Display panel. 2020-04-16 21:28:08 +02:00
e654a7d67f Fix error in previous commit
I unintentionally changed the size of checkboxes, should be back to the
old size now.
2020-04-16 21:28:08 +02:00
d191723756 Change padding around checkboxes
Two changes:
* Reduce padding between checkbox and text. That makes it clearer what
  the checkbox belongs to if there's also a column heading in front of
  the checkbox.
* Don't add padding on the left side of checkboxes. That makes them line
  up better with items above and below it.
2020-04-16 21:28:08 +02:00
c9fd25b070 Use row header for strip proxy resolutions 2020-04-16 21:28:08 +02:00
1ac55cad30 Use heading row for the Sequencer Flip X/Y controls 2020-04-16 21:28:08 +02:00
966431c2dc Use column header for Transform Affect Only toggles 2020-04-16 21:28:08 +02:00
5588497639 Fix error in prior commit 2020-04-16 21:28:08 +02:00
fbe9ee62cd Use new layout features throughout all Cycles properties 2020-04-16 21:28:08 +02:00
3e43c5f2cc Better alignment in Experimental Preferences 2020-04-16 21:28:07 +02:00
5b14027f54 Use checkbox+value for Sculpt Plane Trim & fix column headers 2020-04-16 21:28:07 +02:00
8383fc55d5 UI: Tweaks to modifier layouts
- Use checkbox + values configuration and expand 3-axis enums.
2020-04-16 21:15:34 +02:00
482334aa98 Various small tweaks to modifier layouts 2020-04-15 15:13:36 -05:00
7447c2ecaf Merge branch 'master' into modifier-panels-ui 2020-04-15 13:35:57 -05:00
d91078bb6e Merge branch 'master' into modifier-panels-ui 2020-04-15 13:19:03 -05:00
915fd3d088 Simplify Edge Split Modifier Layout 2020-04-15 09:47:44 -05:00
338232c294 Rename RECREATE panels to LIST panels 2020-04-15 09:15:59 -05:00
5eac872627 Use layout row with heading
Also use the new uiItemR flag to clear decorators
2020-04-14 17:25:21 -05:00
adad62e8d6 Add new options to solidify modifier
The subpanel organization might need to be rethought here, some of the
new items don't fit perfectly into the categories.
2020-04-14 16:54:08 -05:00
1035184c15 Merge branch 'master' into modifier-panels-ui 2020-04-14 15:36:03 -05:00
f3a2f735a2 Add margin and rounded corners to list panels
This helps differentiate them from regular panels and makes it clearer
that they are separate from each other.

Also added a list panel subpanel flag to avoid always searching parents to
see if a panel belongs to a list panel.
2020-04-14 15:29:37 -05:00
a284ac3213 Use PNL_ prefix for new panel type flags
This prefix should be changed, but it's best to be consistent for now
2020-04-13 15:00:53 -05:00
c128c65345 Tweaks to layout for many modifiers
Bevel: Move to two new panels
Data Transfer: Add advanced panel for rarely used inputs
Mesh Sequence Cache: Don't use useless subpanels
Mirror: Clip in main panel, data panel instead of UVs
Multires: Advanced panel and add missing properties
Normal Edit: Offset in subpanel
Simple Deform: Orientation panel to restrictions panel
Solidify: Add normals subpanel
Subdivision Surface: Add advanced subpanel
UVWarp: Add transform subpanel
Wave: use_x and use_y as toggles on the same row
Wireframe: Don't use split layout
2020-04-13 12:57:06 -05:00
cdb0449e91 Merge branch 'temp-checkbox-layout-tweaks' into modifier-panels-ui 2020-04-11 23:56:33 +02:00
7fb4010137 Option to insert blank dummy decorator for uiItemFullR
When there are multiple items in a property split row (e.g. mirror axes
in the mirror modifier) the decorator would only apply to the first
element. A dummy decorator could be inserted manually by using
`uiItemL_respect_property_split()`, but it's better to let the UI code
have an option for that, the case is common enough.
2020-04-11 23:50:43 +02:00
513de8eaf6 Mirror modifier: Avoid manual placement of dummy decorators for alignment
There's an option to let interface code do this now.
2020-04-11 23:45:12 +02:00
db06fd9a01 Fix use-after-free again 2020-04-11 23:43:31 +02:00
2c19926cc2 Merge branch 'temp-checkbox-layout-tweaks' into modifier-panels-ui 2020-04-11 23:00:47 +02:00
01900f5e6c Use row headings for sculpt symmetry options
Also removed redundant columns.
2020-04-11 22:59:17 +02:00
7714746e5c Support heading in row layouts too - uiLayout.row(heading="FOO") 2020-04-11 22:50:57 +02:00
ce54157417 Use property split layout for sculpt symmetry options
Meant as an example of how to do this with Python. Wasn't possible
without a broken layout until the previous commit.
2020-04-11 22:19:52 +02:00
d20886e98d Fix more cases of recursive property splitting
A bit hacky, but we have to disable the `use_property_split` flag for a
row after adding the split layout to prevent it from further splitting
when adding more items. If these new items actually add multiple buttons
(vector items), these should be placed in a column like before (by
accident?). E.g. that's how the translate buttons (a vector item) is
aligned with the lock icons (another vector item).
2020-04-11 22:19:52 +02:00
dfc62af147 Use column heading for Bevel tool settings 2020-04-11 17:03:27 +02:00
a8036cc2a1 Use checkbox+value for Text Editor 2020-04-11 17:03:03 +02:00
ac01b80221 Modifier UI: separate the Apply/Shape/Copy buttons visually from the modifier controls
Also make these items smaller, to de-emphasize them.
2020-04-11 14:40:05 +02:00
191a565600 Use checkbox+value configuration for Decimate modifier UI layout 2020-04-11 14:30:30 +02:00
1651a5e52c Revert mistake in Sculpt Symmetry panel 2020-04-11 10:58:29 +02:00
24dfb057bd Add checkbox+value configuration many places where applicable 2020-04-11 10:55:18 +02:00
2fecab55f9 Update Vertex Weight Edit modifier UI layout 2020-04-11 09:06:53 +02:00
50154a52cb Add UI for recently added bone properties 2020-04-10 14:57:58 -05:00
e60ad2867a Merge branch 'master' into modifier-panels-ui 2020-04-10 14:35:44 -05:00
4f5c607622 Resolve crash when switching to grease pencil object 2020-04-10 14:30:32 -05:00
31690ad463 Small tweaks to bevel modifier UI 2020-04-10 14:15:04 -05:00
0f95127d1a Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-10 12:57:33 -05:00
5bf61c9d74 Refactor saving and setting list panel expansion
The public functions are named more sanely and their requirements are
much simpler, with more of the logic handled internally by interface_panel.c.

Also solves a bug saving and loading sub-subpanel expansion.
2020-04-10 12:57:18 -05:00
26b9436975 Merge branch 'temp-checkbox-layout-tweaks' into modifier-panels-ui 2020-04-10 17:53:40 +02:00
61dafc1afb Fix pointer properties breaking column layouts 2020-04-10 17:52:48 +02:00
6fb4816956 Merge branch 'master' into temp-checkbox-layout-tweaks 2020-04-10 17:34:36 +02:00
0c927243d0 Resolve const warning for panel data reordering 2020-04-10 10:14:23 -05:00
5e0b359ac5 Merge branch 'master' into temp-checkbox-layout-tweaks 2020-04-10 15:09:00 +02:00
3b0f241e72 Use checkbox+value in split layout for mirror modifier UV offset
See previous commits.
Meant as an example for how this can be done in C.
2020-04-10 02:07:26 +02:00
5a33f291f4 Use checkbox+value in split layout for object bounds type
See previous commit.
Meant as an example for how this can be done in .py.
2020-04-10 02:03:44 +02:00
9d1c9e86c4 Support displaying single checkbox for a value in split layouts
Mockup: F7430498.

This is technically quite difficult to support, due to how we create the
split layouts for each item. With this commit, layout creators should be
able to do it, even though it involves some boilerplate code. The
followup commit will demonstrate how it can be done.
2020-04-10 02:03:44 +02:00
fc4d2d1e16 Use checkbox+value in split layout for object bounds type
See previous commit.
Meant as an example for how this can be done in .py.
2020-04-10 02:01:52 +02:00
f8347075d0 Support displaying single checkbox for a value in split layouts
Mockup: F7430498.

This is technically quite difficult to support, due to how we create the
split layouts for each item. With this commit, layout creators should be
able to do it, even though it involves some boilerplate code. The
followup commit will demonstrate how it can be done.
2020-04-10 02:01:09 +02:00
184dbb396d Merge branch 'master' into modifier-panels-ui 2020-04-09 16:15:23 -05:00
fb58cc8dc9 Revert "Add Modifier Apply Button Extras Menu"
This reverts commit 824f80a5d7.

After some discussion, it's clear this isn't really an improvement.
2020-04-09 12:23:39 -05:00
824f80a5d7 Add Modifier Apply Button Extras Menu
- Apply as shape key if supported
- Move up and down
Makes room for other convenient operations in the future too.
2020-04-09 11:59:55 -05:00
e4043bb908 Use simpler method to create split labels for toggles 2020-04-09 11:17:56 -05:00
40dbb7fc31 Boolean: Better layout for debug options 2020-04-09 09:12:53 -05:00
1974b5b903 Fix misalignment of items added with uiItemPointerR()
The split layout flag is changed in-between.
2020-04-09 15:41:31 +02:00
c5500b6af8 Merge branch 'temp-checkbox-layout-tweaks' into modifier-panels-ui 2020-04-09 15:37:33 +02:00
27717c5d0a Merge branch 'master' into temp-checkbox-layout-tweaks 2020-04-09 15:37:15 +02:00
bbeb31f4ce Trying new checkbox+value configuration for Mirror UVs 2020-04-09 14:16:44 +02:00
820350ac80 Fix layout when using uiItemFullR() after uiItemL_respect_property_split()
Also make the decorator layout as return value easier to understand.
2020-04-09 02:41:13 +02:00
18f1d80a6c Mirror modifier: Fix layout misalignments and simplify code
Meant as an example for changes to be applied everywhere.
2020-04-09 02:39:41 +02:00
4884d9cd52 Fix layout when using uiItemFullR() after uiItemL_respect_property_split()
Also make the decorator layout as return value easier to understand.
2020-04-09 02:36:19 +02:00
beeb650940 Merge branch 'master' into temp-checkbox-layout-tweaks 2020-04-09 01:49:23 +02:00
0dcc4fd780 Fix broken split layout for operator properties popups
Was creating multiple nested split layouts. `uiDefAutoButsRNA()` used to
do it's own layout splitting, that's redundant now, so I removed it.
2020-04-09 01:40:37 +02:00
6c655d6a50 Solidify UI checkbox layout update 2020-04-09 00:30:26 +02:00
014a575129 Image empty checkbox layout updates 2020-04-09 00:12:42 +02:00
7cca282052 Sequencer checkbox layout updates 2020-04-08 23:53:52 +02:00
1e889f2705 Sculpt & paint UI checkbox layout updates 2020-04-08 23:53:32 +02:00
45b6f746a3 Camera and Curve obdata properties layout updates 2020-04-08 23:19:48 +02:00
dd723f5f89 Change manually split layouts to 40% 2020-04-08 14:38:19 -05:00
8d2128009d Mask modifier layout
C++ needs workaround for including BKE_screen.h and a
PanelDrawFn definition.
2020-04-08 14:37:49 -05:00
bcf9daf155 Update Preferences and Physics UI layouts for new checkboxes 2020-04-08 20:45:30 +02:00
cdfd743c93 Update Mesh obdata properties 2020-04-08 19:40:21 +02:00
2692ec06d1 Data transfer modifier UI update 2020-04-08 11:48:10 -05:00
105b0b7f6a Object properties layout update 2020-04-08 18:10:07 +02:00
babb028b84 Fix debug mode crash adding and deleting modifier 2020-04-08 10:38:09 -05:00
1f669db7ae Cleanup: Doxygen secionts, rename re_order -> reorder 2020-04-08 10:38:09 -05:00
5071288adb Update View Layer properties layout 2020-04-08 17:34:30 +02:00
53a3e88175 Layout updates for Output Properties 2020-04-08 17:23:09 +02:00
f2792cff11 Use 40/50% properties split layout 2020-04-08 17:22:27 +02:00
63db01cd58 Bevel modifier layout update 2020-04-08 15:57:17 +02:00
2bae660703 Armature and Wave modifier UI updates 2020-04-08 15:52:26 +02:00
88ff68f011 UI: set the prop seperation divide to 40/60 2020-04-08 15:30:58 +02:00
5fc13d1112 Support multiple panels of the same type
The name for the uiBlock associated with a panel was just the panel type's
idname, so the old block found at the start of drawing was the same for
every panel of a certain type.

Panel blocks for list panels are now named with the list index appended
to the end of the name. The panel list is also rebuilt when reordering
panels of the same type.
2020-04-07 15:57:37 -05:00
274481620b Merge branch 'master' into modifier-panels-ui 2020-04-07 12:53:00 -05:00
98c289f5d8 Free panelsort panels from recreate list reordering 2020-04-07 11:54:03 -05:00
a5184a82cb Merge branch 'temp-checkbox-layout-tweaks' into modifier-panels-ui 2020-04-07 17:17:12 +02:00
e21fc05b35 Initial changes to checkbox layout: Use split layout & better section headings
See T65965.
Checkboxes now use the split layout as proposed in the design task and
columns can define headings now (`uiLayout.column(heading="Foo")`).
These headings are placed in the left column of the first item if that
doesn't add its own label there. Otherwise an own row is inserted for
the heading.
2020-04-07 17:08:37 +02:00
21a313eec2 Always add recreate list panels in the correct place.
This requires adding a start type in case we're adding the first
recreate panel.
2020-04-06 15:07:38 -05:00
50c747d234 Explode, Particle Instance modifier layouts 2020-04-06 11:08:58 -05:00
4e8532c145 Remove emboss around modifier remove button. 2020-04-06 12:55:08 +02:00
27a40b880e Remove modifier list for now 2020-04-05 22:02:06 -05:00
191ddaf577 New layouts for more modifiers
- Armature
- Corrective Smooth
- Laplacian Smooth
- Multiresolution
And progress for data transfer modifier
2020-04-05 21:38:18 -05:00
92541ba2ad Add remove button to modifier panel header
Also make sub-subpanels possible for datatransfer modifier layout
2020-04-05 21:35:55 -05:00
240fb4d8d1 Remove unused variables and leftover comments 2020-04-05 21:33:31 -05:00
e7458db4b4 Update UI layouts for Lattice, Mesh Deform, Shrinkwrap and Simple Deform modifiers 2020-04-05 23:32:47 +02:00
172ac7896b Updates to Skin, Subsurf and Wireframe modifier layouts 2020-04-05 22:59:08 +02:00
aed38c2207 Initial update to Bevel modifier layout 2020-04-05 20:26:02 +02:00
d9787141da Update Smooth modifier layout 2020-04-05 19:21:23 +02:00
3bd124d78e Update Warp modifier layout 2020-04-05 19:13:43 +02:00
b47e8c1b94 Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-05 11:48:27 -05:00
e19f83294a Cast modifier layout, no decorators for vgroup invert 2020-04-05 11:34:14 -05:00
29344fca44 Update Decimate, Solidify and Surface Deform layouts. 2020-04-05 18:17:19 +02:00
fb22ae2387 Initial 2.8 style layouts for more modifiers 2020-04-05 09:57:38 -05:00
23199693f9 Fix build error 2020-04-05 09:07:16 -05:00
2dc5d82ba8 Merge branch 'master' into modifier-panels-ui 2020-04-05 08:44:54 -05:00
d37df1a39d Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-04 19:30:03 -05:00
adb989768d First pass on 2.8 style UI for more modifers 2020-04-04 19:29:20 -05:00
fa9e1a5873 Modifier UI: Standardize naming and order of functions 2020-04-04 19:28:12 -05:00
f60d614c5f Fix use-after-free 2020-04-05 01:44:55 +02:00
42a030ccac Triangulate Modifier UI update 2020-04-04 13:27:31 -05:00
c0f481c7f2 Remove open parameter from subpanel register 2020-04-04 13:22:47 -05:00
2814a1316f Update Ocean, Remesh, Build modifier UI layouts 2020-04-04 13:22:13 -05:00
25f72d1d17 Screw modifier layout 2020-04-04 19:24:58 +02:00
c4672ff3a8 Array modifier layout 2020-04-04 17:35:33 +02:00
fce2c12ca6 Merge branch 'master' into modifier-panels-ui 2020-04-03 17:00:53 -05:00
b5233a4f74 Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-03 16:46:26 -05:00
4d5a9b7755 Tweak apply button, fix its location for a few modifiers 2020-04-03 16:46:04 -05:00
cd9a64b9c0 Merge branch 'modifier-panels-ui' of git.blender.org:blender into modifier-panels-ui 2020-04-03 16:35:28 -05:00
3d9af1de8d Ocean: move spectrum to subpanel 2020-04-03 16:17:48 -05:00
c0d187d434 UV Project and UV Warp panel layouts 2020-04-03 23:17:19 +02:00
d0ba75544a Miscellaneous cleanup 2020-04-03 16:17:16 -05:00
94f986edd4 Generalize recreate panel lists, add functionality
The recreate panel list concept should be MUCH easier to use
in different situations, as now it makes use of callbacks for any
modifier-specific functionality.

This commit also enables storing the panel expansion in modifiers
so it is remembered even when the panels are replaced.
2020-04-03 16:15:45 -05:00
ecfae8a55b Use 2.8-compliant layouts for some modifiers 2020-04-03 22:52:26 +02:00
4ac54cf6b0 Add apply / copy buttons
They're not working yet, but it's one possibility for
the location of these buttons.

Also make the order of statements in the panel_draw
functions more consistent.
2020-04-02 18:52:10 -05:00
3221187dd5 Add settings recently added to modifiers, tweak UI 2020-04-02 15:57:07 -05:00
f4d70b686d Re-order modifier mode settings for right align 2020-04-02 14:28:02 -05:00
2c5795618b Merge branch 'master' into modifier-panels-ui 2020-04-02 12:59:25 -05:00
0b75c41afe Cleanup: Remove print statements and comment 2020-04-02 12:57:28 -05:00
5699058e54 Drag and drop modifiers from panels
When the panel animation finishes, a new move modifier to index
operator is called, reordering the modifier stack. Then on the next
draw, the panel types mismatch and the stack is redrawn (or new
indices are set if the types match).
2020-04-02 12:56:33 -05:00
8b073594d9 Don't lower the active modifier index past 0 2020-04-02 10:50:06 -05:00
932f974532 Fix panel header drawing
- Use the preset callback to draw the modifier mode buttons.
- Don't draw empty panel label strings.
2020-04-02 09:57:57 -05:00
8709a46e96 Add modifier move to index API function 2020-04-01 14:04:04 -05:00
270b3d1a04 Small tweaks to modifier panels 2020-04-01 13:58:00 -05:00
6e7873e54a Implement panels for remaining modifiers 2020-04-01 11:41:05 -05:00
042fab271f Implement 13 more modifier panels 2020-03-31 17:31:41 -05:00
2d20d11b01 Merge branch 'master' into modifier-panels-ui 2020-03-31 12:11:29 -05:00
249c5663d8 Implement more modifier panels
Alphabetically to MOD_screw.c
2020-03-31 12:10:10 -05:00
bdabb02ee6 Implement panels for more modifiers
UI layouts WIP
2020-03-30 19:49:40 -05:00
520b7b2887 Rename panel to panelRegister 2020-03-30 16:01:02 -05:00
bd307afbbe Merge branch 'master' into modifier-panels-ui 2020-03-30 15:51:21 -05:00
2374237762 Only rebuild panels when modifier list changes
Benefits of this:
- Epanding and collapsing modifier panels works
- Efficiency
- Solves other handler crashes

Also renamed modifier_index to list_index for more generality
2020-03-30 15:49:51 -05:00
b5ec14af68 Remove unecessary changes 2020-03-30 15:24:00 -05:00
f0e7dba4ff Fix more build errors, remove old property from UI
Test before pushing...
2020-03-28 00:35:49 -05:00
802be17ce7 Fix build error (typo) 2020-03-28 00:29:47 -05:00
4f4f08cee4 Add commented out C drawing code for modifiers.
Left over from an earlier patch, this layout drawing code still
needs to be converted to be panels.
2020-03-27 23:29:54 -05:00
51ea1eea48 Use a panel based UI to draw modifiers
Currently an interface template creates a RECREATE panel for each
modifier, which is then drawn with the rest of the panels. The python
 based modifier drawing is removed.

 This also adds a UIList and the idea of an active modifier, along with
 object operations to add and move it.
2020-03-27 23:28:33 -05:00
68c96b8bb2 Add a modifier callback to register UI panels
The modifier UI is defined in each modifier file. This commit only
implements the callback for a few modifiers, with work in progress UI.

New common UI functions handle the common parts of registering panels
and retrieving modifier pointers from them.
2020-03-27 23:18:08 -05:00
a8bb0af673 Add a RECREATE panel type
Panels built from types with this flag don't have a 1 to 1 correspondence
with their types-- there can be many panels built from a single type. That
can be used to tie each panel to a modifier instead.
2020-03-27 23:07:06 -05:00
61 changed files with 3807 additions and 1413 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -46,13 +46,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
bl_label = "Modifiers"
def check_conflicts(self, layout, ob):
for md in ob.grease_pencil_modifiers:
if md.type == 'GP_TIME':
row = layout.row()
row.label(text="Build and Time Offset modifier not compatible", icon='ERROR')
break
@classmethod
def poll(cls, context):
ob = context.object
@@ -60,483 +53,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
ob = context.object
layout.operator_menu_enum("object.gpencil_modifier_add", "type")
for md in ob.grease_pencil_modifiers:
box = layout.template_greasepencil_modifier(md)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, md.type)(box, ob, md)
# the mt.type enum is (ab)used for a lookup on function names
# ...to avoid lengthy if statements
# so each type must have a function here.
def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False):
gpd = ob.data
layout.separator()
layout.label(text="Influence Filters:")
split = layout.split(factor=0.25)
col1 = split.column()
col1.label(text="Layer:")
col1.label(text="Material:")
if use_vertex:
col1.label(text="Vertex Group:")
col2 = split.column()
split = col2.split(factor=0.6)
row = split.row(align=True)
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
row = split.row(align=True)
row.prop(md, "layer_pass", text="Pass")
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
split = col2.split(factor=0.6)
row = split.row(align=True)
valid = md.material in (slot.material for slot in ob.material_slots) or md.material is None
if valid:
icon = 'SHADING_TEXTURE'
else:
icon = 'ERROR'
row.alert = not valid
row.prop_search(md, "material", gpd, "materials", text="", icon=icon)
row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
row = split.row(align=True)
row.prop(md, "pass_index", text="Pass")
row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
if use_vertex:
row = col2.row(align=True)
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
if use_curve:
col = layout.column()
col.separator()
col.prop(md, "use_custom_curve")
if md.use_custom_curve:
col.template_curve_mapping(md, "curve")
def GP_NOISE(self, layout, ob, md):
split = layout.split()
col = split.column()
row = col.row(align=True)
row.prop(md, "factor", text="Position")
row = col.row(align=True)
row.prop(md, "factor_strength", text="Strength")
row = col.row(align=True)
row.prop(md, "factor_thickness", text="Thickness")
row = col.row(align=True)
row.prop(md, "factor_uvs", text="UV")
col.separator()
row = col.row(align=True)
row.prop(md, "random", text="", icon='TIME', toggle=True)
subrow = row.row(align=True)
subrow.enabled = md.random
subrow.prop(md, "step")
subrow.prop(md, "seed")
col.separator()
col.prop(md, "noise_scale")
self.gpencil_masking(layout, ob, md, True, True)
def GP_SMOOTH(self, layout, ob, md):
col = layout.column()
col.prop(md, "factor")
col.prop(md, "step", text="Repeat")
col.label(text="Affect:")
row = col.row(align=True)
row.prop(md, "use_edit_position", text="Position", toggle=True)
row.prop(md, "use_edit_strength", text="Strength", toggle=True)
row.prop(md, "use_edit_thickness", text="Thickness", toggle=True)
row.prop(md, "use_edit_uv", text="UV", toggle=True)
self.gpencil_masking(layout, ob, md, True, True)
def GP_SUBDIV(self, layout, ob, md):
layout.row().prop(md, "subdivision_type", expand=True)
split = layout.split()
col = split.column()
row = col.row(align=True)
row.prop(md, "level", text="Subdivisions")
self.gpencil_masking(layout, ob, md, False)
def GP_SIMPLIFY(self, layout, ob, md):
gpd = ob.data
row = layout.row()
row.prop(md, "mode")
split = layout.split()
col = split.column()
col.label(text="Settings:")
if md.mode == 'FIXED':
col.prop(md, "step")
elif md.mode == 'ADAPTIVE':
col.prop(md, "factor")
elif md.mode == 'SAMPLE':
col.prop(md, "length")
elif md.mode == 'MERGE':
col.prop(md, "distance")
self.gpencil_masking(layout, ob, md, False)
def GP_THICK(self, layout, ob, md):
col = layout.column()
col.prop(md, "normalize_thickness")
if md.normalize_thickness:
col.prop(md, "thickness")
else:
col.prop(md, "thickness_factor")
self.gpencil_masking(layout, ob, md, True, True)
def GP_TEXTURE(self, layout, ob, md):
col = layout.column()
col.prop(md, "mode")
if md.mode in {'STROKE', 'STROKE_AND_FILL'}:
col.label(text="Stroke Texture:")
col.prop(md, "fit_method")
col.prop(md, "uv_offset")
col.prop(md, "uv_scale")
if md.mode == 'STROKE_AND_FILL':
col.separator()
if md.mode in {'FILL', 'STROKE_AND_FILL'}:
col.label(text="Fill Texture:")
col.prop(md, "fill_rotation", text="Rotation")
col.prop(md, "fill_offset", text="Location")
col.prop(md, "fill_scale", text="Scale")
self.gpencil_masking(layout, ob, md, True)
def GP_TINT(self, layout, ob, md):
layout.row().prop(md, "tint_type", expand=True)
if md.tint_type == 'UNIFORM':
col = layout.column()
col.prop(md, "color")
col.separator()
col.prop(md, "factor")
if md.tint_type == 'GRADIENT':
col = layout.column()
col.label(text="Colors:")
col.template_color_ramp(md, "colors")
col.separator()
col.label(text="Object:")
col.prop(md, "object", text="")
col.separator()
row = col.row(align=True)
row.prop(md, "radius")
row.prop(md, "factor")
col.separator()
col.prop(md, "vertex_mode")
self.gpencil_masking(layout, ob, md, True, True)
def GP_TIME(self, layout, ob, md):
gpd = ob.data
row = layout.row()
row.prop(md, "mode", text="Mode")
row = layout.row()
if md.mode == 'FIX':
txt = "Frame"
else:
txt = "Frame Offset"
row.prop(md, "offset", text=txt)
row = layout.row()
row.enabled = md.mode != 'FIX'
row.prop(md, "frame_scale")
row = layout.row()
row.separator()
row = layout.row()
row.enabled = md.mode != 'FIX'
row.prop(md, "use_custom_frame_range")
row = layout.row(align=True)
row.enabled = md.mode != 'FIX' and md.use_custom_frame_range is True
row.prop(md, "frame_start")
row.prop(md, "frame_end")
row = layout.row()
row.enabled = md.mode != 'FIX'
row.prop(md, "use_keep_loop")
row = layout.row()
row.label(text="Layer:")
row = layout.row(align=True)
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
row = layout.row(align=True)
row.prop(md, "layer_pass", text="Pass")
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
def GP_COLOR(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Color:")
col.prop(md, "hue", text="H", slider=True)
col.prop(md, "saturation", text="S", slider=True)
col.prop(md, "value", text="V", slider=True)
row = layout.row()
row.prop(md, "modify_color")
self.gpencil_masking(layout, ob, md, False, True)
def GP_OPACITY(self, layout, ob, md):
split = layout.split()
col = split.column()
col.prop(md, "modify_color")
if md.modify_color == 'HARDNESS':
col.prop(md, "hardness")
show = False
else:
col.prop(md, "normalize_opacity")
if md.normalize_opacity is True:
text="Strength"
else:
text="Opacity Factor"
col.prop(md, "factor", text=text)
show = True
self.gpencil_masking(layout, ob, md, show, show)
def GP_ARRAY(self, layout, ob, md):
col = layout.column()
col.prop(md, "count")
split = layout.split()
col = split.column()
col.prop(md, "use_constant_offset", text="Constant Offset")
subcol = col.column()
subcol.enabled = md.use_constant_offset
subcol.prop(md, "constant_offset", text="")
col.prop(md, "use_object_offset")
subcol = col.column()
subcol.enabled = md.use_object_offset
subcol.prop(md, "offset_object", text="")
col = split.column()
col.prop(md, "use_relative_offset", text="Relative Offset")
subcol = col.column()
subcol.enabled = md.use_relative_offset
subcol.prop(md, "relative_offset", text="")
split = layout.split()
col = split.column()
col.label(text="Random Offset:")
col.prop(md, "random_offset", text="")
col = split.column()
col.label(text="Random Rotation:")
col.prop(md, "random_rotation", text="")
col = split.column()
col.label(text="Random Scale:")
col.prop(md, "random_scale", text="")
col = layout.column()
col.prop(md, "seed")
col.separator()
col.prop(md, "replace_material", text="Material Override")
self.gpencil_masking(layout, ob, md, False)
def GP_BUILD(self, layout, ob, md):
gpd = ob.data
split = layout.split()
col = split.column()
self.check_conflicts(col, ob)
col.prop(md, "mode")
if md.mode == 'CONCURRENT':
col.prop(md, "concurrent_time_alignment")
col.separator()
col.prop(md, "transition")
sub = col.column(align=True)
sub.prop(md, "start_delay")
sub.prop(md, "length")
col = layout.column(align=True)
col.prop(md, "use_restrict_frame_range")
sub = col.column(align=True)
sub.active = md.use_restrict_frame_range
sub.prop(md, "frame_start", text="Start")
sub.prop(md, "frame_end", text="End")
col.prop(md, "use_percentage")
sub = col.column(align=True)
sub.active = md.use_percentage
sub.prop(md, "percentage_factor")
layout.label(text="Influence Filters:")
split = layout.split(factor=0.25)
col1 = split.column()
col1.label(text="Layer:")
col2 = split.column()
split = col2.split(factor=0.6)
row = split.row(align=True)
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
row = split.row(align=True)
row.prop(md, "layer_pass", text="Pass")
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
def GP_LATTICE(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
layout.prop(md, "strength", slider=True)
self.gpencil_masking(layout, ob, md, True)
def GP_MIRROR(self, layout, ob, md):
row = layout.row(align=True)
row.prop(md, "x_axis")
row.prop(md, "y_axis")
row.prop(md, "z_axis")
layout.label(text="Mirror Object:")
layout.prop(md, "object", text="")
self.gpencil_masking(layout, ob, md, False)
def GP_HOOK(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
if md.object and md.object.type == 'ARMATURE':
col.label(text="Bone:")
col.prop_search(md, "subtarget", md.object.data, "bones", text="")
use_falloff = (md.falloff_type != 'NONE')
layout.separator()
row = layout.row(align=True)
if use_falloff:
row.prop(md, "falloff_radius")
row.prop(md, "strength", slider=True)
layout.prop(md, "falloff_type")
col = layout.column()
if use_falloff:
if md.falloff_type == 'CURVE':
col.template_curve_mapping(md, "falloff_curve")
split = layout.split()
col = split.column()
col.prop(md, "use_falloff_uniform")
self.gpencil_masking(layout, ob, md, True)
def GP_OFFSET(self, layout, ob, md):
split = layout.split()
split.column().prop(md, "location")
split.column().prop(md, "rotation")
split.column().prop(md, "scale")
self.gpencil_masking(layout, ob, md, True)
def GP_ARMATURE(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
# col.prop(md, "use_deform_preserve_volume")
col = split.column()
col.label(text="Bind To:")
col.prop(md, "use_vertex_groups", text="Vertex Groups")
col.prop(md, "use_bone_envelopes", text="Bone Envelopes")
layout.separator()
row = layout.row(align=True)
row.label(text="Vertex Group:")
row = layout.row(align=True)
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
sub = row.row(align=True)
sub.active = bool(md.vertex_group)
sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
def GP_MULTIPLY(self, layout, ob, md):
col = layout.column()
col.prop(md, "duplicates")
subcol = col.column()
subcol.enabled = md.duplicates > 0
subcol.prop(md, "distance")
subcol.prop(md, "offset", slider=True)
subcol.separator()
subcol.prop(md, "use_fade")
if md.use_fade:
subcol.prop(md, "fading_center")
subcol.prop(md, "fading_thickness", slider=True)
subcol.prop(md, "fading_opacity", slider=True)
self.gpencil_masking(layout, ob, md, False)
layout.template_grease_pencil_modifiers()
classes = (

View File

@@ -24,11 +24,11 @@ class ShaderFxButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "shaderfx"
bl_options = {'HIDE_HEADER'}
class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
bl_label = "Effects"
bl_options = {'HIDE_HEADER'}
# Unused: always show for now.
@@ -39,122 +39,8 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
ob = context.object
layout.operator_menu_enum("object.shaderfx_add", "type")
for fx in ob.shader_effects:
box = layout.template_shaderfx(fx)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, fx.type)(box, fx)
# the mt.type enum is (ab)used for a lookup on function names
# ...to avoid lengthy if statements
# so each type must have a function here.
def FX_BLUR(self, layout, fx):
layout.prop(fx, "use_dof_mode", text="Use Depth of Field")
layout.separator()
col = layout.column()
col.enabled = not fx.use_dof_mode
col.prop(fx, "size", text="Size")
col.separator()
col.prop(fx, "rotation")
layout.prop(fx, "samples", text="Samples")
def FX_COLORIZE(self, layout, fx):
layout.prop(fx, "mode", text="Mode")
if fx.mode == 'DUOTONE':
layout.prop(fx, "low_color", text="Low Color")
if fx.mode == 'CUSTOM':
layout.prop(fx, "low_color", text="Color")
if fx.mode == 'DUOTONE':
layout.prop(fx, "high_color", text="High Color")
layout.prop(fx, "factor")
def FX_WAVE(self, layout, fx):
row = layout.row(align=True)
row.prop(fx, "orientation", expand=True)
layout.separator()
layout.prop(fx, "amplitude")
layout.prop(fx, "period")
layout.prop(fx, "phase")
def FX_PIXEL(self, layout, fx):
layout.prop(fx, "size", text="Size")
def FX_RIM(self, layout, fx):
layout.prop(fx, "offset", text="Offset")
layout.prop(fx, "rim_color")
layout.prop(fx, "mask_color")
layout.prop(fx, "mode", text="Blend")
layout.prop(fx, "blur")
layout.prop(fx, "samples")
def FX_SHADOW(self, layout, fx):
layout.prop(fx, "offset", text="Offset")
layout.prop(fx, "shadow_color")
layout.prop(fx, "scale")
layout.prop(fx, "rotation")
layout.separator()
layout.prop(fx, "blur")
layout.prop(fx, "samples")
layout.separator()
layout.prop(fx, "use_object", text="Use Object as Pivot")
if fx.use_object:
row = layout.row()
row.prop(fx, "object", text="Object")
layout.separator()
layout.prop(fx, "use_wave", text="Use Wave Effect")
if fx.use_wave is True:
row = layout.row(align=True)
row.prop(fx, "orientation", expand=True)
layout.prop(fx, "amplitude")
layout.prop(fx, "period")
layout.prop(fx, "phase")
def FX_GLOW(self, layout, fx):
layout.prop(fx, "mode")
if fx.mode == 'LUMINANCE':
layout.prop(fx, "threshold")
else:
layout.prop(fx, "select_color")
layout.prop(fx, "glow_color")
layout.separator()
layout.prop(fx, "blend_mode", text="Blend")
layout.prop(fx, "opacity")
layout.prop(fx, "size")
layout.prop(fx, "rotation")
layout.prop(fx, "samples")
layout.prop(fx, "use_glow_under", text="Glow Under")
def FX_SWIRL(self, layout, fx):
layout.prop(fx, "object", text="Object")
layout.prop(fx, "radius")
layout.prop(fx, "angle")
def FX_FLIP(self, layout, fx):
layout.prop(fx, "flip_horizontal")
layout.prop(fx, "flip_vertical")
layout.template_shaderfx()
classes = (

View File

@@ -38,6 +38,9 @@ struct bPoseChannel;
extern "C" {
#endif
/** For building the panel UI for constraints. */
#define CONSTRAINT_TYPE_PANEL_PREFIX "OBJECT_PT_"
/* special struct for use in constraint evaluation */
typedef struct bConstraintOb {
/** to get evaluated armature. */
@@ -136,6 +139,8 @@ typedef struct bConstraintTypeInfo {
const bConstraintTypeInfo *BKE_constraint_typeinfo_get(struct bConstraint *con);
const bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type);
void BKE_constraint_panel_id(int type, char *r_name);
/* ---------------------------------------------------------------------------- */
/* Constraint function prototypes */

View File

@@ -20,12 +20,14 @@
* \ingroup bke
*/
#include "BLI_compiler_attrs.h"
#include "DNA_gpencil_modifier_types.h" /* needed for all enum typdefs */
#ifdef __cplusplus
extern "C" {
#endif
struct ARegionType;
struct Depsgraph;
struct GpencilModifierData;
struct ID;
@@ -255,11 +257,17 @@ typedef struct GpencilModifierTypeInfo {
struct Object *ob,
GreasePencilTexWalkFunc walk,
void *userData);
/* Register the panel types for the modifier's UI. */
void (*panelRegister)(struct ARegionType *region_type);
} GpencilModifierTypeInfo;
#define GPENCIL_MODIFIER_TYPE_PANEL_PREFIX "MOD_PT_gpencil_"
/* Initialize modifier's global data (type info and some common global storages). */
void BKE_gpencil_modifier_init(void);
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname);
const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType type);
struct GpencilModifierData *BKE_gpencil_modifier_new(int type);
void BKE_gpencil_modifier_free_ex(struct GpencilModifierData *md, const int flag);
@@ -276,6 +284,8 @@ void BKE_gpencil_modifier_copydata(struct GpencilModifierData *md,
void BKE_gpencil_modifier_copydata_ex(struct GpencilModifierData *md,
struct GpencilModifierData *target,
const int flag);
void BKE_gpencil_modifier_set_error(struct GpencilModifierData *md, const char *format, ...)
ATTR_PRINTF_FORMAT(2, 3);
void BKE_gpencil_modifiers_foreach_ID_link(struct Object *ob,
GreasePencilIDWalkFunc walk,
void *userData);

View File

@@ -28,6 +28,7 @@
extern "C" {
#endif
struct ARegionType;
struct ID;
struct ListBase;
struct ModifierUpdateDepsgraphContext;
@@ -157,11 +158,17 @@ typedef struct ShaderFxTypeInfo {
struct Object *ob,
ShaderFxIDWalkFunc walk,
void *userData);
/* Register the panel types for the effect's UI. */
void (*panelRegister)(struct ARegionType *region_type);
} ShaderFxTypeInfo;
#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
/* Initialize global data (type info and some common global storages). */
void BKE_shaderfx_init(void);
void BKE_shaderfxType_panel_id(ShaderFxType type, char *panel_id);
const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type);
struct ShaderFxData *BKE_shaderfx_new(int type);
void BKE_shaderfx_free_ex(struct ShaderFxData *fx, const int flag);

View File

@@ -5288,6 +5288,20 @@ const bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type)
return NULL;
}
/**
* Get the idname of the constraint type's panel, which was defined elsewhere.
*
* \note: Constraint panel types are assumed to be named with the struct name field concatenated to
* the defined prefix.
*/
void BKE_constraint_panel_id(int type, char *r_idname)
{
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(type);
strcpy(r_idname, CONSTRAINT_TYPE_PANEL_PREFIX);
strcat(r_idname, cti->structName);
}
/* This function should always be used to get the appropriate type-info, as it
* has checks which prevent segfaults in some weird cases.
*/
@@ -5412,9 +5426,14 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
/* Set up a generic constraint data-block. */
con->type = type;
con->flag |= CONSTRAINT_EXPAND | CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
con->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
con->ui_expand_flag = 1; /* Only expand the parent panel by default. */
con->enforce = 1.0f;
/* Only open the main panel when constraints are created, not the subpanels.
* Note: This can be overriden for individual constraint types. */
con->ui_expand_flag = 1;
/* Determine a basic name, and info */
if (cti) {
/* initialize constraint data */

View File

@@ -53,6 +53,9 @@
#include "MOD_gpencil_modifiertypes.h"
#include "CLG_log.h"
static CLG_LogRef LOG = {"bke.modifier"};
static GpencilModifierTypeInfo *modifier_gpencil_types[NUM_GREASEPENCIL_MODIFIER_TYPES] = {NULL};
/* *************************************************** */
@@ -428,9 +431,9 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
md->type = type;
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render |
eGpencilModifierMode_Expanded;
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render;
md->flag = eGpencilModifierFlag_OverrideLibrary_Local;
md->ui_expand_flag = 1; /* Only expand the parent panel at first. */
if (mti->flags & eGpencilModifierTypeFlag_EnableInEditmode) {
md->mode |= eGpencilModifierMode_Editmode;
@@ -508,7 +511,8 @@ bool BKE_gpencil_modifier_depends_ontime(GpencilModifierData *md)
const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType type)
{
/* type unsigned, no need to check < 0 */
if (type < NUM_GREASEPENCIL_MODIFIER_TYPES && modifier_gpencil_types[type]->name[0] != '\0') {
if (type < NUM_GREASEPENCIL_MODIFIER_TYPES && type > 0 &&
modifier_gpencil_types[type]->name[0] != '\0') {
return modifier_gpencil_types[type];
}
else {
@@ -516,6 +520,17 @@ const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType
}
}
/**
* Get the idname of the modifier type's panel, which was defined in the #panelRegister callback.
*/
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname)
{
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(type);
strcpy(r_idname, GPENCIL_MODIFIER_TYPE_PANEL_PREFIX);
strcat(r_idname, mti->name);
}
void BKE_gpencil_modifier_copydata_generic(const GpencilModifierData *md_src,
GpencilModifierData *md_dst)
{
@@ -553,6 +568,7 @@ void BKE_gpencil_modifier_copydata_ex(GpencilModifierData *md,
target->mode = md->mode;
target->flag = md->flag;
target->ui_expand_flag = md->ui_expand_flag; /* Expand the parent panel by default. */
if (mti->copyData) {
mti->copyData(md, target);
@@ -587,6 +603,26 @@ GpencilModifierData *BKE_gpencil_modifiers_findby_type(Object *ob, GpencilModifi
return md;
}
void BKE_gpencil_modifier_set_error(GpencilModifierData *md, const char *_format, ...)
{
char buffer[512];
va_list ap;
const char *format = TIP_(_format);
va_start(ap, _format);
vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
buffer[sizeof(buffer) - 1] = '\0';
if (md->error) {
MEM_freeN(md->error);
}
md->error = BLI_strdup(buffer);
CLOG_STR_ERROR(&LOG, md->error);
}
void BKE_gpencil_modifiers_foreach_ID_link(Object *ob, GreasePencilIDWalkFunc walk, void *userData)
{
GpencilModifierData *md = ob->greasepencil_modifiers.first;

View File

@@ -82,8 +82,9 @@ ShaderFxData *BKE_shaderfx_new(int type)
BLI_strncpy(fx->name, DATA_(fxi->name), sizeof(fx->name));
fx->type = type;
fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render | eShaderFxMode_Expanded;
fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render;
fx->flag = eShaderFxFlag_OverrideLibrary_Local;
fx->ui_expand_flag = 1; /* Expand only the parent panel by default. */
if (fxi->flags & eShaderFxTypeFlag_EnableInEditmode) {
fx->mode |= eShaderFxMode_Editmode;
@@ -156,7 +157,7 @@ bool BKE_shaderfx_depends_ontime(ShaderFxData *fx)
const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type)
{
/* type unsigned, no need to check < 0 */
if (type < NUM_SHADER_FX_TYPES && shader_fx_types[type]->name[0] != '\0') {
if (type < NUM_SHADER_FX_TYPES && type > 0 && shader_fx_types[type]->name[0] != '\0') {
return shader_fx_types[type];
}
else {
@@ -164,6 +165,20 @@ const ShaderFxTypeInfo *BKE_shaderfx_get_info(ShaderFxType type)
}
}
/**
* Get an effect's panel type, which was defined in the #panelRegister callback.
*
* \note: ShaderFx panel types are assumed to be named with the struct name field concatenated to
* the defined prefix.
*/
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
{
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(type);
strcpy(r_idname, SHADERFX_TYPE_PANEL_PREFIX);
strcat(r_idname, fxi->name);
}
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
{
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx_src->type);
@@ -198,6 +213,7 @@ void BKE_shaderfx_copydata_ex(ShaderFxData *fx, ShaderFxData *target, const int
target->mode = fx->mode;
target->flag = fx->flag;
target->ui_expand_flag = fx->ui_expand_flag;
if (fxi->copyData) {
fxi->copyData(fx, target);

View File

@@ -24,6 +24,7 @@
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
#include "DNA_constraint_types.h"
#include "DNA_genfile.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_modifier_types.h"
@@ -267,6 +268,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Keep this block, even when empty. */
/* Transition to saving expansion for all of a modifier's subpanels. */
if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
@@ -279,5 +281,33 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
/* Transition to saving expansion for all of a constraint's subpanels. */
if (!DNA_struct_elem_find(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
LISTBASE_FOREACH (bConstraint *, con, &object->constraints) {
if (con->flag & CONSTRAINT_EXPAND_DEPRECATED) {
con->ui_expand_flag = 1;
}
else {
con->ui_expand_flag = 0;
}
}
}
}
/* Transition to saving expansion for all of grease pencil modifier's subpanels. */
if (!DNA_struct_elem_find(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) {
if (md->mode & eGpencilModifierMode_Expanded_DEPRECATED) {
md->ui_expand_flag = 1;
}
else {
md->ui_expand_flag = 0;
}
}
}
}
}
}

View File

@@ -1318,7 +1318,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
else {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
if ((cti && cti->get_constraint_targets) && (curcon->flag & CONSTRAINT_EXPAND)) {
if ((cti && cti->get_constraint_targets) && (curcon->ui_expand_flag)) {
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;

View File

@@ -425,6 +425,10 @@ int ED_object_gpencil_modifier_move_down(struct ReportList *reports,
int ED_object_gpencil_modifier_move_up(struct ReportList *reports,
struct Object *ob,
struct GpencilModifierData *md);
bool ED_object_gpencil_modifier_move_to_index(struct ReportList *reports,
struct Object *ob,
struct GpencilModifierData *md,
const int index);
int ED_object_gpencil_modifier_apply(struct Main *bmain,
struct ReportList *reports,
struct Depsgraph *depsgraph,
@@ -453,6 +457,10 @@ int ED_object_shaderfx_move_down(struct ReportList *reports,
int ED_object_shaderfx_move_up(struct ReportList *reports,
struct Object *ob,
struct ShaderFxData *fx);
bool ED_object_shaderfx_move_to_index(struct ReportList *reports,
struct Object *ob,
struct ShaderFxData *fx,
const int index);
/* object_select.c */
void ED_object_select_linked_by_id(struct bContext *C, struct ID *id);

View File

@@ -2003,6 +2003,10 @@ void uiTemplatePathBuilder(uiLayout *layout,
struct PointerRNA *root_ptr,
const char *text);
void uiTemplateModifiers(uiLayout *layout, struct bContext *C);
void uiTemplateGpencilModifiers(uiLayout *layout, struct bContext *C);
void uiTemplateConstraints(uiLayout *layout, struct bContext *C);
void uiTemplateShaderFx(uiLayout *layout, struct bContext *C);
uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
void uiTemplateGpencilColorPreview(uiLayout *layout,
struct bContext *C,
@@ -2013,11 +2017,9 @@ void uiTemplateGpencilColorPreview(uiLayout *layout,
float scale,
int filter);
uiLayout *uiTemplateShaderFx(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C);
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplateConstraintHeader(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplatePreview(uiLayout *layout,
struct bContext *C,
struct ID *id,

View File

@@ -1851,7 +1851,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti->panelRegister) {
char panel_idname[MAX_NAME];
modifier_panel_id(md, panel_idname);
modifier_panel_id((void *)md, panel_idname);
Panel *new_panel = UI_panel_add_instanced(sa, region, &region->panels, panel_idname, i);
if (new_panel != NULL) {
@@ -1872,268 +1872,185 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Grease Pencil Modifier Template
/** \name Grease Pencil Modifiers Template
*
* Template for building the panel layout for the active object's modifiers.
* \{ */
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
static uiLayout *gpencil_draw_modifier(uiLayout *layout, Object *ob, GpencilModifierData *md)
/**
* Function with void * argument for #uiListPanelIDFromDataFunc.
*/
static void gpencil_modifier_panel_id(void *md_link, char *r_name)
{
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
PointerRNA ptr;
uiBlock *block;
uiLayout *box, *column, *row, *sub;
uiLayout *result = NULL;
/* create RNA pointer */
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
column = uiLayoutColumn(layout, true);
uiLayoutSetContextPointer(column, "modifier", &ptr);
/* rounded header ------------------------------------------------------------------- */
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* Open/Close ................................. */
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
/* modifier-type icon */
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
UI_block_emboss_set(block, UI_EMBOSS);
/* modifier name */
if (mti->isDisabled && mti->isDisabled(md, 0)) {
uiLayoutSetRedAlert(row, true);
}
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
uiLayoutSetRedAlert(row, false);
/* mode enabling buttons */
UI_block_align_begin(block);
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) {
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, false);
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
UI_block_align_end(block);
/* Up/Down + Delete ........................... */
UI_block_align_begin(block);
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_gpencil_modifier_move_up");
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_gpencil_modifier_move_down");
UI_block_align_end(block);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemO(row, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove");
UI_block_emboss_set(block, UI_EMBOSS);
/* modifier settings (under the header) --------------------------------------------------- */
if (md->mode & eGpencilModifierMode_Expanded) {
/* apply/convert/copy */
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
/* only here obdata, the rest of modifiers is ob level */
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
sub = uiLayoutRow(row, false);
if (mti->flags & eGpencilModifierTypeFlag_NoApply) {
uiLayoutSetEnabled(sub, false);
}
uiItemEnumO(sub,
"OBJECT_OT_gpencil_modifier_apply",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
0,
"apply_as",
MODIFIER_APPLY_DATA);
UI_block_lock_clear(block);
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
uiItemO(row,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"),
ICON_NONE,
"OBJECT_OT_gpencil_modifier_copy");
/* result is the layout block inside the box,
* that we return so that modifier settings can be drawn */
result = uiLayoutColumn(box, false);
block = uiLayoutAbsoluteBlock(box);
}
/* error messages */
if (md->error) {
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
uiItemL(row, md->error, ICON_ERROR);
}
return result;
ModifierData *md = (ModifierData *)md_link;
BKE_gpencil_modifierType_panel_id(md->type, r_name);
}
uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
{
Object *ob;
GpencilModifierData *md, *vmd;
int i;
ScrArea *sa = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
ListBase *modifiers = &ob->greasepencil_modifiers;
/* verify we have valid data */
if (!RNA_struct_is_a(ptr->type, &RNA_GpencilModifier)) {
RNA_warning("Expected modifier on object");
return NULL;
}
bool panels_match = UI_panel_list_matches_data(region, modifiers, gpencil_modifier_panel_id);
ob = (Object *)ptr->owner_id;
md = ptr->data;
if (!panels_match) {
UI_panels_free_instanced(C, region);
GpencilModifierData *md = modifiers->first;
for (int i = 0; md; i++, md = md->next) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
if (mti->panelRegister) {
char panel_idname[MAX_NAME];
gpencil_modifier_panel_id(md, panel_idname);
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected modifier on object");
return NULL;
}
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
/* find modifier and draw it */
vmd = ob->greasepencil_modifiers.first;
for (i = 0; vmd; i++, vmd = vmd->next) {
if (md == vmd) {
return gpencil_draw_modifier(layout, ob, md);
Panel *new_panel = UI_panel_add_instanced(sa, region, &region->panels, panel_idname, i);
if (new_panel != NULL) {
UI_panel_set_expand_from_list_data(C, new_panel);
}
}
}
}
return NULL;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Grease Pencil Shader FX Template
/** \name Constraints Template
*
* Template for building the panel layout for the active object or bone's constraints.
* \{ */
static uiLayout *gpencil_draw_shaderfx(uiLayout *layout, Object *ob, ShaderFxData *md)
/**
* Move a constraint to the index it's moved to after a drag and drop.
*/
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
{
const ShaderFxTypeInfo *mti = BKE_shaderfx_get_info(md->type);
PointerRNA ptr;
uiBlock *block;
uiLayout *box, *column, *row, *sub;
uiLayout *result = NULL;
/* create RNA pointer */
RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, &ptr);
column = uiLayoutColumn(layout, true);
uiLayoutSetContextPointer(column, "shaderfx", &ptr);
/* rounded header ------------------------------------------------------------------- */
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(row);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* Open/Close ................................. */
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
/* shader-type icon */
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
UI_block_emboss_set(block, UI_EMBOSS);
/* effect name */
if (mti->isDisabled && mti->isDisabled(md, 0)) {
uiLayoutSetRedAlert(row, true);
}
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
uiLayoutSetRedAlert(row, false);
/* mode enabling buttons */
UI_block_align_begin(block);
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
if (mti->flags & eShaderFxTypeFlag_SupportsEditmode) {
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, false);
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
UI_block_align_end(block);
/* Up/Down + Delete ........................... */
UI_block_align_begin(block);
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_shaderfx_move_up");
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_shaderfx_move_down");
UI_block_align_end(block);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemO(row, "", ICON_X, "OBJECT_OT_shaderfx_remove");
UI_block_emboss_set(block, UI_EMBOSS);
/* effect settings (under the header) --------------------------------------------------- */
if (md->mode & eShaderFxMode_Expanded) {
/* apply/convert/copy */
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
/* only here obdata, the rest of effect is ob level */
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
/* result is the layout block inside the box,
* that we return so that effect settings can be drawn */
result = uiLayoutColumn(box, false);
block = uiLayoutAbsoluteBlock(box);
}
/* error messages */
if (md->error) {
box = uiLayoutBox(column);
row = uiLayoutRow(box, false);
uiItemL(row, md->error, ICON_ERROR);
}
return result;
}
uiLayout *uiTemplateShaderFx(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
Object *ob;
ShaderFxData *fx, *vfx;
int i;
/* verify we have valid data */
if (!RNA_struct_is_a(ptr->type, &RNA_ShaderFx)) {
RNA_warning("Expected shader fx on object");
return NULL;
}
ob = (Object *)ptr->owner_id;
fx = ptr->data;
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected shader fx on object");
return NULL;
}
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
/* find modifier and draw it */
vfx = ob->shader_fx.first;
for (i = 0; vfx; i++, vfx = vfx->next) {
if (fx == vfx) {
return gpencil_draw_shaderfx(layout, ob, fx);
Object *ob = CTX_data_active_object(C);
ListBase *lb = ED_object_constraint_list_from_context(ob);
bool constraint_from_bone = false;
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
pchan = BKE_pose_channel_active(ob);
if (pchan) {
constraint_from_bone = true;
}
}
return NULL;
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
PointerRNA props_ptr;
wmOperatorType *ot = WM_operatortype_find("CONSTRAINT_OT_move_to_index", false);
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "constraint", con->name);
RNA_int_set(&props_ptr, "index", new_index);
/* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */
RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
WM_operator_properties_free(&props_ptr);
}
/**
* Get the expand flag from the active constraint to use for the panel.
*/
static short get_constraint_expand_flag(const bContext *C, Panel *panel)
{
Object *ob = CTX_data_active_object(C);
ListBase *lb = ED_object_constraint_list_from_context(ob);
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
return con->ui_expand_flag;
}
/**
* Save the expand flag for the panel and subpanels to the constraint.
*/
static void set_constraint_expand_flag(const bContext *C, Panel *panel, short expand_flag)
{
Object *ob = CTX_data_active_object(C);
ListBase *lb = ED_object_constraint_list_from_context(ob);
bConstraint *con = BLI_findlink(lb, panel->runtime.list_index);
con->ui_expand_flag = expand_flag;
}
static void constraint_panel_id(void *md_link, char *r_name)
{
bConstraint *con = (bConstraint *)md_link;
BKE_constraint_panel_id(con->type, r_name);
}
/**
* Check if the constraint panels don't match the data and rebuild the panels if so.
*/
void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
ListBase *constraints = ED_object_constraint_list_from_context(ob);
bool panels_match = UI_panel_list_matches_data(region, constraints, constraint_panel_id);
if (!panels_match) {
UI_panels_free_instanced(C, region);
bConstraint *con = constraints->first;
for (int i = 0; con; i++, con = con->next) {
char panel_idname[MAX_NAME];
constraint_panel_id(con, panel_idname);
Panel *new_panel = UI_panel_add_instanced(sa, region, &region->panels, panel_idname, i);
if (new_panel) {
/* Set the list panel functionality function pointers since we don't do it with python. */
new_panel->type->set_list_data_expand_flag = set_constraint_expand_flag;
new_panel->type->get_list_data_expand_flag = get_constraint_expand_flag;
new_panel->type->reorder = constraint_reorder;
UI_panel_set_expand_from_list_data(C, new_panel);
}
}
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name ShaderFx Template
*
* Template for building the panel layout for the active object's grease pencil shader effects.
* \{ */
/**
* Function with void * argument for #uiListPanelIDFromDataFunc.
*/
static void shaderfx_panel_id(void *fx_v, char *r_idname)
{
ShaderFxData *fx = (ShaderFxData *)fx_v;
BKE_shaderfxType_panel_id(fx->type, r_idname);
}
/**
* Check if the shader effect panels don't match the data and rebuild the panels if so.
*/
void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
ListBase *shaderfx = &ob->shader_fx;
bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id);
if (!panels_match) {
UI_panels_free_instanced(C, region);
ShaderFxData *fx = shaderfx->first;
for (int i = 0; fx; i++, fx = fx->next) {
char panel_idname[MAX_NAME];
shaderfx_panel_id(fx, panel_idname);
Panel *new_panel = UI_panel_add_instanced(sa, region, &region->panels, panel_idname, i);
if (new_panel != NULL) {
UI_panel_set_expand_from_list_data(C, new_panel);
}
}
}
}
/** \} */
@@ -2442,18 +2359,19 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
/** \name Constraint Template
* \{ */
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
{
ED_object_constraint_active_set(ob_v, con_v);
}
/* draw panel showing settings for a constraint */
static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *con)
{
bPoseChannel *pchan = BKE_pose_channel_active(ob);
const bConstraintTypeInfo *cti;
uiBlock *block;
uiLayout *result = NULL, *col, *box, *row;
uiLayout *sub;
PointerRNA ptr;
char typestr[32];
short proxy_protected, xco = 0, yco = 0;
@@ -2485,36 +2403,23 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
col = uiLayoutColumn(layout, true);
uiLayoutSetContextPointer(col, "constraint", &ptr);
box = uiLayoutBox(col);
row = uiLayoutRow(box, false);
block = uiLayoutGetBlock(box);
/* Draw constraint header */
/* open/close */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
uiLayoutSetContextPointer(layout, "constraint", &ptr);
/* constraint-type icon */
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
sub = uiLayoutRow(layout, false);
uiLayoutSetEmboss(sub, false);
uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE));
uiItemL(sub, "", RNA_struct_ui_icon(ptr.type));
UI_block_emboss_set(block, UI_EMBOSS);
if (con->flag & CONSTRAINT_DISABLE) {
uiLayoutSetRedAlert(row, true);
}
if (proxy_protected == 0) {
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
uiItemR(layout, &ptr, "name", 0, "", ICON_NONE);
}
else {
uiItemL(row, con->name, ICON_NONE);
uiItemL(layout, con->name, ICON_NONE);
}
uiLayoutSetRedAlert(row, false);
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
if (proxy_protected) {
UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -2553,54 +2458,20 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
UI_block_emboss_set(block, UI_EMBOSS);
}
else {
short prev_proxylock, show_upbut, show_downbut;
/* Up/Down buttons:
* Proxy-constraints are not allowed to occur after local (non-proxy) constraints
* as that poses problems when restoring them, so disable the "up" button where
* it may cause this situation.
*
* Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose.
*/
if (BKE_constraints_proxylocked_owner(ob, pchan)) {
if (con->prev) {
prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
}
else {
prev_proxylock = 0;
}
}
else {
prev_proxylock = 0;
}
show_upbut = ((prev_proxylock == 0) && (con->prev));
show_downbut = (con->next) ? 1 : 0;
/* enabled */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemR(row, &ptr, "mute", 0, "", 0);
uiItemR(layout, &ptr, "mute", 0, "", 0);
UI_block_emboss_set(block, UI_EMBOSS);
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
/* up/down */
if (show_upbut || show_downbut) {
UI_block_align_begin(block);
if (show_upbut) {
uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
}
if (show_downbut) {
uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
}
UI_block_align_end(block);
}
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
UI_block_emboss_set(block, UI_EMBOSS_NONE);
uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete");
uiItemO(layout, "", ICON_X, "CONSTRAINT_OT_delete");
UI_block_emboss_set(block, UI_EMBOSS);
/* Some extra padding at the end, so 'x' icon isn't too close to drag button. */
uiItemS(layout);
}
/* Set but-locks for protected settings (magic numbers are used here!) */
@@ -2608,23 +2479,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
UI_block_lock_set(block, true, TIP_("Cannot edit Proxy-Protected Constraint"));
}
/* Draw constraint data */
if ((con->flag & CONSTRAINT_EXPAND) == 0) {
(yco) -= 10.5f * UI_UNIT_Y;
}
else {
box = uiLayoutBox(col);
block = uiLayoutAbsoluteBlock(box);
result = box;
}
/* clear any locks set up for proxies/lib-linking */
UI_block_lock_clear(block);
return result;
}
uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
void uiTemplateConstraintHeader(uiLayout *layout, PointerRNA *ptr)
{
Object *ob;
bConstraint *con;
@@ -2632,7 +2491,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
/* verify we have valid data */
if (!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
RNA_warning("Expected constraint on object");
return NULL;
return;
}
ob = (Object *)ptr->owner_id;
@@ -2640,7 +2499,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected constraint on object");
return NULL;
return;
}
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
@@ -2649,11 +2508,11 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
if (data->flag & CONSTRAINT_IK_TEMP) {
return NULL;
return;
}
}
return draw_constraint(layout, ob, con);
draw_constraint_header(layout, ob, con);
}
/** \} */

View File

@@ -1556,6 +1556,76 @@ void CONSTRAINT_OT_move_up(wmOperatorType *ot)
/** \} */
/* ------------------------------------------------------------------- */
/** \name Move Constraint To Index Operator
* \{ */
static int constraint_move_to_index_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
int new_index = RNA_int_get(op->ptr, "index");
if (new_index < 0) {
new_index = 0;
}
if (con) {
ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL);
int current_index = BLI_findindex(conlist, con);
BLI_assert(current_index >= 0);
BLI_listbase_link_move(conlist, con, new_index - current_index);
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
}
static int constraint_move_to_index_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
if (edit_constraint_invoke_properties(C, op)) {
return constraint_move_to_index_exec(C, op);
}
else {
return OPERATOR_CANCELLED;
}
}
void CONSTRAINT_OT_move_to_index(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Move Constraint To Index";
ot->idname = "CONSTRAINT_OT_move_to_index";
ot->description =
"Change the constraint's index in the list so it evaluates after the set number of others";
/* callbacks */
ot->exec = constraint_move_to_index_exec;
ot->invoke = constraint_move_to_index_invoke;
ot->poll = edit_constraint_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
RNA_def_int(ot->srna,
"index",
0,
0,
INT_MAX,
"Index",
"The index to move the constraint to",
0,
INT_MAX);
}
/** \} */
/* ------------------------------------------------------------------- */
/** \name Clear Pose Constraints Operator
* \{ */

View File

@@ -211,6 +211,40 @@ int ED_object_gpencil_modifier_move_down(ReportList *UNUSED(reports),
return 1;
}
bool ED_object_gpencil_modifier_move_to_index(ReportList *reports,
Object *ob,
GpencilModifierData *md,
const int index)
{
BLI_assert(md != NULL);
BLI_assert(index >= 0);
if (index >= BLI_listbase_count(&ob->greasepencil_modifiers)) {
BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the stack");
return false;
}
int md_index = BLI_findindex(&ob->greasepencil_modifiers, md);
BLI_assert(md_index != -1);
if (md_index < index) {
/* Move modifier down in list. */
for (; md_index < index; md_index++) {
if (!ED_object_gpencil_modifier_move_down(reports, ob, md)) {
break;
}
}
}
else {
/* Move modifier up in list. */
for (; md_index > index; md_index--) {
if (!ED_object_gpencil_modifier_move_up(reports, ob, md)) {
break;
}
}
}
return true;
}
static int gpencil_modifier_apply_obdata(
ReportList *reports, Main *bmain, Depsgraph *depsgraph, Object *ob, GpencilModifierData *md)
{
@@ -596,6 +630,58 @@ void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot)
gpencil_edit_modifier_properties(ot);
}
/* ************************* Move to Index Gpencil Modifier Operator ************************* */
static bool gpencil_modifier_move_to_index_poll(bContext *C)
{
return gpencil_edit_modifier_poll(C);
}
static int gpencil_modifier_move_to_index_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
int index = RNA_int_get(op->ptr, "index");
if (!ED_object_gpencil_modifier_move_to_index(op->reports, ob, md, index)) {
return OPERATOR_CANCELLED;
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
static int gpencil_modifier_move_to_index_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_move_to_index_exec(C, op);
}
else {
return OPERATOR_CANCELLED;
}
}
void OBJECT_OT_gpencil_modifier_move_to_index(wmOperatorType *ot)
{
ot->name = "Move Active Modifier to Index";
ot->description = "Move the active modifier to an index in the stack";
ot->idname = "OBJECT_OT_gpencil_modifier_move_to_index";
ot->invoke = gpencil_modifier_move_to_index_invoke;
ot->exec = gpencil_modifier_move_to_index_exec;
ot->poll = gpencil_modifier_move_to_index_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_modifier_properties(ot);
RNA_def_int(
ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the modifier to", 0, INT_MAX);
}
/************************ apply modifier operator *********************/
static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)

View File

@@ -190,6 +190,7 @@ void OBJECT_OT_gpencil_modifier_add(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_remove(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_move_up(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_move_down(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_move_to_index(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_apply(struct wmOperatorType *ot);
void OBJECT_OT_gpencil_modifier_copy(struct wmOperatorType *ot);
@@ -198,6 +199,7 @@ void OBJECT_OT_shaderfx_add(struct wmOperatorType *ot);
void OBJECT_OT_shaderfx_remove(struct wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_up(struct wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_down(struct wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_to_index(struct wmOperatorType *ot);
/* object_constraint.c */
void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
@@ -218,6 +220,7 @@ void CONSTRAINT_OT_delete(struct wmOperatorType *ot);
void CONSTRAINT_OT_move_up(struct wmOperatorType *ot);
void CONSTRAINT_OT_move_down(struct wmOperatorType *ot);
void CONSTRAINT_OT_move_to_index(struct wmOperatorType *ot);
void CONSTRAINT_OT_stretchto_reset(struct wmOperatorType *ot);
void CONSTRAINT_OT_limitdistance_reset(struct wmOperatorType *ot);

View File

@@ -152,6 +152,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_gpencil_modifier_remove);
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_up);
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_down);
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_to_index);
WM_operatortype_append(OBJECT_OT_gpencil_modifier_apply);
WM_operatortype_append(OBJECT_OT_gpencil_modifier_copy);
@@ -160,6 +161,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_shaderfx_remove);
WM_operatortype_append(OBJECT_OT_shaderfx_move_up);
WM_operatortype_append(OBJECT_OT_shaderfx_move_down);
WM_operatortype_append(OBJECT_OT_shaderfx_move_to_index);
WM_operatortype_append(OBJECT_OT_correctivesmooth_bind);
WM_operatortype_append(OBJECT_OT_meshdeform_bind);
@@ -178,6 +180,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(POSE_OT_ik_clear);
WM_operatortype_append(CONSTRAINT_OT_delete);
WM_operatortype_append(CONSTRAINT_OT_move_up);
WM_operatortype_append(CONSTRAINT_OT_move_to_index);
WM_operatortype_append(CONSTRAINT_OT_move_down);
WM_operatortype_append(CONSTRAINT_OT_stretchto_reset);
WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset);

View File

@@ -200,6 +200,41 @@ int ED_object_shaderfx_move_down(ReportList *UNUSED(reports), Object *ob, Shader
return 1;
}
bool ED_object_shaderfx_move_to_index(ReportList *reports,
Object *ob,
ShaderFxData *fx,
const int index)
{
BLI_assert(fx != NULL);
BLI_assert(index >= 0);
if (index >= BLI_listbase_count(&ob->greasepencil_modifiers)) {
BKE_report(reports, RPT_WARNING, "Cannot move effect beyond the end of the stack");
return false;
}
int fx_index = BLI_findindex(&ob->shader_fx, fx);
printf("moving fx at %d to %d\n", fx_index, index);
BLI_assert(fx_index != -1);
if (fx_index < index) {
/* Move shaderfx down in list. */
for (; fx_index < index; fx_index++) {
if (!ED_object_shaderfx_move_up(reports, ob, fx)) {
break;
}
}
}
else {
/* Move shaderfx up in list. */
for (; fx_index > index; fx_index--) {
if (!ED_object_shaderfx_move_down(reports, ob, fx)) {
break;
}
}
}
return true;
}
/************************ add effect operator *********************/
static int shaderfx_add_exec(bContext *C, wmOperator *op)
@@ -487,3 +522,53 @@ void OBJECT_OT_shaderfx_move_down(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_shaderfx_properties(ot);
}
/************************ move shaderfx to index operator *********************/
static bool shaderfx_move_to_index_poll(bContext *C)
{
return edit_shaderfx_poll_generic(C, &RNA_ShaderFx, 0);
}
static int shaderfx_move_to_index_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
int index = RNA_int_get(op->ptr, "index");
if (!fx || !ED_object_shaderfx_move_to_index(op->reports, ob, fx, index)) {
return OPERATOR_CANCELLED;
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
static int shaderfx_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_move_to_index_exec(C, op);
}
else {
return OPERATOR_CANCELLED;
}
}
void OBJECT_OT_shaderfx_move_to_index(wmOperatorType *ot)
{
ot->name = "Move Effect to Index";
ot->description = "Move shaderfx to an index in the stack";
ot->idname = "OBJECT_OT_shaderfx_move_to_index";
ot->invoke = shaderfx_move_to_index_invoke;
ot->exec = shaderfx_move_to_index_exec;
ot->poll = shaderfx_move_to_index_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
edit_shaderfx_properties(ot);
RNA_def_int(
ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the effect to", 0, INT_MAX);
}

View File

@@ -30,10 +30,10 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_gpencil_modifier.h" /* Types for registering panels. */
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DNA_modifier_types.h"
#include "BKE_shader_fx.h"
#include "ED_screen.h"
#include "ED_space_api.h"
@@ -643,6 +643,21 @@ void ED_spacetype_buttons(void)
mti->panelRegister(art);
}
}
for (int i = 0; i < NUM_GREASEPENCIL_MODIFIER_TYPES; i++) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(i);
if (mti != NULL && mti->panelRegister != NULL) {
mti->panelRegister(art);
}
}
for (int i = 0; i < NUM_SHADER_FX_TYPES; i++) {
if (i == eShaderFxType_Light_deprecated) {
continue;
}
const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(i);
if (fxti != NULL && fxti->panelRegister != NULL) {
fxti->panelRegister(art);
}
}
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");

View File

@@ -25,11 +25,14 @@ set(INC
../blenfont
../blenkernel
../blenlib
../blentranslation
../bmesh
../depsgraph
../editors/include
../makesdna
../makesrna
../render/extern/include
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
)
@@ -40,6 +43,7 @@ set(INC_SYS
set(SRC
intern/MOD_gpencil_util.h
intern/MOD_gpencil_ui_common.c
intern/MOD_gpencil_util.c
intern/MOD_gpencilarmature.c
@@ -61,6 +65,7 @@ set(SRC
intern/MOD_gpenciltime.c
intern/MOD_gpenciltint.c
intern/MOD_gpencil_ui_common.h
MOD_gpencil_modifiertypes.h
)

View File

@@ -0,0 +1,413 @@
/* 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.
*/
/** \file
* \ingroup modifiers
*/
#include <string.h>
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "BKE_context.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_material.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "ED_object.h"
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
#include "MOD_gpencil_ui_common.h" /* Self include */
static Object *get_gpencilmodifier_object(const bContext *C)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) {
return (Object *)sbuts->pinid;
}
else {
return CTX_data_active_object(C);
}
}
/**
* Poll function so these modifier panels only show for grease pencil objects.
*/
static bool gpencil_modifier_ui_poll(const bContext *C, PanelType *UNUSED(pt))
{
Object *ob = get_gpencilmodifier_object(C);
return (ob != NULL) && (ob->type == OB_GPENCIL);
}
/* -------------------------------------------------------------------- */
/** \name Panel Drag and Drop, Expansion Saving
* \{ */
/**
* Move a modifier to the index it's moved to after a drag and drop.
*/
static void gpencil_modifier_reorder(bContext *C, Panel *panel, int new_index)
{
Object *ob = get_gpencilmodifier_object(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
PointerRNA props_ptr;
wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_gpencil_modifier_move_to_index", false);
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "modifier", md->name);
RNA_int_set(&props_ptr, "index", new_index);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
WM_operator_properties_free(&props_ptr);
}
static short get_gpencil_modifier_expand_flag(const bContext *C, Panel *panel)
{
Object *ob = get_gpencilmodifier_object(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
return md->ui_expand_flag;
return 0;
}
static void set_gpencil_modifier_expand_flag(const bContext *C, Panel *panel, short expand_flag)
{
Object *ob = get_gpencilmodifier_object(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
md->ui_expand_flag = expand_flag;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Modifier Panel Layouts
* \{ */
void gpencil_modifier_masking_panel_draw(const bContext *C,
Panel *panel,
bool use_material,
bool use_vertex)
{
uiLayout *row, *col, *sub;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
bool has_layer = RNA_string_length(&ptr, "layer") != 0;
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, true);
row = uiLayoutRow(col, true);
uiItemPointerR(row, &ptr, "layer", &obj_data_ptr, "layers", NULL, ICON_GREASEPENCIL);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_layer);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_layers", 0, "", ICON_ARROW_LEFTRIGHT);
row = uiLayoutRow(col, true);
uiItemR(row, &ptr, "layer_pass", 0, NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, RNA_int_get(&ptr, "layer_pass") != 0);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_layer_pass", 0, "", ICON_ARROW_LEFTRIGHT);
if (use_material) {
PointerRNA material_ptr = RNA_pointer_get(&ptr, "material");
bool has_material = !RNA_pointer_is_null(&material_ptr);
/* Because the Gpencil modifier material property used to be a string in an earlier version of
* Blender, we need to check if the material is valid and display it differently if so. */
bool valid = false;
{
if (!has_material) {
valid = true;
}
else {
Material *current_material = material_ptr.data;
Object *ob = ob_ptr.data;
for (int i = 0; i <= ob->totcol; i++) {
Material *mat = BKE_object_material_get(ob, i);
if (mat == current_material) {
valid = true;
break;
}
}
}
}
col = uiLayoutColumn(layout, true);
row = uiLayoutRow(col, true);
uiLayoutSetRedAlert(row, !valid);
uiItemPointerR(row,
&ptr,
"material",
&obj_data_ptr,
"materials",
NULL,
valid ? ICON_SHADING_TEXTURE : ICON_ERROR);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_material);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_materials", 0, "", ICON_ARROW_LEFTRIGHT);
row = uiLayoutRow(col, true);
uiItemR(row, &ptr, "pass_index", 0, NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, RNA_int_get(&ptr, "pass_index") != 0);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_material_pass", 0, "", ICON_ARROW_LEFTRIGHT);
}
if (use_vertex) {
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
row = uiLayoutRow(layout, true);
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_vertex_group);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
}
}
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_custom_curve", 0, NULL, ICON_NONE);
}
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiTemplateCurveMapping(layout, &ptr, "curve", 0, false, false, false, false);
}
/**
* Draw modifier error message.
*/
void gpencil_modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
{
GpencilModifierData *md = ptr->data;
if (md->error) {
uiLayout *row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_(md->error), ICON_ERROR);
}
}
/**
* Gets RNA pointers for the active object and the panel's modifier data.
*/
#define ERROR_LIBDATA_MESSAGE TIP_("External library data")
void gpencil_modifier_panel_get_property_pointers(const bContext *C,
Panel *panel,
PointerRNA *r_ob_ptr,
PointerRNA *r_md_ptr)
{
Object *ob = get_gpencilmodifier_object(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, r_md_ptr);
if (r_ob_ptr != NULL) {
RNA_pointer_create(&ob->id, &RNA_Object, ob, r_ob_ptr);
}
uiBlock *block = uiLayoutGetBlock(panel->layout);
UI_block_lock_clear(block);
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
uiLayoutSetContextPointer(panel->layout, "modifier", r_md_ptr);
}
static void gpencil_modifier_ops_extra_draw(bContext *UNUSED(C), uiLayout *layout, void *md_v)
{
GpencilModifierData *md = (GpencilModifierData *)md_v;
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
if (!(mti->flags & eGpencilModifierTypeFlag_NoApply)) {
uiItemEnumO(layout,
"OBJECT_OT_gpencil_modifier_apply",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
0,
"apply_as",
MODIFIER_APPLY_DATA);
}
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"),
ICON_DUPLICATE,
"OBJECT_OT_gpencil_modifier_copy");
uiItemO(layout,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete"),
ICON_X,
"OBJECT_OT_gpencil_modifier_remove");
}
static void gpencil_modifier_panel_header(const bContext *C, Panel *panel)
{
uiLayout *row, *sub;
uiLayout *layout = panel->layout;
Object *ob = get_gpencilmodifier_object(C);
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
PointerRNA ptr;
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
uiLayoutSetContextPointer(panel->layout, "modifier", &ptr);
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
bool narrow_panel = (panel->sizex < UI_UNIT_X * 8 && panel->sizex != 0);
/* Modifier Icon. */
row = uiLayoutRow(layout, false);
if (mti->isDisabled && mti->isDisabled(md, 0)) {
uiLayoutSetRedAlert(row, true);
}
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
/* Modifier Name. */
if (!narrow_panel) {
uiItemR(layout, &ptr, "name", 0, "", ICON_NONE);
}
row = uiLayoutRow(layout, true);
if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) {
sub = uiLayoutRow(row, true);
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemMenuF(row, "", ICON_DOWNARROW_HLT, gpencil_modifier_ops_extra_draw, md);
/* Some extra padding at the end, so 'x' icon isn't too close to drag button. */
uiItemS(layout);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Modifier Registration Helpers
* \{ */
/**
* Create a panel in the context's region
*/
PanelType *gpencil_modifier_panel_register(ARegionType *region_type,
GpencilModifierType type,
PanelDrawFn draw)
{
/* Get the name for the modifier's panel. */
char panel_idname[BKE_ST_MAXNAME];
BKE_gpencil_modifierType_panel_id(type, panel_idname);
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
strcpy(panel_type->idname, panel_idname);
strcpy(panel_type->label, "");
strcpy(panel_type->context, "modifier");
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
panel_type->draw_header = gpencil_modifier_panel_header;
panel_type->draw = draw;
panel_type->poll = gpencil_modifier_ui_poll;
/* Give the panel the special flag that says it was built here and corresponds to a
* modifer rather than a PanelType. */
panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
panel_type->reorder = gpencil_modifier_reorder;
panel_type->get_list_data_expand_flag = get_gpencil_modifier_expand_flag;
panel_type->set_list_data_expand_flag = set_gpencil_modifier_expand_flag;
BLI_addtail(&region_type->paneltypes, panel_type);
return panel_type;
}
/**
* Add a child panel to the parent.
*
* \note To create the panel type's idname, it appends the \a name argument to the \a parent's
* idname.
*/
PanelType *gpencil_modifier_subpanel_register(ARegionType *region_type,
const char *name,
const char *label,
PanelDrawFn draw_header,
PanelDrawFn draw,
PanelType *parent)
{
/* Create the subpanel's ID name. */
char panel_idname[BKE_ST_MAXNAME];
strcpy(panel_idname, parent->idname);
strcat(panel_idname, "_");
strcat(panel_idname, name);
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
strcpy(panel_type->idname, panel_idname);
strcpy(panel_type->label, label);
strcpy(panel_type->context, "modifier");
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = gpencil_modifier_ui_poll;
panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
BLI_assert(parent != NULL);
strcpy(panel_type->parent_id, parent->idname);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
return panel_type;
}
/** \} */

View File

@@ -0,0 +1,66 @@
/*
* 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.
*/
/** \file
* \ingroup modifiers
*/
#ifndef __MOD_UI_COMMON__GPENCIL_H__
#define __MOD_UI_COMMON__GPENCIL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "MOD_gpencil_modifiertypes.h"
struct ARegionType;
struct bContext;
struct PanelType;
struct uiLayout;
typedef void (*PanelDrawFn)(const bContext *, Panel *);
void gpencil_modifier_masking_panel_draw(const bContext *C,
Panel *panel,
bool use_material,
bool use_vertex);
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel);
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel);
void gpencil_modifier_panel_end(struct uiLayout *layout, PointerRNA *ptr);
void gpencil_modifier_panel_get_property_pointers(const bContext *C,
struct Panel *panel,
struct PointerRNA *r_ob_ptr,
struct PointerRNA *r_ptr);
PanelType *gpencil_modifier_panel_register(struct ARegionType *region_type,
GpencilModifierType type,
PanelDrawFn draw);
struct PanelType *gpencil_modifier_subpanel_register(struct ARegionType *region_type,
const char *name,
const char *label,
PanelDrawFn draw_header,
PanelDrawFn draw,
struct PanelType *parent);
#ifdef __cplusplus
}
#endif
#endif /* __MOD_UI_COMMON__GPENCIL_H__ */

View File

@@ -28,6 +28,8 @@
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_armature_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
@@ -35,7 +37,9 @@
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
@@ -44,10 +48,17 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
#include "DEG_depsgraph.h"
@@ -186,6 +197,39 @@ static void foreachObjectLink(GpencilModifierData *md,
walk(userData, ob, &mmd->object, IDWALK_CB_NOP);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *sub, *row, *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
row = uiLayoutRow(layout, true);
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_vertex_group);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_vertex_group", 0, "", ICON_ARROW_LEFTRIGHT);
col = uiLayoutColumnWithHeading(layout, true, "Bind to");
uiItemR(col, &ptr, "use_vertex_groups", 0, IFACE_("Vertex Groups"), ICON_NONE);
uiItemR(col, &ptr, "use_bone_envelopes", 0, IFACE_("Bone Envelopes"), ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
gpencil_modifier_panel_register(region_type, eGpencilModifierType_Armature, panel_draw);
}
GpencilModifierTypeInfo modifierType_Gpencil_Armature = {
/* name */ "Armature",
/* structName */ "ArmatureGpencilModifierData",
@@ -207,4 +251,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Armature = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -35,12 +35,16 @@
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
@@ -51,12 +55,19 @@
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
typedef struct tmpStrokes {
@@ -330,6 +341,143 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "count", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "replace_material", 0, IFACE_("Material Override"), ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void relative_offset_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_relative_offset", 0, IFACE_("Relative Offset"), ICON_NONE);
}
static void relative_offset_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_relative_offset"));
uiItemR(col, &ptr, "relative_offset", 0, IFACE_("Factor"), ICON_NONE);
}
static void constant_offset_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_constant_offset", 0, IFACE_("Constant Offset"), ICON_NONE);
}
static void constant_offset_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_constant_offset"));
uiItemR(col, &ptr, "constant_offset", 0, IFACE_("Distance"), ICON_NONE);
}
/**
* Object offset in a subpanel for consistency with the other offset types.
*/
static void object_offset_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_object_offset", 0, NULL, ICON_NONE);
}
static void object_offset_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayout *col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_object_offset"));
uiItemR(col, &ptr, "offset_object", 0, NULL, ICON_NONE);
}
static void random_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "random_offset", 0, IFACE_("Offset"), ICON_NONE);
uiItemR(layout, &ptr, "random_rotation", 0, IFACE_("Rotation"), ICON_NONE);
uiItemR(layout, &ptr, "random_scale", 0, IFACE_("Scale"), ICON_NONE);
uiItemR(layout, &ptr, "seed", 0, NULL, ICON_NONE);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Array, panel_draw);
gpencil_modifier_subpanel_register(region_type,
"relative_offset",
"",
relative_offset_header_draw,
relative_offset_draw,
panel_type);
gpencil_modifier_subpanel_register(region_type,
"constant_offset",
"",
constant_offset_header_draw,
constant_offset_draw,
panel_type);
gpencil_modifier_subpanel_register(
region_type, "object_offset", "", object_offset_header_draw, object_offset_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "randomize", "Randomize", NULL, random_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Array = {
/* name */ "Array",
/* structName */ "ArrayGpencilModifierData",
@@ -352,4 +500,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Array = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -30,20 +30,31 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -537,6 +548,86 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
}
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row, *sub;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
if (mode == GP_BUILD_MODE_CONCURRENT) {
uiItemR(layout, &ptr, "concurrent_time_alignment", 0, NULL, ICON_NONE);
}
uiItemS(layout);
uiItemR(layout, &ptr, "transition", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "start_delay", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "length", 0, IFACE_("Frames"), ICON_NONE);
uiItemS(layout);
row = uiLayoutRowWithHeading(layout, true, IFACE_("Use Factor"));
uiItemR(row, &ptr, "use_percentage", 0, "", ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_percentage"));
uiItemR(sub, &ptr, "percentage_factor", 0, "", ICON_NONE);
/* Check for incompatible time modifier. */
Object *ob = ob_ptr.data;
GpencilModifierData *md = ptr.data;
if (BKE_gpencil_modifiers_findby_type(ob, eGpencilModifierType_Time) != NULL) {
BKE_gpencil_modifier_set_error(md, "Build and Time Offset modifiers are incompatible");
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void frame_range_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_restrict_frame_range", 0, IFACE_("Custom Range"), ICON_NONE);
}
static void frame_range_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
uiItemR(layout, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, false, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Build, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "frame_range", "", frame_range_header_draw, frame_range_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "_mask", "Influence", NULL, mask_panel_draw, panel_type);
}
/* ******************************************** */
GpencilModifierTypeInfo modifierType_Gpencil_Build = {
@@ -561,4 +652,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Build = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -29,22 +29,33 @@
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "BKE_modifier.h"
#include "RNA_access.h"
#include "DEG_depsgraph.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -186,6 +197,42 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "modify_color", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(layout, &ptr, "saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(layout, &ptr, "value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Color, panel_draw);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
"curve",
"",
gpencil_modifier_curve_header_draw,
gpencil_modifier_curve_panel_draw,
mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Color = {
/* name */ "Hue/Saturation",
/* structName */ "ColorGpencilModifierData",
@@ -208,4 +255,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Color = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,15 +28,19 @@
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_action.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
@@ -45,10 +49,17 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
#include "DEG_depsgraph.h"
@@ -345,6 +356,81 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *sub, *row, *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
PointerRNA hook_object_ptr = RNA_pointer_get(&ptr, "object");
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "object", 0, NULL, ICON_NONE);
if (!RNA_pointer_is_null(&hook_object_ptr) &&
RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) {
PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data");
uiItemPointerR(
col, &ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE);
}
row = uiLayoutRow(layout, true);
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_vertex_group);
uiLayoutSetPropSep(sub, false);
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
uiItemR(layout, &ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void falloff_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
bool use_falloff = RNA_enum_get(&ptr, "falloff_type") != eWarp_Falloff_None;
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "falloff_type", 0, IFACE_("Type"), ICON_NONE);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, use_falloff);
uiItemR(row, &ptr, "falloff_radius", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "use_falloff_uniform", 0, NULL, ICON_NONE);
if (RNA_enum_get(&ptr, "falloff_type") == eWarp_Falloff_Curve) {
uiTemplateCurveMapping(layout, &ptr, "falloff_curve", 0, false, false, false, false);
}
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Hook, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Hook = {
/* name */ "Hook",
/* structName */ "HookGpencilModifierData",
@@ -367,4 +453,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Hook = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,12 +26,16 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
@@ -41,10 +45,17 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
#include "DEG_depsgraph.h"
@@ -207,6 +218,54 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *sub, *row, *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
PointerRNA hook_object_ptr = RNA_pointer_get(&ptr, "object");
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "object", 0, NULL, ICON_NONE);
if (!RNA_pointer_is_null(&hook_object_ptr) &&
RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) {
PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data");
uiItemPointerR(
col, &ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE);
}
row = uiLayoutRow(layout, true);
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, has_vertex_group);
uiLayoutSetPropSep(sub, false);
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
uiItemR(layout, &ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Lattice, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Lattice = {
/* name */ "Lattice",
/* structName */ "LatticeGpencilModifierData",
@@ -229,4 +288,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Lattice = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,12 +28,16 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
@@ -43,10 +47,17 @@
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
#include "DEG_depsgraph.h"
@@ -254,6 +265,40 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis"));
uiItemR(row, &ptr, "x_axis", toggles_flag, NULL, ICON_NONE);
uiItemR(row, &ptr, "y_axis", toggles_flag, NULL, ICON_NONE);
uiItemR(row, &ptr, "z_axis", toggles_flag, NULL, ICON_NONE);
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Mirror, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Mirror = {
/* name */ "Mirror",
/* structName */ "MirrorGpencilModifierData",
@@ -276,4 +321,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Mirror = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -29,6 +29,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_alloca.h"
#include "BLI_blenlib.h"
@@ -37,6 +38,8 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -51,6 +54,7 @@
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "bmesh.h"
#include "bmesh_tools.h"
@@ -59,7 +63,13 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -305,8 +315,71 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "duplicates", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(layout, RNA_int_get(&ptr, "duplicates") > 0);
uiItemR(col, &ptr, "distance", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "offset", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void fade_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_fade", 0, NULL, ICON_NONE);
}
static void fade_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_fade"));
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "fading_center", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "fading_thickness", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(col, &ptr, "fading_opacity", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Multiply, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "fade", "", fade_header_draw, fade_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Multiply = {
/* name */ "Multiple Strokes",
/* name */ "MultipleStrokes",
/* structName */ "MultiplyGpencilModifierData",
/* structSize */ sizeof(MultiplyGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
@@ -327,4 +400,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Multiply = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -31,6 +31,8 @@
#include "BLI_math_vector.h"
#include "BLI_rand.h"
#include "BLT_translation.h"
#include "MEM_guardedalloc.h"
#include "DNA_gpencil_modifier_types.h"
@@ -38,8 +40,10 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
@@ -47,11 +51,18 @@
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -269,6 +280,72 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "factor", 0, IFACE_("Position"), ICON_NONE);
uiItemR(col, &ptr, "factor_strength", 0, IFACE_("Strength"), ICON_NONE);
uiItemR(col, &ptr, "factor_thickness", 0, IFACE_("Thickness"), ICON_NONE);
uiItemR(col, &ptr, "factor_uvs", 0, IFACE_("UV"), ICON_NONE);
uiItemR(col, &ptr, "noise_scale", 0, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void random_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "random", 0, IFACE_("Randomize"), ICON_NONE);
}
static void random_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "random"));
uiItemR(layout, &ptr, "step", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "seed", 0, NULL, ICON_NONE);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Noise, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "randomize", "", random_header_draw, random_panel_draw, panel_type);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
"curve",
"",
gpencil_modifier_curve_header_draw,
gpencil_modifier_curve_panel_draw,
mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Noise = {
/* name */ "Noise",
/* structName */ "NoiseGpencilModifierData",
@@ -291,4 +368,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Noise = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,22 +28,33 @@
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -136,6 +147,35 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "location", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "rotation", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "scale", 0, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, true);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Offset, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Offset = {
/* name */ "Offset",
/* structName */ "OffsetGpencilModifierData",
@@ -158,4 +198,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Offset = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,13 +28,17 @@
#include "BLI_blenlib.h"
#include "BLI_math_vector.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
@@ -42,10 +46,17 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -180,6 +191,7 @@ static void bakeModifier(Main *UNUSED(bmain),
}
}
}
static void freeData(GpencilModifierData *md)
{
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
@@ -196,6 +208,79 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
int modify_color = RNA_enum_get(&ptr, "modify_color");
uiItemR(layout, &ptr, "modify_color", 0, NULL, ICON_NONE);
if (modify_color == GP_MODIFY_COLOR_HARDNESS) {
uiItemR(layout, &ptr, "hardness", 0, NULL, ICON_NONE);
}
else {
uiItemR(layout, &ptr, "normalize_opacity", 0, NULL, ICON_NONE);
const char *text = (RNA_boolean_get(&ptr, "normalize_opacity")) ? IFACE_("Strength") :
IFACE_("Opacity Factor");
uiItemR(layout, &ptr, "hardness", 0, text, ICON_NONE);
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int modify_color = RNA_enum_get(&ptr, "modify_color");
bool show_vertex = (modify_color != GP_MODIFY_COLOR_HARDNESS);
gpencil_modifier_masking_panel_draw(C, panel, true, show_vertex);
}
static void curve_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int modify_color = RNA_enum_get(&ptr, "modify_color");
uiLayoutSetActive(layout, modify_color != GP_MODIFY_COLOR_HARDNESS);
gpencil_modifier_curve_header_draw(C, panel);
}
static void curve_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int modify_color = RNA_enum_get(&ptr, "modify_color");
uiLayoutSetActive(layout, modify_color != GP_MODIFY_COLOR_HARDNESS);
gpencil_modifier_curve_panel_draw(C, panel);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Opacity, panel_draw);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
region_type, "curve", "", curve_header_draw, curve_panel_draw, mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
/* name */ "Opacity",
/* structName */ "OpacityGpencilModifierData",
@@ -218,4 +303,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,20 +26,31 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_vec_types.h"
#include "BKE_context.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -131,6 +142,48 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
if (mode == GP_SIMPLIFY_FIXED) {
uiItemR(layout, &ptr, "step", 0, NULL, ICON_NONE);
}
else if (mode == GP_SIMPLIFY_ADAPTIVE) {
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
}
else if (mode == GP_SIMPLIFY_SAMPLE) {
uiItemR(layout, &ptr, "length", 0, NULL, ICON_NONE);
}
else if (mode == GP_SIMPLIFY_MERGE) {
uiItemR(layout, &ptr, "distance", 0, NULL, ICON_NONE);
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Simplify, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Simplify = {
/* name */ "Simplify",
/* structName */ "SimplifyGpencilModifierData",
@@ -153,4 +206,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Simplify = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,21 +26,32 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -174,6 +185,47 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
row = uiLayoutRow(layout, true);
uiItemR(row, &ptr, "use_edit_position", UI_ITEM_R_TOGGLE, IFACE_("Position"), ICON_NONE);
uiItemR(row, &ptr, "use_edit_strength", UI_ITEM_R_TOGGLE, IFACE_("Stength"), ICON_NONE);
uiItemR(row, &ptr, "use_edit_thickness", UI_ITEM_R_TOGGLE, IFACE_("Thickness"), ICON_NONE);
uiItemR(row, &ptr, "use_edit_uv", UI_ITEM_R_TOGGLE, IFACE_("UV"), ICON_NONE);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "step", 0, IFACE_("Repeat"), ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, true);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Smooth, panel_draw);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
"curve",
"",
gpencil_modifier_curve_header_draw,
gpencil_modifier_curve_panel_draw,
mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Smooth = {
/* name */ "Smooth",
/* structName */ "SmoothGpencilModifierData",
@@ -196,4 +248,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Smooth = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,20 +28,31 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -112,6 +123,34 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "subdivision_type", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "level", 0, IFACE_("Subdivisions"), ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Subdiv, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = {
/* name */ "Subdivide",
/* structName */ "SubdivGpencilModifierData",
@@ -134,4 +173,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -27,23 +27,34 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -147,8 +158,56 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
if (ELEM(mode, STROKE, STROKE_AND_FILL)) {
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "fit_method", 0, IFACE_("Stroke Fit Method"), ICON_NONE);
uiItemR(col, &ptr, "uv_offset", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "uv_scale", 0, IFACE_("Scale"), ICON_NONE);
}
if (mode == STROKE_AND_FILL) {
uiItemS(layout);
}
if (ELEM(mode, FILL, STROKE_AND_FILL)) {
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "fill_rotation", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "fill_offset", 0, IFACE_("Offset"), ICON_NONE);
uiItemR(col, &ptr, "fill_scale", 0, IFACE_("Scale"), ICON_NONE);
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, true);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Texture, panel_draw);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Texture = {
/* name */ "Texture Mapping",
/* name */ "TextureMapping",
/* structName */ "TextureGpencilModifierData",
/* structSize */ sizeof(TextureGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
@@ -169,4 +228,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Texture = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -27,22 +27,33 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -166,6 +177,46 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "normalize_thickness", 0, NULL, ICON_NONE);
if (RNA_boolean_get(&ptr, "normalize_thickness")) {
uiItemR(layout, &ptr, "thickness", 0, NULL, ICON_NONE);
}
else {
uiItemR(layout, &ptr, "thickness_factor", 0, NULL, ICON_NONE);
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, true);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Thick, panel_draw);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
"curve",
"",
gpencil_modifier_curve_header_draw,
gpencil_modifier_curve_panel_draw,
mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
/* name */ "Thickness",
/* structName */ "ThickGpencilModifierData",
@@ -188,4 +239,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,20 +26,31 @@
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
static void initData(GpencilModifierData *md)
@@ -165,8 +176,91 @@ static int remapTime(struct GpencilModifierData *md,
return cfra + offset;
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row, *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, false);
const char *text = (mode == GP_TIME_MODE_FIX) ? IFACE_("Frame") : IFACE_("Frame Offset");
uiItemR(col, &ptr, "offset", 0, text, ICON_NONE);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX);
uiItemR(row, &ptr, "frame_scale", 0, IFACE_("Scale"), ICON_NONE);
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX);
uiItemR(row, &ptr, "use_keep_loop", 0, NULL, ICON_NONE);
gpencil_modifier_panel_end(layout, &ptr);
}
static void custom_range_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetActive(layout, mode != GP_TIME_MODE_FIX);
uiItemR(layout, &ptr, "use_custom_frame_range", 0, NULL, ICON_NONE);
}
static void custom_range_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiLayoutSetActive(
layout, (mode != GP_TIME_MODE_FIX) && (RNA_boolean_get(&ptr, "use_custom_frame_range")));
col = uiLayoutColumn(layout, false);
uiItemR(col, &ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
uiItemR(col, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, false, false);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Time, panel_draw);
gpencil_modifier_subpanel_register(region_type,
"custom_range",
"",
custom_range_header_draw,
custom_range_panel_draw,
panel_type);
gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Time = {
/* name */ "Time Offset",
/* name */ "TimeOffset",
/* structName */ "TimeGpencilModifierData",
/* structSize */ sizeof(TimeGpencilModifierData),
/* type */ eGpencilModifierTypeType_Gpencil,
@@ -187,4 +281,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Time = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -28,16 +28,20 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLT_translation.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_action.h"
#include "BKE_colorband.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_modifier.h"
@@ -47,10 +51,17 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
#include "DEG_depsgraph.h"
@@ -330,6 +341,56 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
int tint_type = RNA_enum_get(&ptr, "tint_type");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "vertex_mode", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "tint_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
if (tint_type == GP_TINT_UNIFORM) {
uiItemR(layout, &ptr, "color", 0, NULL, ICON_NONE);
}
else {
col = uiLayoutColumn(layout, false);
uiLayoutSetPropSep(col, false);
uiTemplateColorRamp(col, &ptr, "colors", true);
uiItemS(layout);
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "radius", 0, NULL, ICON_NONE);
}
gpencil_modifier_panel_end(layout, &ptr);
}
static void mask_panel_draw(const bContext *C, Panel *panel)
{
gpencil_modifier_masking_panel_draw(C, panel, true, true);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Tint, panel_draw);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
"curve",
"",
gpencil_modifier_curve_header_draw,
gpencil_modifier_curve_panel_draw,
mask_panel_type);
}
GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
/* name */ "Tint",
/* structName */ "TintGpencilModifierData",
@@ -352,4 +413,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -61,7 +61,8 @@ typedef struct bConstraint {
/** Constraint name, MAX_NAME. */
char name[64];
char _pad[2];
/* Flag for panel and subpanel closed / open state in the UI. */
short ui_expand_flag;
/** Amount of influence exherted by constraint (0.0-1.0). */
float enforce;
@@ -689,8 +690,8 @@ typedef enum eBConstraint_Types {
/* flag 0x20 (1 << 5) was used to indicate that a constraint was evaluated
* using a 'local' hack for posebones only. */
typedef enum eBConstraint_Flags {
/* expand for UI */
CONSTRAINT_EXPAND = (1 << 0),
/* Expansion for old box constraint layouts. Just for versioning. */
CONSTRAINT_EXPAND_DEPRECATED = (1 << 0),
/* pre-check for illegal object name or bone name */
CONSTRAINT_DISABLE = (1 << 2),
/* to indicate which Ipo should be shown, maybe for 3d access later too */

View File

@@ -56,7 +56,7 @@ typedef enum GpencilModifierMode {
eGpencilModifierMode_Realtime = (1 << 0),
eGpencilModifierMode_Render = (1 << 1),
eGpencilModifierMode_Editmode = (1 << 2),
eGpencilModifierMode_Expanded = (1 << 3),
eGpencilModifierMode_Expanded_DEPRECATED = (1 << 3),
} GpencilModifierMode;
typedef enum {
@@ -70,7 +70,7 @@ typedef struct GpencilModifierData {
int type, mode;
int stackindex;
short flag;
short _pad;
short ui_expand_flag;
/** MAX_NAME. */
char name[64];

View File

@@ -50,7 +50,7 @@ typedef enum ShaderFxMode {
eShaderFxMode_Realtime = (1 << 0),
eShaderFxMode_Render = (1 << 1),
eShaderFxMode_Editmode = (1 << 2),
eShaderFxMode_Expanded = (1 << 3),
eShaderFxMode_Expanded_DEPRECATED = (1 << 3),
} ShaderFxMode;
typedef enum {
@@ -64,7 +64,8 @@ typedef struct ShaderFxData {
int type, mode;
int stackindex;
short flag;
char _pad[2];
/* Expansion for constraint panels. */
short ui_expand_flag;
/** MAX_NAME. */
char name[64];

View File

@@ -2483,7 +2483,7 @@ static void rna_def_constraint_location_limit(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM);
RNA_def_property_ui_text(
prop, "For Transform", "Transforms are affected by this constraint as well");
prop, "Affect Transform", "Transforms are affected by this constraint as well");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
RNA_define_lib_overridable(false);
@@ -3380,8 +3380,8 @@ void RNA_def_constraint(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
/* XXX this is really an internal flag,

View File

@@ -1490,7 +1490,7 @@ static void rna_def_modifier_gpencilarray(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "relative_offset", PROP_FLOAT, PROP_NONE);
prop = RNA_def_property(srna, "relative_offset", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "shift");
RNA_def_property_ui_text(
prop,
@@ -2127,8 +2127,7 @@ static void rna_def_modifier_gpencilmultiply(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_fade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", GP_MULTIPLY_ENABLE_FADING);
RNA_def_property_ui_text(
prop, "Enable Fade", "Fade the stroke thickness for each generated stroke");
RNA_def_property_ui_text(prop, "Fade", "Fade the stroke thickness for each generated stroke");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE);
@@ -2183,12 +2182,12 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
{GP_TEX_CONSTANT_LENGTH,
"CONSTANT_LENGTH",
0,
"Keep Texture at Constant Length",
"Constant Length",
"Keep the texture at a constant length regardless of the length of each stroke"},
{GP_TEX_FIT_STROKE,
"FIT_STROKE",
0,
"Fit Texture to Stroke Length",
"Stroke Length",
"Scale the texture to fit the length of each stroke"},
{0, NULL, 0, NULL, NULL},
};
@@ -2269,7 +2268,7 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -100.0, 100.0, 0.1, 3);
RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(prop, "Offset UVs", "Offset value to add to stroke UVs");
RNA_def_property_ui_text(prop, "UV Offset", "Offset value to add to stroke UVs");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "uv_scale", PROP_FLOAT, PROP_NONE);
@@ -2360,7 +2359,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Expanded);
RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);

View File

@@ -424,7 +424,7 @@ static void rna_def_shader_fx_shadow(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Offset", "Offset of the shadow");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "scale");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_text(prop, "Scale", "Offset of the shadow");
@@ -681,9 +681,9 @@ void RNA_def_shader_fx(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", eShaderFxMode_Expanded);
RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Expanded", "Set effect expanded in the user interface");
RNA_def_property_ui_text(prop, "Expanded", "Set effect expansion in the user interface");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
/* types */

View File

@@ -1213,21 +1213,18 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Generates the UI layout for the modifier stack");
func = RNA_def_function(srna, "template_greasepencil_modifier", "uiTemplateGpencilModifier");
func = RNA_def_function(srna, "template_grease_pencil_modifiers", "uiTemplateGpencilModifiers");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Generates the UI layout for grease pencil modifiers");
parm = RNA_def_pointer(func, "data", "GpencilModifier", "", "Modifier data");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
RNA_def_function_ui_description(func,
"Generates the panels for the grease pencil modifier stack");
func = RNA_def_function(srna, "template_constraints", "uiTemplateConstraints");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Generates the panels for the constraint stack");
func = RNA_def_function(srna, "template_shaderfx", "uiTemplateShaderFx");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Generates the UI layout for shader effect");
parm = RNA_def_pointer(func, "data", "ShaderFx", "", "Shader data");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
RNA_def_function_ui_description(func, "Generates the panels for the shader effect stack");
func = RNA_def_function(srna, "template_greasepencil_color", "uiTemplateGpencilColorPreview");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -1251,12 +1248,10 @@ void RNA_api_ui_layout(StructRNA *srna)
"",
"Optionally limit the items which can be selected");
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
func = RNA_def_function(srna, "template_constraint_header", "uiTemplateConstraintHeader");
RNA_def_function_ui_description(func, "Generates the header for constraint panels");
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "template_preview", "uiTemplatePreview");
RNA_def_function_ui_description(

View File

@@ -24,12 +24,15 @@ set(INC
intern
../blenfont
../blenkernel
../blentranslation
../blenlib
../bmesh
../depsgraph
../editors/include
../makesdna
../makesrna
../render/extern/include
../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
)
@@ -40,6 +43,7 @@ set(INC_SYS
set(SRC
intern/FX_shader_util.h
intern/FX_ui_common.c
intern/FX_shader_blur.c
intern/FX_shader_colorize.c
@@ -52,6 +56,7 @@ set(SRC
intern/FX_shader_util.c
intern/FX_shader_wave.c
intern/FX_ui_common.h
FX_shader_types.h
)

View File

@@ -26,7 +26,20 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "DNA_screen_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -41,6 +54,32 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "samples", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "use_dof_mode", 0, IFACE_("Use Depth of Field"), ICON_NONE);
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, !RNA_boolean_get(&ptr, "use_dof_mode"));
uiItemR(col, &ptr, "size", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "rotation", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Blur, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Blur = {
/* name */ "Blur",
/* structName */ "BlurShaderFxData",
@@ -57,4 +96,5 @@ ShaderFxTypeInfo shaderfx_Type_Blur = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -23,11 +23,23 @@
#include <stdio.h>
#include "DNA_shader_fx_types.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -43,6 +55,38 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
if (ELEM(mode, eShaderFxColorizeMode_Custom, eShaderFxColorizeMode_Duotone)) {
const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
IFACE_("Color");
uiItemR(layout, &ptr, "low_color", 0, text, ICON_NONE);
}
if (mode == eShaderFxColorizeMode_Duotone) {
uiItemR(layout, &ptr, "high_color", 0, NULL, ICON_NONE);
}
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Colorize, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Colorize = {
/* name */ "Colorize",
/* structName */ "ColorizeShaderFxData",
@@ -59,4 +103,5 @@ ShaderFxTypeInfo shaderfx_Type_Colorize = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,10 +26,22 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -42,6 +54,29 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis"));
uiItemR(row, &ptr, "flip_horizontal", toggles_flag, NULL, ICON_NONE);
uiItemR(row, &ptr, "flip_vertical", toggles_flag, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Flip, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Flip = {
/* name */ "Flip",
/* structName */ "FlipShaderFxData",
@@ -58,4 +93,5 @@ ShaderFxTypeInfo shaderfx_Type_Flip = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,14 +26,23 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *md)
{
@@ -50,6 +59,44 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
int mode = RNA_enum_get(&ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
if (mode == eShaderFxGlowMode_Luminance) {
uiItemR(layout, &ptr, "threshold", 0, NULL, ICON_NONE);
}
else {
uiItemR(layout, &ptr, "select_color", 0, NULL, ICON_NONE);
}
uiItemR(layout, &ptr, "glow_color", 0, NULL, ICON_NONE);
uiItemS(layout);
uiItemR(layout, &ptr, "blend_mode", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "opacity", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "size", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "rotation", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "samples", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "use_glow_under", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Glow, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Glow = {
/* name */ "Glow",
/* structName */ "GlowShaderFxData",
@@ -66,4 +113,5 @@ ShaderFxTypeInfo shaderfx_Type_Glow = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,14 +26,23 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -93,4 +102,5 @@ ShaderFxTypeInfo shaderfx_Type_Light = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* panelRegister */ NULL,
};

View File

@@ -25,7 +25,20 @@
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "DNA_screen_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -39,6 +52,30 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
/* Add the X, Y labels manually because size is a #PROP_PIXEL. */
col = uiLayoutColumn(layout, true);
PropertyRNA *prop = RNA_struct_find_property(&ptr, "size");
uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Size X"), ICON_NONE);
uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Pixel, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Pixel = {
/* name */ "Pixelate",
/* structName */ "PixelShaderFxData",
@@ -55,4 +92,5 @@ ShaderFxTypeInfo shaderfx_Type_Pixel = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -23,11 +23,23 @@
#include <stdio.h>
#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -46,6 +58,42 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "rim_color", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "mask_color", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "mode", 0, IFACE_("Blend"), ICON_NONE);
uiItemR(layout, &ptr, "offset", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void blur_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "blur", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "samples", 0, NULL, ICON_NONE);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = shaderfx_panel_register(region_type, eShaderFxType_Rim, panel_draw);
shaderfx_subpanel_register(region_type, "blur", "Blur", NULL, blur_panel_draw, panel_type);
}
ShaderFxTypeInfo shaderfx_Type_Rim = {
/* name */ "Rim",
/* structName */ "RimShaderFxData",
@@ -62,4 +110,5 @@ ShaderFxTypeInfo shaderfx_Type_Rim = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,14 +26,25 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -88,6 +99,88 @@ static void foreachObjectLink(ShaderFxData *fx,
walk(userData, ob, &fxd->object, IDWALK_CB_NOP);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *row, *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "shadow_color", 0, NULL, ICON_NONE);
/* Add the X, Y labels manually because size is a #PROP_PIXEL. */
col = uiLayoutColumn(layout, true);
PropertyRNA *prop = RNA_struct_find_property(&ptr, "offset");
uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Offset X"), ICON_NONE);
uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
uiItemR(layout, &ptr, "scale", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "rotation", 0, NULL, ICON_NONE);
row = uiLayoutRowWithHeading(layout, true, IFACE_("Object Pivot"));
uiItemR(row, &ptr, "use_object", 0, "", ICON_NONE);
uiItemR(row, &ptr, "object", 0, "", ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void blur_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
/* Add the X, Y labels manually because size is a #PROP_PIXEL. */
col = uiLayoutColumn(layout, true);
PropertyRNA *prop = RNA_struct_find_property(&ptr, "blur");
uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Blur X"), ICON_NONE);
uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
uiItemR(layout, &ptr, "samples", 0, NULL, ICON_NONE);
}
static void wave_header_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiItemR(layout, &ptr, "use_wave", 0, IFACE_("Wave Effect"), ICON_NONE);
}
static void wave_panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_wave"));
uiItemR(layout, &ptr, "orientation", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(layout, &ptr, "amplitude", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "period", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "phase", 0, NULL, ICON_NONE);
}
static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = shaderfx_panel_register(region_type, eShaderFxType_Shadow, panel_draw);
shaderfx_subpanel_register(region_type, "blur", "Blur", NULL, blur_panel_draw, panel_type);
shaderfx_subpanel_register(
region_type, "wave", "", wave_header_draw, wave_panel_draw, panel_type);
}
ShaderFxTypeInfo shaderfx_Type_Shadow = {
/* name */ "Shadow",
/* structName */ "ShadowShaderFxData",
@@ -104,4 +197,5 @@ ShaderFxTypeInfo shaderfx_Type_Shadow = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,15 +26,24 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_math_base.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_lib_query.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -77,6 +86,28 @@ static void foreachObjectLink(ShaderFxData *fx,
walk(userData, ob, &fxd->object, IDWALK_CB_NOP);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
PointerRNA ob_ptr;
shaderfx_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "radius", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "angle", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Swirl, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Swirl = {
/* name */ "Swirl",
/* structName */ "SwirlShaderFxData",
@@ -93,4 +124,5 @@ ShaderFxTypeInfo shaderfx_Type_Swirl = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -26,10 +26,20 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BLI_utildefines.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "FX_shader_types.h"
#include "FX_ui_common.h"
static void initData(ShaderFxData *fx)
{
@@ -45,8 +55,30 @@ static void copyData(const ShaderFxData *md, ShaderFxData *target)
BKE_shaderfx_copydata_generic(md, target);
}
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
uiLayoutSetPropSep(layout, true);
uiItemR(layout, &ptr, "orientation", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(layout, &ptr, "amplitude", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "period", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "phase", 0, NULL, ICON_NONE);
shaderfx_panel_end(layout, &ptr);
}
static void panelRegister(ARegionType *region_type)
{
shaderfx_panel_register(region_type, eShaderFxType_Wave, panel_draw);
}
ShaderFxTypeInfo shaderfx_Type_Wave = {
/* name */ "Wave Distortion",
/* name */ "WaveDistortion",
/* structName */ "WaveShaderFxData",
/* structSize */ sizeof(WaveShaderFxData),
/* type */ eShaderFxType_GpencilType,
@@ -61,4 +93,5 @@ ShaderFxTypeInfo shaderfx_Type_Wave = {
/* dependsOnTime */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* panelRegister */ panelRegister,
};

View File

@@ -0,0 +1,261 @@
/* 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.
*/
/** \file
* \ingroup modifiers
*/
#include <string.h>
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_shader_fx.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_shader_fx_types.h"
#include "ED_object.h"
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
#include "FX_ui_common.h" /* Self include */
/* -------------------------------------------------------------------- */
/** \name Panel Drag and Drop, Expansion Saving
* \{ */
/**
* Move an effect to the index it's moved to after a drag and drop.
*/
static void shaderfx_reorder(bContext *C, Panel *panel, int new_index)
{
Object *ob = CTX_data_active_object(C);
ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index);
PointerRNA props_ptr;
wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_shaderfx_move_to_index", false);
WM_operator_properties_create_ptr(&props_ptr, ot);
RNA_string_set(&props_ptr, "shaderfx", fx->name);
RNA_int_set(&props_ptr, "index", new_index);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
}
/**
* Get the expand flag from the active effect to use for the panel.
*/
static short get_shaderfx_expand_flag(const bContext *C, Panel *panel)
{
Object *ob = CTX_data_active_object(C);
ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index);
return fx->ui_expand_flag;
}
/**
* Save the expand flag for the panel and subpanels to the effect.
*/
static void set_shaderfx_expand_flag(const bContext *C, Panel *panel, short expand_flag)
{
Object *ob = CTX_data_active_object(C);
ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index);
fx->ui_expand_flag = expand_flag;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name ShaderFx Panel Layouts
* \{ */
/**
* Draw shaderfx error message.
*/
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
{
ShaderFxData *fx = ptr->data;
if (fx->error) {
uiLayout *row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_(fx->error), ICON_ERROR);
}
}
/**
* Gets RNA pointers for the active object and the panel's shaderfx data.
*/
void shaderfx_panel_get_property_pointers(const bContext *C,
Panel *panel,
PointerRNA *r_ob_ptr,
PointerRNA *r_md_ptr)
{
Object *ob = CTX_data_active_object(C);
ShaderFxData *md = BLI_findlink(&ob->shader_fx, panel->runtime.list_index);
RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, r_md_ptr);
if (r_ob_ptr != NULL) {
RNA_pointer_create(&ob->id, &RNA_Object, ob, r_ob_ptr);
}
uiLayoutSetContextPointer(panel->layout, "shaderfx", r_md_ptr);
}
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
static void shaderfx_panel_header(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
bool narrow_panel = (panel->sizex < UI_UNIT_X * 7 && panel->sizex != 0);
PointerRNA ptr;
shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr);
Object *ob = CTX_data_active_object(C);
ShaderFxData *fx = (ShaderFxData *)ptr.data;
const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(fx->type);
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
/* Effect type icon. */
uiLayout *row = uiLayoutRow(layout, false);
if (fxti->isDisabled && fxti->isDisabled(fx, 0)) {
uiLayoutSetRedAlert(row, true);
}
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
/* Effect name. */
if (!narrow_panel) {
uiItemR(layout, &ptr, "name", 0, "", ICON_NONE);
}
/* Mode enabling buttons. */
row = uiLayoutRow(layout, true);
if (fxti->flags & eShaderFxTypeFlag_SupportsEditmode) {
uiLayout *sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, false);
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
row = uiLayoutRow(layout, false);
uiLayoutSetEmboss(row, UI_EMBOSS_NONE);
uiItemO(row, "", ICON_X, "OBJECT_OT_shaderfx_remove");
/* Some padding so the X isn't too close to the drag icon. */
uiItemS(layout);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name ShaderFx Registration Helpers
* \{ */
static bool shaderfx_ui_poll(const bContext *C, PanelType *UNUSED(pt))
{
Object *ob = CTX_data_active_object(C);
return (ob != NULL) && (ob->type == OB_GPENCIL);
}
/**
* Create a panel in the context's region
*/
PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
{
/* Get the name for the effect's panel. */
char panel_idname[BKE_ST_MAXNAME];
BKE_shaderfxType_panel_id(type, panel_idname);
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
strcpy(panel_type->idname, panel_idname);
strcpy(panel_type->label, "");
strcpy(panel_type->context, "shaderfx");
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
panel_type->draw_header = shaderfx_panel_header;
panel_type->draw = draw;
panel_type->poll = shaderfx_ui_poll;
/* Give the panel the special flag that says it was built here and corresponds to a
* shader effect rather than a PanelType. */
panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
panel_type->reorder = shaderfx_reorder;
panel_type->get_list_data_expand_flag = get_shaderfx_expand_flag;
panel_type->set_list_data_expand_flag = set_shaderfx_expand_flag;
BLI_addtail(&region_type->paneltypes, panel_type);
return panel_type;
}
/**
* Add a child panel to the parent.
*
* \note To create the panel type's idname, it appends the \a name argument to the \a parent's
* idname.
*/
PanelType *shaderfx_subpanel_register(ARegionType *region_type,
const char *name,
const char *label,
PanelDrawFn draw_header,
PanelDrawFn draw,
PanelType *parent)
{
/* Create the subpanel's ID name. */
char panel_idname[BKE_ST_MAXNAME];
strcpy(panel_idname, parent->idname);
strcat(panel_idname, "_");
strcat(panel_idname, name);
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
strcpy(panel_type->idname, panel_idname);
strcpy(panel_type->label, label);
strcpy(panel_type->context, "shaderfx");
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
panel_type->draw_header = draw_header;
panel_type->draw = draw;
panel_type->poll = shaderfx_ui_poll;
panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
BLI_assert(parent != NULL);
strcpy(panel_type->parent_id, parent->idname);
panel_type->parent = parent;
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
BLI_addtail(&region_type->paneltypes, panel_type);
return panel_type;
}
/** \} */

View File

@@ -0,0 +1,56 @@
/*
* 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.
*/
/** \file
* \ingroup modifiers
*/
#ifndef __FX_UI_COMMON_H__
#define __FX_UI_COMMON_H__
#include "FX_shader_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ARegionType;
struct bContext;
struct PanelType;
struct uiLayout;
typedef void (*PanelDrawFn)(const bContext *, Panel *);
void shaderfx_panel_end(struct uiLayout *layout, PointerRNA *ptr);
void shaderfx_panel_get_property_pointers(const bContext *C,
struct Panel *panel,
struct PointerRNA *r_ob_ptr,
struct PointerRNA *r_ptr);
PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw);
struct PanelType *shaderfx_subpanel_register(struct ARegionType *region_type,
const char *name,
const char *label,
PanelDrawFn draw_header,
PanelDrawFn draw,
struct PanelType *parent);
#ifdef __cplusplus
}
#endif
#endif /* __FX_UI_COMMON_H__ */