9fb0d0b4afdf81e83323abdc04444ad18bb54336
[blender.git] / release / scripts / startup / bl_ui / space_image.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_paint_common import UnifiedPaintPanel
23
24
25 class ImagePaintPanel(UnifiedPaintPanel):
26     bl_space_type = 'IMAGE_EDITOR'
27     bl_region_type = 'UI'
28
29
30 class BrushButtonsPanel():
31     bl_space_type = 'IMAGE_EDITOR'
32     bl_region_type = 'UI'
33
34     @classmethod
35     def poll(cls, context):
36         sima = context.space_data
37         toolsettings = context.tool_settings.image_paint
38         return sima.show_paint and toolsettings.brush
39
40
41 class IMAGE_MT_view(Menu):
42     bl_label = "View"
43
44     def draw(self, context):
45         layout = self.layout
46
47         sima = context.space_data
48         uv = sima.uv_editor
49         toolsettings = context.tool_settings
50
51         show_uvedit = sima.show_uvedit
52
53         layout.operator("image.properties", icon='MENU_PANEL')
54         layout.operator("image.scopes", icon='MENU_PANEL')
55
56         layout.separator()
57
58         layout.prop(sima, "use_realtime_update")
59         if show_uvedit:
60             layout.prop(toolsettings, "show_uv_local_view")
61
62         layout.prop(uv, "show_other_objects")
63
64         layout.separator()
65
66         layout.operator("image.view_zoom_in")
67         layout.operator("image.view_zoom_out")
68
69         layout.separator()
70
71         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
72
73         for a, b in ratios:
74             layout.operator("image.view_zoom_ratio", text="Zoom" + " %d:%d" % (a, b)).ratio = a / b
75
76         layout.separator()
77
78         if show_uvedit:
79             layout.operator("image.view_selected")
80
81         layout.operator("image.view_all")
82
83         layout.separator()
84
85         layout.operator("screen.area_dupli")
86         layout.operator("screen.screen_full_area")
87
88
89 class IMAGE_MT_select(Menu):
90     bl_label = "Select"
91
92     def draw(self, context):
93         layout = self.layout
94
95         layout.operator("uv.select_border").pinned = False
96         layout.operator("uv.select_border", text="Border Select Pinned").pinned = True
97
98         layout.separator()
99
100         layout.operator("uv.select_all").action = 'TOGGLE'
101         layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
102         layout.operator("uv.unlink_selected")
103
104         layout.separator()
105
106         layout.operator("uv.select_pinned")
107         layout.operator("uv.select_linked")
108
109
110 class IMAGE_MT_image(Menu):
111     bl_label = "Image"
112
113     def draw(self, context):
114         layout = self.layout
115
116         sima = context.space_data
117         ima = sima.image
118
119         layout.operator("image.new")
120         layout.operator("image.open")
121
122         show_render = sima.show_render
123
124         if ima:
125             if not show_render:
126                 layout.operator("image.replace")
127                 layout.operator("image.reload")
128
129             layout.operator("image.save")
130             layout.operator("image.save_as")
131             layout.operator("image.save_as", text="Save a Copy").copy = True
132
133             if ima.source == 'SEQUENCE':
134                 layout.operator("image.save_sequence")
135
136             layout.operator("image.external_edit", "Edit Externally")
137
138             layout.separator()
139
140             layout.menu("IMAGE_MT_image_invert")
141
142             if not show_render:
143                 layout.separator()
144
145                 if ima.packed_file:
146                     layout.operator("image.unpack")
147                 else:
148                     layout.operator("image.pack")
149
150                 # only for dirty && specific image types, perhaps
151                 # this could be done in operator poll too
152                 if ima.is_dirty:
153                     if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
154                         layout.operator("image.pack", text="Pack As PNG").as_png = True
155
156             if not context.tool_settings.use_uv_sculpt:
157                 layout.separator()
158                 layout.prop(sima, "use_image_paint")
159
160             layout.separator()
161
162
163 class IMAGE_MT_image_invert(Menu):
164     bl_label = "Invert"
165
166     def draw(self, context):
167         layout = self.layout
168
169         props = layout.operator("image.invert", text="Invert Image Colors")
170         props.invert_r = True
171         props.invert_g = True
172         props.invert_b = True
173
174         layout.separator()
175
176         props = layout.operator("image.invert", text="Invert Red Channel")
177         props.invert_r = True
178
179         props = layout.operator("image.invert", text="Invert Green Channel")
180         props.invert_g = True
181
182         props = layout.operator("image.invert", text="Invert Blue Channel")
183         props.invert_b = True
184
185         props = layout.operator("image.invert", text="Invert Alpha Channel")
186         props.invert_a = True
187
188
189 class IMAGE_MT_uvs_showhide(Menu):
190     bl_label = "Show/Hide Faces"
191
192     def draw(self, context):
193         layout = self.layout
194
195         layout.operator("uv.reveal")
196         layout.operator("uv.hide", text="Hide Selected").unselected = False
197         layout.operator("uv.hide", text="Hide Unselected").unselected = True
198
199
200 class IMAGE_MT_uvs_transform(Menu):
201     bl_label = "Transform"
202
203     def draw(self, context):
204         layout = self.layout
205
206         layout.operator("transform.translate")
207         layout.operator("transform.rotate")
208         layout.operator("transform.resize")
209
210         layout.separator()
211
212         layout.operator("transform.shear")
213
214
215 class IMAGE_MT_uvs_snap(Menu):
216     bl_label = "Snap"
217
218     def draw(self, context):
219         layout = self.layout
220         layout.operator_context = 'EXEC_REGION_WIN'
221
222         layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
223         layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
224         layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
225
226         layout.separator()
227
228         layout.operator("uv.snap_cursor", text="Cursor to Pixels").target = 'PIXELS'
229         layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED'
230
231
232 class IMAGE_MT_uvs_mirror(Menu):
233     bl_label = "Mirror"
234
235     def draw(self, context):
236         layout = self.layout
237         layout.operator_context = 'EXEC_REGION_WIN'
238
239         layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
240         layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True
241
242
243 class IMAGE_MT_uvs_weldalign(Menu):
244     bl_label = "Weld/Align"
245
246     def draw(self, context):
247         layout = self.layout
248
249         layout.operator("uv.weld")  # W, 1
250         layout.operator_enum("uv.align", "axis")  # W, 2/3/4
251
252
253 class IMAGE_MT_uvs(Menu):
254     bl_label = "UVs"
255
256     def draw(self, context):
257         layout = self.layout
258
259         sima = context.space_data
260         uv = sima.uv_editor
261         toolsettings = context.tool_settings
262
263         layout.prop(uv, "use_snap_to_pixels")
264         layout.prop(uv, "lock_bounds")
265
266         layout.separator()
267
268         layout.prop(toolsettings, "use_uv_sculpt")
269
270         layout.separator()
271
272         layout.prop(uv, "use_live_unwrap")
273         layout.operator("uv.unwrap")
274         layout.operator("uv.pin", text="Unpin").clear = True
275         layout.operator("uv.pin")
276
277         layout.separator()
278
279         layout.operator("uv.pack_islands")
280         layout.operator("uv.average_islands_scale")
281         layout.operator("uv.minimize_stretch")
282         layout.operator("uv.stitch")
283         layout.operator("uv.mark_seam")
284         layout.operator("uv.seams_from_islands")
285         layout.operator("mesh.faces_mirror_uv")
286
287         layout.separator()
288
289         layout.menu("IMAGE_MT_uvs_transform")
290         layout.menu("IMAGE_MT_uvs_mirror")
291         layout.menu("IMAGE_MT_uvs_snap")
292         layout.menu("IMAGE_MT_uvs_weldalign")
293
294         layout.separator()
295
296         layout.prop_menu_enum(toolsettings, "proportional_edit")
297         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
298
299         layout.separator()
300
301         layout.menu("IMAGE_MT_uvs_showhide")
302
303
304 class IMAGE_MT_uvs_select_mode(Menu):
305     bl_label = "UV Select Mode"
306
307     def draw(self, context):
308         layout = self.layout
309
310         layout.operator_context = 'INVOKE_REGION_WIN'
311         toolsettings = context.tool_settings
312
313         # do smart things depending on whether uv_select_sync is on
314
315         if toolsettings.use_uv_select_sync:
316             props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
317             props.value = "(True, False, False)"
318             props.data_path = "tool_settings.mesh_select_mode"
319
320             props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
321             props.value = "(False, True, False)"
322             props.data_path = "tool_settings.mesh_select_mode"
323
324             props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
325             props.value = "(False, False, True)"
326             props.data_path = "tool_settings.mesh_select_mode"
327
328         else:
329             props = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
330             props.value = 'VERTEX'
331             props.data_path = "tool_settings.uv_select_mode"
332
333             props = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
334             props.value = 'EDGE'
335             props.data_path = "tool_settings.uv_select_mode"
336
337             props = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
338             props.value = 'FACE'
339             props.data_path = "tool_settings.uv_select_mode"
340
341             props = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
342             props.value = 'ISLAND'
343             props.data_path = "tool_settings.uv_select_mode"
344
345
346 class IMAGE_HT_header(Header):
347     bl_space_type = 'IMAGE_EDITOR'
348
349     def draw(self, context):
350         layout = self.layout
351
352         sima = context.space_data
353         ima = sima.image
354         iuser = sima.image_user
355         toolsettings = context.tool_settings
356
357         show_render = sima.show_render
358         # show_paint = sima.show_paint
359         show_uvedit = sima.show_uvedit
360
361         row = layout.row(align=True)
362         row.template_header()
363
364         # menus
365         if context.area.show_menus:
366             sub = row.row(align=True)
367             sub.menu("IMAGE_MT_view")
368
369             if show_uvedit:
370                 sub.menu("IMAGE_MT_select")
371
372             if ima and ima.is_dirty:
373                 sub.menu("IMAGE_MT_image", text="Image*")
374             else:
375                 sub.menu("IMAGE_MT_image", text="Image")
376
377             if show_uvedit:
378                 sub.menu("IMAGE_MT_uvs")
379
380         layout.template_ID(sima, "image", new="image.new")
381         if not show_render:
382             layout.prop(sima, "use_image_pin", text="")
383
384         # uv editing
385         if show_uvedit:
386             uvedit = sima.uv_editor
387
388             layout.prop(uvedit, "pivot_point", text="", icon_only=True)
389             layout.prop(toolsettings, "use_uv_select_sync", text="")
390
391             if toolsettings.use_uv_select_sync:
392                 layout.template_edit_mode_selection()
393             else:
394                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
395                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
396
397             row = layout.row(align=True)
398             row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
399             if toolsettings.proportional_edit != 'DISABLED':
400                 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
401
402             row = layout.row(align=True)
403             row.prop(toolsettings, "use_snap", text="")
404             row.prop(toolsettings, "snap_target", text="")
405
406             mesh = context.edit_object.data
407             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
408
409         if ima:
410             # layers
411             layout.template_image_layers(ima, iuser)
412
413             # painting
414             layout.prop(sima, "use_image_paint", text="")
415
416             # draw options
417             row = layout.row(align=True)
418             row.prop(sima, "draw_channels", text="", expand=True)
419
420             row = layout.row(align=True)
421             if ima.type == 'COMPOSITE':
422                 row.operator("image.record_composite", icon='REC')
423             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
424                 row.operator("image.play_composite", icon='PLAY')
425
426         if show_uvedit or sima.use_image_paint:
427             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
428
429
430 class IMAGE_PT_display_properties(Panel):
431     bl_space_type = 'IMAGE_EDITOR'
432     bl_region_type = 'UI'
433     bl_label = "Display Properties"
434
435     def draw(self, context):
436         layout = self.layout
437
438         sima = context.space_data
439         window = context.window
440
441         layout.prop(window, "display_device", text="Display")
442         layout.prop(sima, "view_transform", text="View")
443
444
445 class IMAGE_PT_image_properties(Panel):
446     bl_space_type = 'IMAGE_EDITOR'
447     bl_region_type = 'UI'
448     bl_label = "Image"
449
450     @classmethod
451     def poll(cls, context):
452         sima = context.space_data
453         return (sima.image)
454
455     def draw(self, context):
456         layout = self.layout
457
458         sima = context.space_data
459         iuser = sima.image_user
460
461         layout.template_image(sima, "image", iuser)
462
463
464 class IMAGE_PT_game_properties(Panel):
465     bl_space_type = 'IMAGE_EDITOR'
466     bl_region_type = 'UI'
467     bl_label = "Game Properties"
468
469     @classmethod
470     def poll(cls, context):
471         sima = context.space_data
472         # display even when not in game mode because these settings effect the 3d view
473         return (sima and sima.image)  # and (rd.engine == 'BLENDER_GAME')
474
475     def draw(self, context):
476         layout = self.layout
477
478         sima = context.space_data
479         ima = sima.image
480
481         split = layout.split()
482
483         col = split.column()
484
485         col.prop(ima, "use_animation")
486         sub = col.column(align=True)
487         sub.active = ima.use_animation
488         sub.prop(ima, "frame_start", text="Start")
489         sub.prop(ima, "frame_end", text="End")
490         sub.prop(ima, "fps", text="Speed")
491
492         col.prop(ima, "use_tiles")
493         sub = col.column(align=True)
494         sub.active = ima.use_tiles or ima.use_animation
495         sub.prop(ima, "tiles_x", text="X")
496         sub.prop(ima, "tiles_y", text="Y")
497
498         col = split.column()
499         col.label(text="Clamp:")
500         col.prop(ima, "use_clamp_x", text="X")
501         col.prop(ima, "use_clamp_y", text="Y")
502         col.separator()
503         col.prop(ima, "mapping", expand=True)
504
505
506 class IMAGE_PT_view_histogram(Panel):
507     bl_space_type = 'IMAGE_EDITOR'
508     bl_region_type = 'PREVIEW'
509     bl_label = "Histogram"
510
511     @classmethod
512     def poll(cls, context):
513         sima = context.space_data
514         return (sima and sima.image)
515
516     def draw(self, context):
517         layout = self.layout
518
519         sima = context.space_data
520         hist = sima.scopes.histogram
521
522         layout.template_histogram(sima.scopes, "histogram")
523         row = layout.row(align=True)
524         row.prop(hist, "mode", icon_only=True, expand=True)
525         row.prop(hist, "show_line", text="")
526
527
528 class IMAGE_PT_view_waveform(Panel):
529     bl_space_type = 'IMAGE_EDITOR'
530     bl_region_type = 'PREVIEW'
531     bl_label = "Waveform"
532
533     @classmethod
534     def poll(cls, context):
535         sima = context.space_data
536         return (sima and sima.image)
537
538     def draw(self, context):
539         layout = self.layout
540
541         sima = context.space_data
542
543         layout.template_waveform(sima, "scopes")
544         row = layout.split(percentage=0.75)
545         row.prop(sima.scopes, "waveform_alpha")
546         row.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
547
548
549 class IMAGE_PT_view_vectorscope(Panel):
550     bl_space_type = 'IMAGE_EDITOR'
551     bl_region_type = 'PREVIEW'
552     bl_label = "Vectorscope"
553
554     @classmethod
555     def poll(cls, context):
556         sima = context.space_data
557         return (sima and sima.image)
558
559     def draw(self, context):
560         layout = self.layout
561
562         sima = context.space_data
563         layout.template_vectorscope(sima, "scopes")
564         layout.prop(sima.scopes, "vectorscope_alpha")
565
566
567 class IMAGE_PT_sample_line(Panel):
568     bl_space_type = 'IMAGE_EDITOR'
569     bl_region_type = 'PREVIEW'
570     bl_label = "Sample Line"
571
572     @classmethod
573     def poll(cls, context):
574         sima = context.space_data
575         return (sima and sima.image)
576
577     def draw(self, context):
578         layout = self.layout
579
580         sima = context.space_data
581         hist = sima.sample_histogram
582
583         layout.operator("image.sample_line")
584         layout.template_histogram(sima, "sample_histogram")
585         row = layout.row(align=True)
586         row.prop(hist, "mode", expand=True)
587         row.prop(hist, "show_line", text="")
588
589
590 class IMAGE_PT_scope_sample(Panel):
591     bl_space_type = 'IMAGE_EDITOR'
592     bl_region_type = 'PREVIEW'
593     bl_label = "Scope Samples"
594
595     @classmethod
596     def poll(cls, context):
597         sima = context.space_data
598         return sima
599
600     def draw(self, context):
601         layout = self.layout
602
603         sima = context.space_data
604
605         row = layout.row()
606         row.prop(sima.scopes, "use_full_resolution")
607         sub = row.row()
608         sub.active = not sima.scopes.use_full_resolution
609         sub.prop(sima.scopes, "accuracy")
610
611
612 class IMAGE_PT_view_properties(Panel):
613     bl_space_type = 'IMAGE_EDITOR'
614     bl_region_type = 'UI'
615     bl_label = "Display"
616
617     @classmethod
618     def poll(cls, context):
619         sima = context.space_data
620         return (sima and (sima.image or sima.show_uvedit))
621
622     def draw(self, context):
623         layout = self.layout
624
625         sima = context.space_data
626         ima = sima.image
627         show_uvedit = sima.show_uvedit
628         uvedit = sima.uv_editor
629
630         split = layout.split()
631
632         col = split.column()
633         if ima:
634             col.prop(ima, "display_aspect", text="Aspect Ratio")
635
636             col = split.column()
637             col.label(text="Coordinates:")
638             col.prop(sima, "show_repeat", text="Repeat")
639             if show_uvedit:
640                 col.prop(uvedit, "show_normalized_coords", text="Normalized")
641
642         elif show_uvedit:
643             col.label(text="Coordinates:")
644             col.prop(uvedit, "show_normalized_coords", text="Normalized")
645
646         if show_uvedit:
647
648             col = layout.column()
649             col.label("Cursor Location:")
650             col.row().prop(uvedit, "cursor_location", text="")
651
652             col.separator()
653
654             col.label(text="UVs:")
655             col.row().prop(uvedit, "edge_draw_type", expand=True)
656
657             split = layout.split()
658
659             col = split.column()
660             col.prop(uvedit, "show_faces")
661             col.prop(uvedit, "show_smooth_edges", text="Smooth")
662             col.prop(uvedit, "show_modified_edges", text="Modified")
663
664             col = split.column()
665             col.prop(uvedit, "show_stretch", text="Stretch")
666             sub = col.column()
667             sub.active = uvedit.show_stretch
668             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
669
670
671 class IMAGE_PT_paint(Panel, ImagePaintPanel):
672     bl_space_type = 'IMAGE_EDITOR'
673     bl_region_type = 'UI'
674     bl_label = "Paint"
675
676     @classmethod
677     def poll(cls, context):
678         sima = context.space_data
679         return sima.show_paint
680
681     def draw(self, context):
682         layout = self.layout
683
684         toolsettings = context.tool_settings.image_paint
685         brush = toolsettings.brush
686
687         col = layout.column()
688         col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6)
689
690         if brush:
691             col = layout.column()
692             col.template_color_wheel(brush, "color", value_slider=True)
693             col.prop(brush, "color", text="")
694
695             row = col.row(align=True)
696             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
697             self.prop_unified_size(row, context, brush, "use_pressure_size")
698
699             row = col.row(align=True)
700             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
701             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
702
703             row = col.row(align=True)
704             row.prop(brush, "jitter", slider=True)
705             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
706
707             col.prop(brush, "blend", text="Blend")
708
709             if brush.image_tool == 'CLONE':
710                 col.separator()
711                 col.prop(brush, "clone_image", text="Image")
712                 col.prop(brush, "clone_alpha", text="Alpha")
713
714
715 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
716     bl_label = "Texture"
717     bl_options = {'DEFAULT_CLOSED'}
718
719     def draw(self, context):
720         layout = self.layout
721
722         toolsettings = context.tool_settings.image_paint
723         brush = toolsettings.brush
724
725         col = layout.column()
726         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
727         col.prop(brush, "use_fixed_texture")
728
729
730 class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
731     bl_label = "Tool"
732     bl_options = {'DEFAULT_CLOSED'}
733
734     def draw(self, context):
735         layout = self.layout
736         toolsettings = context.tool_settings.image_paint
737         brush = toolsettings.brush
738
739         layout.prop(brush, "image_tool", text="")
740
741         row = layout.row(align=True)
742         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
743         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
744         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
745         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
746
747
748 class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
749     bl_label = "Paint Stroke"
750     bl_options = {'DEFAULT_CLOSED'}
751
752     def draw(self, context):
753         layout = self.layout
754
755         toolsettings = context.tool_settings.image_paint
756         brush = toolsettings.brush
757
758         layout.prop(brush, "use_airbrush")
759         row = layout.row()
760         row.active = brush.use_airbrush
761         row.prop(brush, "rate", slider=True)
762
763         layout.prop(brush, "use_space")
764         row = layout.row(align=True)
765         row.active = brush.use_space
766         row.prop(brush, "spacing", text="Distance", slider=True)
767         row.prop(brush, "use_pressure_spacing", toggle=True, text="")
768
769         layout.prop(brush, "use_wrap")
770
771
772 class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
773     bl_label = "Paint Curve"
774     bl_options = {'DEFAULT_CLOSED'}
775
776     def draw(self, context):
777         layout = self.layout
778
779         toolsettings = context.tool_settings.image_paint
780         brush = toolsettings.brush
781
782         layout.template_curve_mapping(brush, "curve")
783
784         row = layout.row(align=True)
785         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
786         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
787         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
788         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
789         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
790         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
791
792
793 class IMAGE_UV_sculpt_curve(Panel):
794     bl_space_type = 'IMAGE_EDITOR'
795     bl_region_type = 'UI'
796     bl_label = "UV Sculpt Curve"
797     bl_options = {'DEFAULT_CLOSED'}
798
799     @classmethod
800     def poll(cls, context):
801         sima = context.space_data
802         toolsettings = context.tool_settings.image_paint
803         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
804
805     def draw(self, context):
806         layout = self.layout
807
808         toolsettings = context.tool_settings
809         uvsculpt = toolsettings.uv_sculpt
810         brush = uvsculpt.brush
811
812         layout.template_curve_mapping(brush, "curve")
813
814         row = layout.row(align=True)
815         row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH'
816         row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND'
817         row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT'
818         row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP'
819         row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
820         row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
821
822
823 class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
824     bl_space_type = 'IMAGE_EDITOR'
825     bl_region_type = 'UI'
826     bl_label = "UV Sculpt"
827
828     @classmethod
829     def poll(cls, context):
830         sima = context.space_data
831         toolsettings = context.tool_settings.image_paint
832         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
833
834     def draw(self, context):
835         layout = self.layout
836
837         toolsettings = context.tool_settings
838         uvsculpt = toolsettings.uv_sculpt
839         brush = uvsculpt.brush
840
841         if brush:
842             col = layout.column()
843
844             row = col.row(align=True)
845             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
846             self.prop_unified_size(row, context, brush, "use_pressure_size")
847
848             row = col.row(align=True)
849             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
850             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
851
852         split = layout.split()
853         col = split.column()
854
855         col.prop(toolsettings, "uv_sculpt_lock_borders")
856         col.prop(toolsettings, "uv_sculpt_all_islands")
857
858         split = layout.split()
859         col = split.column()
860
861         col.prop(toolsettings, "uv_sculpt_tool")
862
863         if toolsettings.uv_sculpt_tool == 'RELAX':
864             col.prop(toolsettings, "uv_relax_method")
865
866
867 if __name__ == "__main__":  # only for live edit.
868     bpy.utils.register_module(__name__)