43535eb8c2ff1bc066ed045d94f5c338bb6761ae
[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 from bl_ui.properties_paint_common import brush_texture_settings
24
25
26 class ImagePaintPanel(UnifiedPaintPanel):
27     bl_space_type = 'IMAGE_EDITOR'
28     bl_region_type = 'UI'
29
30
31 class BrushButtonsPanel:
32     bl_space_type = 'IMAGE_EDITOR'
33     bl_region_type = 'UI'
34
35     @classmethod
36     def poll(cls, context):
37         sima = context.space_data
38         toolsettings = context.tool_settings.image_paint
39         return sima.show_paint and toolsettings.brush
40
41
42 class IMAGE_MT_view(Menu):
43     bl_label = "View"
44
45     def draw(self, context):
46         layout = self.layout
47
48         sima = context.space_data
49         uv = sima.uv_editor
50         toolsettings = context.tool_settings
51
52         show_uvedit = sima.show_uvedit
53
54         layout.operator("image.properties", icon='MENU_PANEL')
55         layout.operator("image.scopes", icon='MENU_PANEL')
56
57         layout.separator()
58
59         layout.prop(sima, "use_realtime_update")
60         if show_uvedit:
61             layout.prop(toolsettings, "show_uv_local_view")
62
63         layout.prop(uv, "show_other_objects")
64
65         layout.separator()
66
67         layout.operator("image.view_zoom_in")
68         layout.operator("image.view_zoom_out")
69
70         layout.separator()
71
72         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
73
74         pgettext = bpy.app.translations.pgettext
75         for a, b in ratios:
76             layout.operator("image.view_zoom_ratio", text=pgettext("Zoom %d:%d") % (a, b),
77                             translate=False).ratio = a / b
78
79         layout.separator()
80
81         if show_uvedit:
82             layout.operator("image.view_selected")
83
84         layout.operator("image.view_all")
85
86         layout.separator()
87
88         layout.operator("screen.area_dupli")
89         layout.operator("screen.screen_full_area")
90
91
92 class IMAGE_MT_select(Menu):
93     bl_label = "Select"
94
95     def draw(self, context):
96         layout = self.layout
97
98         layout.operator("uv.select_border").pinned = False
99         layout.operator("uv.select_border", text="Border Select Pinned").pinned = True
100
101         layout.separator()
102
103         layout.operator("uv.select_all").action = 'TOGGLE'
104         layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
105         layout.operator("uv.unlink_selected")
106
107         layout.separator()
108
109         layout.operator("uv.select_pinned")
110         layout.operator("uv.select_linked")
111
112         layout.separator()
113
114         layout.operator("uv.select_split")
115
116
117 class IMAGE_MT_image(Menu):
118     bl_label = "Image"
119
120     def draw(self, context):
121         layout = self.layout
122
123         sima = context.space_data
124         ima = sima.image
125
126         layout.operator("image.new")
127         layout.operator("image.open")
128
129         show_render = sima.show_render
130
131         if ima:
132             if not show_render:
133                 layout.operator("image.replace")
134                 layout.operator("image.reload")
135
136             layout.operator("image.save")
137             layout.operator("image.save_as")
138             layout.operator("image.save_as", text="Save a Copy").copy = True
139
140             if ima.source == 'SEQUENCE':
141                 layout.operator("image.save_sequence")
142
143             layout.operator("image.external_edit", "Edit Externally")
144
145             layout.separator()
146
147             layout.menu("IMAGE_MT_image_invert")
148
149             if not show_render:
150                 layout.separator()
151
152                 if not ima.packed_file:
153                     layout.operator("image.pack")
154
155                 # only for dirty && specific image types, perhaps
156                 # this could be done in operator poll too
157                 if ima.is_dirty:
158                     if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
159                         layout.operator("image.pack", text="Pack As PNG").as_png = True
160
161             layout.separator()
162
163
164 class IMAGE_MT_image_invert(Menu):
165     bl_label = "Invert"
166
167     def draw(self, context):
168         layout = self.layout
169
170         props = layout.operator("image.invert", text="Invert Image Colors")
171         props.invert_r = True
172         props.invert_g = True
173         props.invert_b = True
174
175         layout.separator()
176
177         props = layout.operator("image.invert", text="Invert Red Channel")
178         props.invert_r = True
179
180         props = layout.operator("image.invert", text="Invert Green Channel")
181         props.invert_g = True
182
183         props = layout.operator("image.invert", text="Invert Blue Channel")
184         props.invert_b = True
185
186         props = layout.operator("image.invert", text="Invert Alpha Channel")
187         props.invert_a = True
188
189
190 class IMAGE_MT_uvs_showhide(Menu):
191     bl_label = "Show/Hide Faces"
192
193     def draw(self, context):
194         layout = self.layout
195
196         layout.operator("uv.reveal")
197         layout.operator("uv.hide", text="Hide Selected").unselected = False
198         layout.operator("uv.hide", text="Hide Unselected").unselected = True
199
200
201 class IMAGE_MT_uvs_transform(Menu):
202     bl_label = "Transform"
203
204     def draw(self, context):
205         layout = self.layout
206
207         layout.operator("transform.translate")
208         layout.operator("transform.rotate")
209         layout.operator("transform.resize")
210
211         layout.separator()
212
213         layout.operator("transform.shear")
214
215
216 class IMAGE_MT_uvs_snap(Menu):
217     bl_label = "Snap"
218
219     def draw(self, context):
220         layout = self.layout
221
222         layout.operator_context = 'EXEC_REGION_WIN'
223
224         layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
225         layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
226         layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
227
228         layout.separator()
229
230         layout.operator("uv.snap_cursor", text="Cursor to Pixels").target = 'PIXELS'
231         layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED'
232
233
234 class IMAGE_MT_uvs_mirror(Menu):
235     bl_label = "Mirror"
236
237     def draw(self, context):
238         layout = self.layout
239
240         layout.operator_context = 'EXEC_REGION_WIN'
241
242         layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
243         layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True
244
245
246 class IMAGE_MT_uvs_weldalign(Menu):
247     bl_label = "Weld/Align"
248
249     def draw(self, context):
250         layout = self.layout
251
252         layout.operator("uv.weld")  # W, 1
253         layout.operator("uv.remove_doubles")
254         layout.operator_enum("uv.align", "axis")  # W, 2/3/4
255
256
257 class IMAGE_MT_uvs(Menu):
258     bl_label = "UVs"
259
260     def draw(self, context):
261         layout = self.layout
262
263         sima = context.space_data
264         uv = sima.uv_editor
265         toolsettings = context.tool_settings
266
267         layout.prop(uv, "use_snap_to_pixels")
268         layout.prop(uv, "lock_bounds")
269
270         layout.separator()
271
272         layout.prop(toolsettings, "use_uv_sculpt")
273
274         layout.separator()
275
276         layout.prop(uv, "use_live_unwrap")
277         layout.operator("uv.unwrap")
278         layout.operator("uv.pin", text="Unpin").clear = True
279         layout.operator("uv.pin")
280
281         layout.separator()
282
283         layout.operator("uv.pack_islands")
284         layout.operator("uv.average_islands_scale")
285         layout.operator("uv.minimize_stretch")
286         layout.operator("uv.stitch")
287         layout.operator("uv.mark_seam")
288         layout.operator("uv.seams_from_islands")
289         layout.operator("mesh.faces_mirror_uv")
290
291         layout.separator()
292
293         layout.menu("IMAGE_MT_uvs_transform")
294         layout.menu("IMAGE_MT_uvs_mirror")
295         layout.menu("IMAGE_MT_uvs_snap")
296         layout.menu("IMAGE_MT_uvs_weldalign")
297
298         layout.separator()
299
300         layout.prop_menu_enum(toolsettings, "proportional_edit")
301         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
302
303         layout.separator()
304
305         layout.menu("IMAGE_MT_uvs_showhide")
306
307
308 class IMAGE_MT_uvs_select_mode(Menu):
309     bl_label = "UV Select Mode"
310
311     def draw(self, context):
312         layout = self.layout
313
314         layout.operator_context = 'INVOKE_REGION_WIN'
315         toolsettings = context.tool_settings
316
317         # do smart things depending on whether uv_select_sync is on
318
319         if toolsettings.use_uv_select_sync:
320             props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
321             props.value = "(True, False, False)"
322             props.data_path = "tool_settings.mesh_select_mode"
323
324             props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
325             props.value = "(False, True, False)"
326             props.data_path = "tool_settings.mesh_select_mode"
327
328             props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
329             props.value = "(False, False, True)"
330             props.data_path = "tool_settings.mesh_select_mode"
331
332         else:
333             props = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
334             props.value = 'VERTEX'
335             props.data_path = "tool_settings.uv_select_mode"
336
337             props = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
338             props.value = 'EDGE'
339             props.data_path = "tool_settings.uv_select_mode"
340
341             props = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
342             props.value = 'FACE'
343             props.data_path = "tool_settings.uv_select_mode"
344
345             props = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
346             props.value = 'ISLAND'
347             props.data_path = "tool_settings.uv_select_mode"
348
349
350 class IMAGE_HT_header(Header):
351     bl_space_type = 'IMAGE_EDITOR'
352
353     def draw(self, context):
354         layout = self.layout
355
356         sima = context.space_data
357         ima = sima.image
358         iuser = sima.image_user
359         toolsettings = context.tool_settings
360         mode = sima.mode
361
362         show_render = sima.show_render
363         # show_paint = sima.show_paint
364         show_uvedit = sima.show_uvedit
365         show_maskedit = sima.show_maskedit
366
367         row = layout.row(align=True)
368         row.template_header()
369
370         # menus
371         if context.area.show_menus:
372             sub = row.row(align=True)
373             sub.menu("IMAGE_MT_view")
374
375             if show_uvedit:
376                 sub.menu("IMAGE_MT_select")
377
378             if ima and ima.is_dirty:
379                 sub.menu("IMAGE_MT_image", text="Image*")
380             else:
381                 sub.menu("IMAGE_MT_image", text="Image")
382
383             if show_uvedit:
384                 sub.menu("IMAGE_MT_uvs")
385
386         layout.template_ID(sima, "image", new="image.new")
387         if not show_render:
388             layout.prop(sima, "use_image_pin", text="")
389
390         layout.prop(sima, "mode", text="")
391
392         if show_maskedit:
393             row = layout.row()
394             row.template_ID(sima, "mask", new="mask.new")
395
396         if show_uvedit or show_maskedit:
397             layout.prop(sima, "pivot_point", text="", icon_only=True)
398
399         # uv editing
400         if show_uvedit:
401             uvedit = sima.uv_editor
402
403             layout.prop(toolsettings, "use_uv_select_sync", text="")
404
405             if toolsettings.use_uv_select_sync:
406                 layout.template_edit_mode_selection()
407             else:
408                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
409                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
410
411             row = layout.row(align=True)
412             row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
413             if toolsettings.proportional_edit != 'DISABLED':
414                 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
415
416             row = layout.row(align=True)
417             row.prop(toolsettings, "use_snap", text="")
418             row.prop(toolsettings, "snap_uv_element", text="", icon_only=True)
419             if toolsettings.snap_uv_element != 'INCREMENT':
420                 row.prop(toolsettings, "snap_target", text="")
421
422             mesh = context.edit_object.data
423             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
424
425         if ima:
426             # layers
427             layout.template_image_layers(ima, iuser)
428
429             # draw options
430             row = layout.row(align=True)
431             row.prop(sima, "draw_channels", text="", expand=True)
432
433             row = layout.row(align=True)
434             if ima.type == 'COMPOSITE':
435                 row.operator("image.record_composite", icon='REC')
436             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
437                 row.operator("image.play_composite", icon='PLAY')
438
439         if show_uvedit or show_maskedit or mode == 'PAINT':
440             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
441
442
443 class IMAGE_PT_image_properties(Panel):
444     bl_space_type = 'IMAGE_EDITOR'
445     bl_region_type = 'UI'
446     bl_label = "Image"
447
448     @classmethod
449     def poll(cls, context):
450         sima = context.space_data
451         return (sima.image)
452
453     def draw(self, context):
454         layout = self.layout
455
456         sima = context.space_data
457         iuser = sima.image_user
458
459         layout.template_image(sima, "image", iuser)
460
461
462 class IMAGE_PT_game_properties(Panel):
463     bl_space_type = 'IMAGE_EDITOR'
464     bl_region_type = 'UI'
465     bl_label = "Game Properties"
466
467     @classmethod
468     def poll(cls, context):
469         sima = context.space_data
470         # display even when not in game mode because these settings effect the 3d view
471         return (sima and sima.image)  # and (rd.engine == 'BLENDER_GAME')
472
473     def draw(self, context):
474         layout = self.layout
475
476         sima = context.space_data
477         ima = sima.image
478
479         split = layout.split()
480
481         col = split.column()
482
483         col.prop(ima, "use_animation")
484         sub = col.column(align=True)
485         sub.active = ima.use_animation
486         sub.prop(ima, "frame_start", text="Start")
487         sub.prop(ima, "frame_end", text="End")
488         sub.prop(ima, "fps", text="Speed")
489
490         col.prop(ima, "use_tiles")
491         sub = col.column(align=True)
492         sub.active = ima.use_tiles or ima.use_animation
493         sub.prop(ima, "tiles_x", text="X")
494         sub.prop(ima, "tiles_y", text="Y")
495
496         col = split.column()
497         col.label(text="Clamp:")
498         col.prop(ima, "use_clamp_x", text="X")
499         col.prop(ima, "use_clamp_y", text="Y")
500         col.separator()
501         col.prop(ima, "mapping", expand=True)
502
503
504 class IMAGE_PT_view_histogram(Panel):
505     bl_space_type = 'IMAGE_EDITOR'
506     bl_region_type = 'PREVIEW'
507     bl_label = "Histogram"
508
509     @classmethod
510     def poll(cls, context):
511         sima = context.space_data
512         return (sima and sima.image)
513
514     def draw(self, context):
515         layout = self.layout
516
517         sima = context.space_data
518         hist = sima.scopes.histogram
519
520         layout.template_histogram(sima.scopes, "histogram")
521         row = layout.row(align=True)
522         row.prop(hist, "mode", icon_only=True, expand=True)
523         row.prop(hist, "show_line", text="")
524
525
526 class IMAGE_PT_view_waveform(Panel):
527     bl_space_type = 'IMAGE_EDITOR'
528     bl_region_type = 'PREVIEW'
529     bl_label = "Waveform"
530
531     @classmethod
532     def poll(cls, context):
533         sima = context.space_data
534         return (sima and sima.image)
535
536     def draw(self, context):
537         layout = self.layout
538
539         sima = context.space_data
540
541         layout.template_waveform(sima, "scopes")
542         row = layout.split(percentage=0.75)
543         row.prop(sima.scopes, "waveform_alpha")
544         row.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
545
546
547 class IMAGE_PT_view_vectorscope(Panel):
548     bl_space_type = 'IMAGE_EDITOR'
549     bl_region_type = 'PREVIEW'
550     bl_label = "Vectorscope"
551
552     @classmethod
553     def poll(cls, context):
554         sima = context.space_data
555         return (sima and sima.image)
556
557     def draw(self, context):
558         layout = self.layout
559
560         sima = context.space_data
561         layout.template_vectorscope(sima, "scopes")
562         layout.prop(sima.scopes, "vectorscope_alpha")
563
564
565 class IMAGE_PT_sample_line(Panel):
566     bl_space_type = 'IMAGE_EDITOR'
567     bl_region_type = 'PREVIEW'
568     bl_label = "Sample Line"
569
570     @classmethod
571     def poll(cls, context):
572         sima = context.space_data
573         return (sima and sima.image)
574
575     def draw(self, context):
576         layout = self.layout
577
578         sima = context.space_data
579         hist = sima.sample_histogram
580
581         layout.operator("image.sample_line")
582         layout.template_histogram(sima, "sample_histogram")
583         row = layout.row(align=True)
584         row.prop(hist, "mode", expand=True)
585         row.prop(hist, "show_line", text="")
586
587
588 class IMAGE_PT_scope_sample(Panel):
589     bl_space_type = 'IMAGE_EDITOR'
590     bl_region_type = 'PREVIEW'
591     bl_label = "Scope Samples"
592
593     @classmethod
594     def poll(cls, context):
595         sima = context.space_data
596         return sima
597
598     def draw(self, context):
599         layout = self.layout
600
601         sima = context.space_data
602
603         row = layout.row()
604         row.prop(sima.scopes, "use_full_resolution")
605         sub = row.row()
606         sub.active = not sima.scopes.use_full_resolution
607         sub.prop(sima.scopes, "accuracy")
608
609
610 class IMAGE_PT_view_properties(Panel):
611     bl_space_type = 'IMAGE_EDITOR'
612     bl_region_type = 'UI'
613     bl_label = "Display"
614
615     @classmethod
616     def poll(cls, context):
617         sima = context.space_data
618         return (sima and (sima.image or sima.show_uvedit))
619
620     def draw(self, context):
621         layout = self.layout
622
623         sima = context.space_data
624         ima = sima.image
625         show_uvedit = sima.show_uvedit
626         show_maskedit = sima.show_maskedit
627         uvedit = sima.uv_editor
628
629         split = layout.split()
630
631         col = split.column()
632         if ima:
633             col.prop(ima, "display_aspect", text="Aspect Ratio")
634
635             col = split.column()
636             col.label(text="Coordinates:")
637             col.prop(sima, "show_repeat", text="Repeat")
638             if show_uvedit:
639                 col.prop(uvedit, "show_normalized_coords", text="Normalized")
640
641         elif show_uvedit:
642             col.label(text="Coordinates:")
643             col.prop(uvedit, "show_normalized_coords", text="Normalized")
644
645         if show_uvedit or show_maskedit:
646             col = layout.column()
647             col.label("Cursor Location:")
648             col.row().prop(sima, "cursor_location", text="")
649
650         if show_uvedit:
651             col.separator()
652
653             col.label(text="UVs:")
654             col.row().prop(uvedit, "edge_draw_type", expand=True)
655
656             split = layout.split()
657
658             col = split.column()
659             col.prop(uvedit, "show_faces")
660             col.prop(uvedit, "show_smooth_edges", text="Smooth")
661             col.prop(uvedit, "show_modified_edges", text="Modified")
662
663             col = split.column()
664             col.prop(uvedit, "show_stretch", text="Stretch")
665             sub = col.column()
666             sub.active = uvedit.show_stretch
667             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
668
669
670 class IMAGE_PT_paint(Panel, ImagePaintPanel):
671     bl_space_type = 'IMAGE_EDITOR'
672     bl_region_type = 'UI'
673     bl_label = "Paint"
674
675     @classmethod
676     def poll(cls, context):
677         sima = context.space_data
678         return sima.show_paint
679
680     def draw(self, context):
681         layout = self.layout
682
683         toolsettings = context.tool_settings.image_paint
684         brush = toolsettings.brush
685
686         col = layout.column()
687         col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6)
688
689         if brush:
690             col = layout.column()
691             col.template_color_picker(brush, "color", value_slider=True)
692             col.prop(brush, "color", text="")
693
694             row = col.row(align=True)
695             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
696             self.prop_unified_size(row, context, brush, "use_pressure_size")
697
698             row = col.row(align=True)
699             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
700             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
701
702             row = col.row(align=True)
703             row.prop(brush, "jitter", slider=True)
704             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
705
706             col.prop(brush, "blend", text="Blend")
707
708             if brush.image_tool == 'CLONE':
709                 col.separator()
710                 col.prop(brush, "clone_image", text="Image")
711                 col.prop(brush, "clone_alpha", text="Alpha")
712
713
714 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
715     bl_label = "Texture"
716     bl_options = {'DEFAULT_CLOSED'}
717
718     def draw(self, context):
719         layout = self.layout
720
721         toolsettings = context.tool_settings.image_paint
722         brush = toolsettings.brush
723
724         col = layout.column()
725         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
726
727         brush_texture_settings(col, brush, 0)
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         col = layout.column()
853         col.prop(toolsettings, "uv_sculpt_lock_borders")
854         col.prop(toolsettings, "uv_sculpt_all_islands")
855         col.prop(toolsettings, "uv_sculpt_tool")
856
857         if toolsettings.uv_sculpt_tool == 'RELAX':
858             col.prop(toolsettings, "uv_relax_method")
859
860
861 # -----------------------------------------------------------------------------
862 # Mask (similar code in space_clip.py, keep in sync)
863 # note! - panel placement does _not_ fit well with image panels... need to fix
864
865 from bl_ui.properties_mask_common import (MASK_PT_mask,
866                                           MASK_PT_layers,
867                                           MASK_PT_spline,
868                                           MASK_PT_point,
869                                           MASK_PT_display,
870                                           MASK_PT_tools)
871
872
873 class IMAGE_PT_mask(MASK_PT_mask, Panel):
874     bl_space_type = 'IMAGE_EDITOR'
875     bl_region_type = 'PREVIEW'
876
877
878 class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
879     bl_space_type = 'IMAGE_EDITOR'
880     bl_region_type = 'PREVIEW'
881
882
883 class IMAGE_PT_mask_display(MASK_PT_display, Panel):
884     bl_space_type = 'IMAGE_EDITOR'
885     bl_region_type = 'PREVIEW'
886
887
888 class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
889     bl_space_type = 'IMAGE_EDITOR'
890     bl_region_type = 'PREVIEW'
891
892
893 class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
894     bl_space_type = 'IMAGE_EDITOR'
895     bl_region_type = 'PREVIEW'
896
897
898 class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
899     bl_space_type = 'IMAGE_EDITOR'
900     bl_region_type = 'UI'  # is 'TOOLS' in the clip editor
901
902 # --- end mask ---
903
904 if __name__ == "__main__":  # only for live edit.
905     bpy.utils.register_module(__name__)