svn merge ^/trunk/blender -r49601:49620
[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             layout.separator()
157
158
159 class IMAGE_MT_image_invert(Menu):
160     bl_label = "Invert"
161
162     def draw(self, context):
163         layout = self.layout
164
165         props = layout.operator("image.invert", text="Invert Image Colors")
166         props.invert_r = True
167         props.invert_g = True
168         props.invert_b = True
169
170         layout.separator()
171
172         props = layout.operator("image.invert", text="Invert Red Channel")
173         props.invert_r = True
174
175         props = layout.operator("image.invert", text="Invert Green Channel")
176         props.invert_g = True
177
178         props = layout.operator("image.invert", text="Invert Blue Channel")
179         props.invert_b = True
180
181         props = layout.operator("image.invert", text="Invert Alpha Channel")
182         props.invert_a = True
183
184
185 class IMAGE_MT_uvs_showhide(Menu):
186     bl_label = "Show/Hide Faces"
187
188     def draw(self, context):
189         layout = self.layout
190
191         layout.operator("uv.reveal")
192         layout.operator("uv.hide", text="Hide Selected").unselected = False
193         layout.operator("uv.hide", text="Hide Unselected").unselected = True
194
195
196 class IMAGE_MT_uvs_transform(Menu):
197     bl_label = "Transform"
198
199     def draw(self, context):
200         layout = self.layout
201
202         layout.operator("transform.translate")
203         layout.operator("transform.rotate")
204         layout.operator("transform.resize")
205
206         layout.separator()
207
208         layout.operator("transform.shear")
209
210
211 class IMAGE_MT_uvs_snap(Menu):
212     bl_label = "Snap"
213
214     def draw(self, context):
215         layout = self.layout
216
217         layout.operator_context = 'EXEC_REGION_WIN'
218
219         layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
220         layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
221         layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
222
223         layout.separator()
224
225         layout.operator("uv.snap_cursor", text="Cursor to Pixels").target = 'PIXELS'
226         layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED'
227
228
229 class IMAGE_MT_uvs_mirror(Menu):
230     bl_label = "Mirror"
231
232     def draw(self, context):
233         layout = self.layout
234
235         layout.operator_context = 'EXEC_REGION_WIN'
236
237         layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
238         layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True
239
240
241 class IMAGE_MT_uvs_weldalign(Menu):
242     bl_label = "Weld/Align"
243
244     def draw(self, context):
245         layout = self.layout
246
247         layout.operator("uv.weld")  # W, 1
248         layout.operator_enum("uv.align", "axis")  # W, 2/3/4
249
250
251 class IMAGE_MT_uvs(Menu):
252     bl_label = "UVs"
253
254     def draw(self, context):
255         layout = self.layout
256
257         sima = context.space_data
258         uv = sima.uv_editor
259         toolsettings = context.tool_settings
260
261         layout.prop(uv, "use_snap_to_pixels")
262         layout.prop(uv, "lock_bounds")
263
264         layout.separator()
265
266         layout.prop(toolsettings, "use_uv_sculpt")
267
268         layout.separator()
269
270         layout.prop(uv, "use_live_unwrap")
271         layout.operator("uv.unwrap")
272         layout.operator("uv.pin", text="Unpin").clear = True
273         layout.operator("uv.pin")
274
275         layout.separator()
276
277         layout.operator("uv.pack_islands")
278         layout.operator("uv.average_islands_scale")
279         layout.operator("uv.minimize_stretch")
280         layout.operator("uv.stitch")
281         layout.operator("uv.mark_seam")
282         layout.operator("uv.seams_from_islands")
283         layout.operator("mesh.faces_mirror_uv")
284
285         layout.separator()
286
287         layout.menu("IMAGE_MT_uvs_transform")
288         layout.menu("IMAGE_MT_uvs_mirror")
289         layout.menu("IMAGE_MT_uvs_snap")
290         layout.menu("IMAGE_MT_uvs_weldalign")
291
292         layout.separator()
293
294         layout.prop_menu_enum(toolsettings, "proportional_edit")
295         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
296
297         layout.separator()
298
299         layout.menu("IMAGE_MT_uvs_showhide")
300
301
302 class IMAGE_MT_uvs_select_mode(Menu):
303     bl_label = "UV Select Mode"
304
305     def draw(self, context):
306         layout = self.layout
307
308         layout.operator_context = 'INVOKE_REGION_WIN'
309         toolsettings = context.tool_settings
310
311         # do smart things depending on whether uv_select_sync is on
312
313         if toolsettings.use_uv_select_sync:
314             props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
315             props.value = "(True, False, False)"
316             props.data_path = "tool_settings.mesh_select_mode"
317
318             props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
319             props.value = "(False, True, False)"
320             props.data_path = "tool_settings.mesh_select_mode"
321
322             props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
323             props.value = "(False, False, True)"
324             props.data_path = "tool_settings.mesh_select_mode"
325
326         else:
327             props = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
328             props.value = 'VERTEX'
329             props.data_path = "tool_settings.uv_select_mode"
330
331             props = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
332             props.value = 'EDGE'
333             props.data_path = "tool_settings.uv_select_mode"
334
335             props = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
336             props.value = 'FACE'
337             props.data_path = "tool_settings.uv_select_mode"
338
339             props = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
340             props.value = 'ISLAND'
341             props.data_path = "tool_settings.uv_select_mode"
342
343
344 class IMAGE_HT_header(Header):
345     bl_space_type = 'IMAGE_EDITOR'
346
347     def draw(self, context):
348         layout = self.layout
349
350         sima = context.space_data
351         ima = sima.image
352         iuser = sima.image_user
353         toolsettings = context.tool_settings
354         mode = sima.mode
355
356         show_render = sima.show_render
357         # show_paint = sima.show_paint
358         show_uvedit = sima.show_uvedit
359         show_maskedit = sima.show_maskedit
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         layout.prop(sima, "mode", text="")
385
386         if show_maskedit:
387             row = layout.row()
388             row.template_ID(sima, "mask", new="mask.new")
389
390         if show_uvedit or show_maskedit:
391             layout.prop(sima, "pivot_point", text="", icon_only=True)
392
393         # uv editing
394         if show_uvedit:
395             uvedit = sima.uv_editor
396
397             layout.prop(toolsettings, "use_uv_select_sync", text="")
398
399             if toolsettings.use_uv_select_sync:
400                 layout.template_edit_mode_selection()
401             else:
402                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
403                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
404
405             row = layout.row(align=True)
406             row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
407             if toolsettings.proportional_edit != 'DISABLED':
408                 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
409
410             row = layout.row(align=True)
411             row.prop(toolsettings, "use_snap", text="")
412             row.prop(toolsettings, "snap_target", text="")
413
414             mesh = context.edit_object.data
415             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
416
417         if ima:
418             # layers
419             layout.template_image_layers(ima, iuser)
420
421             # draw options
422             row = layout.row(align=True)
423             row.prop(sima, "draw_channels", text="", expand=True)
424
425             row = layout.row(align=True)
426             if ima.type == 'COMPOSITE':
427                 row.operator("image.record_composite", icon='REC')
428             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
429                 row.operator("image.play_composite", icon='PLAY')
430
431         if show_uvedit or show_maskedit or mode == 'PAINT':
432             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
433
434
435 class IMAGE_PT_display_properties(Panel):
436     bl_space_type = 'IMAGE_EDITOR'
437     bl_region_type = 'UI'
438     bl_label = "Display Properties"
439
440     def draw(self, context):
441         layout = self.layout
442         space = context.space_data
443
444         layout.template_colormanaged_view_settings(space, "view_settings", True)
445
446
447 class IMAGE_PT_image_properties(Panel):
448     bl_space_type = 'IMAGE_EDITOR'
449     bl_region_type = 'UI'
450     bl_label = "Image"
451
452     @classmethod
453     def poll(cls, context):
454         sima = context.space_data
455         return (sima.image)
456
457     def draw(self, context):
458         layout = self.layout
459
460         sima = context.space_data
461         iuser = sima.image_user
462
463         layout.template_image(sima, "image", iuser)
464
465
466 class IMAGE_PT_game_properties(Panel):
467     bl_space_type = 'IMAGE_EDITOR'
468     bl_region_type = 'UI'
469     bl_label = "Game Properties"
470
471     @classmethod
472     def poll(cls, context):
473         sima = context.space_data
474         # display even when not in game mode because these settings effect the 3d view
475         return (sima and sima.image)  # and (rd.engine == 'BLENDER_GAME')
476
477     def draw(self, context):
478         layout = self.layout
479
480         sima = context.space_data
481         ima = sima.image
482
483         split = layout.split()
484
485         col = split.column()
486
487         col.prop(ima, "use_animation")
488         sub = col.column(align=True)
489         sub.active = ima.use_animation
490         sub.prop(ima, "frame_start", text="Start")
491         sub.prop(ima, "frame_end", text="End")
492         sub.prop(ima, "fps", text="Speed")
493
494         col.prop(ima, "use_tiles")
495         sub = col.column(align=True)
496         sub.active = ima.use_tiles or ima.use_animation
497         sub.prop(ima, "tiles_x", text="X")
498         sub.prop(ima, "tiles_y", text="Y")
499
500         col = split.column()
501         col.label(text="Clamp:")
502         col.prop(ima, "use_clamp_x", text="X")
503         col.prop(ima, "use_clamp_y", text="Y")
504         col.separator()
505         col.prop(ima, "mapping", expand=True)
506
507
508 class IMAGE_PT_view_histogram(Panel):
509     bl_space_type = 'IMAGE_EDITOR'
510     bl_region_type = 'PREVIEW'
511     bl_label = "Histogram"
512
513     @classmethod
514     def poll(cls, context):
515         sima = context.space_data
516         return (sima and sima.image)
517
518     def draw(self, context):
519         layout = self.layout
520
521         sima = context.space_data
522         hist = sima.scopes.histogram
523
524         layout.template_histogram(sima.scopes, "histogram")
525         row = layout.row(align=True)
526         row.prop(hist, "mode", icon_only=True, expand=True)
527         row.prop(hist, "show_line", text="")
528
529
530 class IMAGE_PT_view_waveform(Panel):
531     bl_space_type = 'IMAGE_EDITOR'
532     bl_region_type = 'PREVIEW'
533     bl_label = "Waveform"
534
535     @classmethod
536     def poll(cls, context):
537         sima = context.space_data
538         return (sima and sima.image)
539
540     def draw(self, context):
541         layout = self.layout
542
543         sima = context.space_data
544
545         layout.template_waveform(sima, "scopes")
546         row = layout.split(percentage=0.75)
547         row.prop(sima.scopes, "waveform_alpha")
548         row.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
549
550
551 class IMAGE_PT_view_vectorscope(Panel):
552     bl_space_type = 'IMAGE_EDITOR'
553     bl_region_type = 'PREVIEW'
554     bl_label = "Vectorscope"
555
556     @classmethod
557     def poll(cls, context):
558         sima = context.space_data
559         return (sima and sima.image)
560
561     def draw(self, context):
562         layout = self.layout
563
564         sima = context.space_data
565         layout.template_vectorscope(sima, "scopes")
566         layout.prop(sima.scopes, "vectorscope_alpha")
567
568
569 class IMAGE_PT_sample_line(Panel):
570     bl_space_type = 'IMAGE_EDITOR'
571     bl_region_type = 'PREVIEW'
572     bl_label = "Sample Line"
573
574     @classmethod
575     def poll(cls, context):
576         sima = context.space_data
577         return (sima and sima.image)
578
579     def draw(self, context):
580         layout = self.layout
581
582         sima = context.space_data
583         hist = sima.sample_histogram
584
585         layout.operator("image.sample_line")
586         layout.template_histogram(sima, "sample_histogram")
587         row = layout.row(align=True)
588         row.prop(hist, "mode", expand=True)
589         row.prop(hist, "show_line", text="")
590
591
592 class IMAGE_PT_scope_sample(Panel):
593     bl_space_type = 'IMAGE_EDITOR'
594     bl_region_type = 'PREVIEW'
595     bl_label = "Scope Samples"
596
597     @classmethod
598     def poll(cls, context):
599         sima = context.space_data
600         return sima
601
602     def draw(self, context):
603         layout = self.layout
604
605         sima = context.space_data
606
607         row = layout.row()
608         row.prop(sima.scopes, "use_full_resolution")
609         sub = row.row()
610         sub.active = not sima.scopes.use_full_resolution
611         sub.prop(sima.scopes, "accuracy")
612
613
614 class IMAGE_PT_view_properties(Panel):
615     bl_space_type = 'IMAGE_EDITOR'
616     bl_region_type = 'UI'
617     bl_label = "Display"
618
619     @classmethod
620     def poll(cls, context):
621         sima = context.space_data
622         return (sima and (sima.image or sima.show_uvedit))
623
624     def draw(self, context):
625         layout = self.layout
626
627         sima = context.space_data
628         ima = sima.image
629         show_uvedit = sima.show_uvedit
630         show_maskedit = sima.show_maskedit
631         uvedit = sima.uv_editor
632
633         split = layout.split()
634
635         col = split.column()
636         if ima:
637             col.prop(ima, "display_aspect", text="Aspect Ratio")
638
639             col = split.column()
640             col.label(text="Coordinates:")
641             col.prop(sima, "show_repeat", text="Repeat")
642             if show_uvedit:
643                 col.prop(uvedit, "show_normalized_coords", text="Normalized")
644
645         elif show_uvedit:
646             col.label(text="Coordinates:")
647             col.prop(uvedit, "show_normalized_coords", text="Normalized")
648
649         if show_uvedit or show_maskedit:
650             col = layout.column()
651             col.label("Cursor Location:")
652             col.row().prop(sima, "cursor_location", text="")
653
654         if show_uvedit:
655             col.separator()
656
657             col.label(text="UVs:")
658             col.row().prop(uvedit, "edge_draw_type", expand=True)
659
660             split = layout.split()
661
662             col = split.column()
663             col.prop(uvedit, "show_faces")
664             col.prop(uvedit, "show_smooth_edges", text="Smooth")
665             col.prop(uvedit, "show_modified_edges", text="Modified")
666
667             col = split.column()
668             col.prop(uvedit, "show_stretch", text="Stretch")
669             sub = col.column()
670             sub.active = uvedit.show_stretch
671             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
672
673
674 class IMAGE_PT_paint(Panel, ImagePaintPanel):
675     bl_space_type = 'IMAGE_EDITOR'
676     bl_region_type = 'UI'
677     bl_label = "Paint"
678
679     @classmethod
680     def poll(cls, context):
681         sima = context.space_data
682         return sima.show_paint
683
684     def draw(self, context):
685         layout = self.layout
686
687         toolsettings = context.tool_settings.image_paint
688         brush = toolsettings.brush
689
690         col = layout.column()
691         col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6)
692
693         if brush:
694             col = layout.column()
695             col.template_color_wheel(brush, "color", value_slider=True)
696             col.prop(brush, "color", text="")
697
698             row = col.row(align=True)
699             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
700             self.prop_unified_size(row, context, brush, "use_pressure_size")
701
702             row = col.row(align=True)
703             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
704             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
705
706             row = col.row(align=True)
707             row.prop(brush, "jitter", slider=True)
708             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
709
710             col.prop(brush, "blend", text="Blend")
711
712             if brush.image_tool == 'CLONE':
713                 col.separator()
714                 col.prop(brush, "clone_image", text="Image")
715                 col.prop(brush, "clone_alpha", text="Alpha")
716
717
718 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
719     bl_label = "Texture"
720     bl_options = {'DEFAULT_CLOSED'}
721
722     def draw(self, context):
723         layout = self.layout
724
725         toolsettings = context.tool_settings.image_paint
726         brush = toolsettings.brush
727
728         col = layout.column()
729         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
730         col.prop(brush, "use_fixed_texture")
731
732
733 class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
734     bl_label = "Tool"
735     bl_options = {'DEFAULT_CLOSED'}
736
737     def draw(self, context):
738         layout = self.layout
739         toolsettings = context.tool_settings.image_paint
740         brush = toolsettings.brush
741
742         layout.prop(brush, "image_tool", text="")
743
744         row = layout.row(align=True)
745         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
746         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
747         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
748         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
749
750
751 class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
752     bl_label = "Paint Stroke"
753     bl_options = {'DEFAULT_CLOSED'}
754
755     def draw(self, context):
756         layout = self.layout
757
758         toolsettings = context.tool_settings.image_paint
759         brush = toolsettings.brush
760
761         layout.prop(brush, "use_airbrush")
762         row = layout.row()
763         row.active = brush.use_airbrush
764         row.prop(brush, "rate", slider=True)
765
766         layout.prop(brush, "use_space")
767         row = layout.row(align=True)
768         row.active = brush.use_space
769         row.prop(brush, "spacing", text="Distance", slider=True)
770         row.prop(brush, "use_pressure_spacing", toggle=True, text="")
771
772         layout.prop(brush, "use_wrap")
773
774
775 class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
776     bl_label = "Paint Curve"
777     bl_options = {'DEFAULT_CLOSED'}
778
779     def draw(self, context):
780         layout = self.layout
781
782         toolsettings = context.tool_settings.image_paint
783         brush = toolsettings.brush
784
785         layout.template_curve_mapping(brush, "curve")
786
787         row = layout.row(align=True)
788         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
789         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
790         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
791         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
792         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
793         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
794
795
796 class IMAGE_UV_sculpt_curve(Panel):
797     bl_space_type = 'IMAGE_EDITOR'
798     bl_region_type = 'UI'
799     bl_label = "UV Sculpt Curve"
800     bl_options = {'DEFAULT_CLOSED'}
801
802     @classmethod
803     def poll(cls, context):
804         sima = context.space_data
805         toolsettings = context.tool_settings.image_paint
806         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
807
808     def draw(self, context):
809         layout = self.layout
810
811         toolsettings = context.tool_settings
812         uvsculpt = toolsettings.uv_sculpt
813         brush = uvsculpt.brush
814
815         layout.template_curve_mapping(brush, "curve")
816
817         row = layout.row(align=True)
818         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
819         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
820         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
821         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
822         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
823         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
824
825
826 class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
827     bl_space_type = 'IMAGE_EDITOR'
828     bl_region_type = 'UI'
829     bl_label = "UV Sculpt"
830
831     @classmethod
832     def poll(cls, context):
833         sima = context.space_data
834         toolsettings = context.tool_settings.image_paint
835         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
836
837     def draw(self, context):
838         layout = self.layout
839
840         toolsettings = context.tool_settings
841         uvsculpt = toolsettings.uv_sculpt
842         brush = uvsculpt.brush
843
844         if brush:
845             col = layout.column()
846
847             row = col.row(align=True)
848             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
849             self.prop_unified_size(row, context, brush, "use_pressure_size")
850
851             row = col.row(align=True)
852             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
853             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
854
855         col = layout.column()
856         col.prop(toolsettings, "uv_sculpt_lock_borders")
857         col.prop(toolsettings, "uv_sculpt_all_islands")
858         col.prop(toolsettings, "uv_sculpt_tool")
859
860         if toolsettings.uv_sculpt_tool == 'RELAX':
861             col.prop(toolsettings, "uv_relax_method")
862
863
864 # -----------------------------------------------------------------------------
865 # Mask (similar code in space_clip.py, keep in sync)
866 # note! - panel placement does _not_ fit well with image panels... need to fix
867
868 from bl_ui.properties_mask_common import (MASK_PT_mask,
869                                           MASK_PT_layers,
870                                           MASK_PT_spline,
871                                           MASK_PT_point,
872                                           MASK_PT_display,
873                                           MASK_PT_tools)
874
875
876 class IMAGE_PT_mask(MASK_PT_mask, Panel):
877     bl_space_type = 'IMAGE_EDITOR'
878     bl_region_type = 'PREVIEW'
879
880
881 class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
882     bl_space_type = 'IMAGE_EDITOR'
883     bl_region_type = 'PREVIEW'
884
885
886 class IMAGE_PT_mask_display(MASK_PT_display, Panel):
887     bl_space_type = 'IMAGE_EDITOR'
888     bl_region_type = 'PREVIEW'
889
890
891 class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
892     bl_space_type = 'IMAGE_EDITOR'
893     bl_region_type = 'PREVIEW'
894
895
896 class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
897     bl_space_type = 'IMAGE_EDITOR'
898     bl_region_type = 'PREVIEW'
899
900
901 class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
902     bl_space_type = 'IMAGE_EDITOR'
903     bl_region_type = 'UI'  # is 'TOOLS' in the clip editor
904
905 # --- end mask ---
906
907 if __name__ == "__main__":  # only for live edit.
908     bpy.utils.register_module(__name__)