e86c18aeba22b7f56abff130f4f07ed2cce64ab5
[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
360         row = layout.row(align=True)
361         row.template_header()
362
363         # menus
364         if context.area.show_menus:
365             sub = row.row(align=True)
366             sub.menu("IMAGE_MT_view")
367
368             if show_uvedit:
369                 sub.menu("IMAGE_MT_select")
370
371             if ima and ima.is_dirty:
372                 sub.menu("IMAGE_MT_image", text="Image*")
373             else:
374                 sub.menu("IMAGE_MT_image", text="Image")
375
376             if show_uvedit:
377                 sub.menu("IMAGE_MT_uvs")
378
379         layout.template_ID(sima, "image", new="image.new")
380         if not show_render:
381             layout.prop(sima, "use_image_pin", text="")
382
383         layout.prop(sima, "mode", text="")
384
385         # uv editing
386         if show_uvedit:
387             uvedit = sima.uv_editor
388
389             layout.prop(uvedit, "pivot_point", text="", icon_only=True)
390             layout.prop(toolsettings, "use_uv_select_sync", text="")
391
392             if toolsettings.use_uv_select_sync:
393                 layout.template_edit_mode_selection()
394             else:
395                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
396                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
397
398             row = layout.row(align=True)
399             row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
400             if toolsettings.proportional_edit != 'DISABLED':
401                 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
402
403             row = layout.row(align=True)
404             row.prop(toolsettings, "use_snap", text="")
405             row.prop(toolsettings, "snap_target", text="")
406
407             mesh = context.edit_object.data
408             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
409
410         elif mode == 'MASK':
411             row = layout.row()
412             row.template_ID(sima, "mask", new="mask.new")
413
414             # reused for mask
415             uvedit = sima.uv_editor
416             layout.prop(uvedit, "pivot_point", text="", icon_only=True)
417
418         if ima:
419             # layers
420             layout.template_image_layers(ima, iuser)
421
422             # draw options
423             row = layout.row(align=True)
424             row.prop(sima, "draw_channels", text="", expand=True)
425
426             row = layout.row(align=True)
427             if ima.type == 'COMPOSITE':
428                 row.operator("image.record_composite", icon='REC')
429             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
430                 row.operator("image.play_composite", icon='PLAY')
431
432         if show_uvedit or mode == 'PAINT':
433             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
434
435
436 class IMAGE_PT_image_properties(Panel):
437     bl_space_type = 'IMAGE_EDITOR'
438     bl_region_type = 'UI'
439     bl_label = "Image"
440
441     @classmethod
442     def poll(cls, context):
443         sima = context.space_data
444         return (sima.image)
445
446     def draw(self, context):
447         layout = self.layout
448
449         sima = context.space_data
450         iuser = sima.image_user
451
452         layout.template_image(sima, "image", iuser)
453
454
455 class IMAGE_PT_game_properties(Panel):
456     bl_space_type = 'IMAGE_EDITOR'
457     bl_region_type = 'UI'
458     bl_label = "Game Properties"
459
460     @classmethod
461     def poll(cls, context):
462         sima = context.space_data
463         # display even when not in game mode because these settings effect the 3d view
464         return (sima and sima.image)  # and (rd.engine == 'BLENDER_GAME')
465
466     def draw(self, context):
467         layout = self.layout
468
469         sima = context.space_data
470         ima = sima.image
471
472         split = layout.split()
473
474         col = split.column()
475
476         col.prop(ima, "use_animation")
477         sub = col.column(align=True)
478         sub.active = ima.use_animation
479         sub.prop(ima, "frame_start", text="Start")
480         sub.prop(ima, "frame_end", text="End")
481         sub.prop(ima, "fps", text="Speed")
482
483         col.prop(ima, "use_tiles")
484         sub = col.column(align=True)
485         sub.active = ima.use_tiles or ima.use_animation
486         sub.prop(ima, "tiles_x", text="X")
487         sub.prop(ima, "tiles_y", text="Y")
488
489         col = split.column()
490         col.label(text="Clamp:")
491         col.prop(ima, "use_clamp_x", text="X")
492         col.prop(ima, "use_clamp_y", text="Y")
493         col.separator()
494         col.prop(ima, "mapping", expand=True)
495
496
497 class IMAGE_PT_view_histogram(Panel):
498     bl_space_type = 'IMAGE_EDITOR'
499     bl_region_type = 'PREVIEW'
500     bl_label = "Histogram"
501
502     @classmethod
503     def poll(cls, context):
504         sima = context.space_data
505         return (sima and sima.image)
506
507     def draw(self, context):
508         layout = self.layout
509
510         sima = context.space_data
511         hist = sima.scopes.histogram
512
513         layout.template_histogram(sima.scopes, "histogram")
514         row = layout.row(align=True)
515         row.prop(hist, "mode", icon_only=True, expand=True)
516         row.prop(hist, "show_line", text="")
517
518
519 class IMAGE_PT_view_waveform(Panel):
520     bl_space_type = 'IMAGE_EDITOR'
521     bl_region_type = 'PREVIEW'
522     bl_label = "Waveform"
523
524     @classmethod
525     def poll(cls, context):
526         sima = context.space_data
527         return (sima and sima.image)
528
529     def draw(self, context):
530         layout = self.layout
531
532         sima = context.space_data
533
534         layout.template_waveform(sima, "scopes")
535         row = layout.split(percentage=0.75)
536         row.prop(sima.scopes, "waveform_alpha")
537         row.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
538
539
540 class IMAGE_PT_view_vectorscope(Panel):
541     bl_space_type = 'IMAGE_EDITOR'
542     bl_region_type = 'PREVIEW'
543     bl_label = "Vectorscope"
544
545     @classmethod
546     def poll(cls, context):
547         sima = context.space_data
548         return (sima and sima.image)
549
550     def draw(self, context):
551         layout = self.layout
552
553         sima = context.space_data
554         layout.template_vectorscope(sima, "scopes")
555         layout.prop(sima.scopes, "vectorscope_alpha")
556
557
558 class IMAGE_PT_sample_line(Panel):
559     bl_space_type = 'IMAGE_EDITOR'
560     bl_region_type = 'PREVIEW'
561     bl_label = "Sample Line"
562
563     @classmethod
564     def poll(cls, context):
565         sima = context.space_data
566         return (sima and sima.image)
567
568     def draw(self, context):
569         layout = self.layout
570
571         sima = context.space_data
572         hist = sima.sample_histogram
573
574         layout.operator("image.sample_line")
575         layout.template_histogram(sima, "sample_histogram")
576         row = layout.row(align=True)
577         row.prop(hist, "mode", expand=True)
578         row.prop(hist, "show_line", text="")
579
580
581 class IMAGE_PT_scope_sample(Panel):
582     bl_space_type = 'IMAGE_EDITOR'
583     bl_region_type = 'PREVIEW'
584     bl_label = "Scope Samples"
585
586     @classmethod
587     def poll(cls, context):
588         sima = context.space_data
589         return sima
590
591     def draw(self, context):
592         layout = self.layout
593
594         sima = context.space_data
595
596         row = layout.row()
597         row.prop(sima.scopes, "use_full_resolution")
598         sub = row.row()
599         sub.active = not sima.scopes.use_full_resolution
600         sub.prop(sima.scopes, "accuracy")
601
602
603 class IMAGE_PT_view_properties(Panel):
604     bl_space_type = 'IMAGE_EDITOR'
605     bl_region_type = 'UI'
606     bl_label = "Display"
607
608     @classmethod
609     def poll(cls, context):
610         sima = context.space_data
611         return (sima and (sima.image or sima.show_uvedit))
612
613     def draw(self, context):
614         layout = self.layout
615
616         sima = context.space_data
617         ima = sima.image
618         show_uvedit = sima.show_uvedit
619         uvedit = sima.uv_editor
620
621         split = layout.split()
622
623         col = split.column()
624         if ima:
625             col.prop(ima, "display_aspect", text="Aspect Ratio")
626
627             col = split.column()
628             col.label(text="Coordinates:")
629             col.prop(sima, "show_repeat", text="Repeat")
630             if show_uvedit:
631                 col.prop(uvedit, "show_normalized_coords", text="Normalized")
632
633         elif show_uvedit:
634             col.label(text="Coordinates:")
635             col.prop(uvedit, "show_normalized_coords", text="Normalized")
636
637         if show_uvedit:
638
639             col = layout.column()
640             col.label("Cursor Location:")
641             col.row().prop(uvedit, "cursor_location", text="")
642
643             col.separator()
644
645             col.label(text="UVs:")
646             col.row().prop(uvedit, "edge_draw_type", expand=True)
647
648             split = layout.split()
649
650             col = split.column()
651             col.prop(uvedit, "show_faces")
652             col.prop(uvedit, "show_smooth_edges", text="Smooth")
653             col.prop(uvedit, "show_modified_edges", text="Modified")
654
655             col = split.column()
656             col.prop(uvedit, "show_stretch", text="Stretch")
657             sub = col.column()
658             sub.active = uvedit.show_stretch
659             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
660
661
662 class IMAGE_PT_paint(Panel, ImagePaintPanel):
663     bl_space_type = 'IMAGE_EDITOR'
664     bl_region_type = 'UI'
665     bl_label = "Paint"
666
667     @classmethod
668     def poll(cls, context):
669         sima = context.space_data
670         return sima.show_paint
671
672     def draw(self, context):
673         layout = self.layout
674
675         toolsettings = context.tool_settings.image_paint
676         brush = toolsettings.brush
677
678         col = layout.column()
679         col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6)
680
681         if brush:
682             col = layout.column()
683             col.template_color_wheel(brush, "color", value_slider=True)
684             col.prop(brush, "color", text="")
685
686             row = col.row(align=True)
687             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
688             self.prop_unified_size(row, context, brush, "use_pressure_size")
689
690             row = col.row(align=True)
691             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
692             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
693
694             row = col.row(align=True)
695             row.prop(brush, "jitter", slider=True)
696             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
697
698             col.prop(brush, "blend", text="Blend")
699
700             if brush.image_tool == 'CLONE':
701                 col.separator()
702                 col.prop(brush, "clone_image", text="Image")
703                 col.prop(brush, "clone_alpha", text="Alpha")
704
705
706 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
707     bl_label = "Texture"
708     bl_options = {'DEFAULT_CLOSED'}
709
710     def draw(self, context):
711         layout = self.layout
712
713         toolsettings = context.tool_settings.image_paint
714         brush = toolsettings.brush
715
716         col = layout.column()
717         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
718         col.prop(brush, "use_fixed_texture")
719
720
721 class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
722     bl_label = "Tool"
723     bl_options = {'DEFAULT_CLOSED'}
724
725     def draw(self, context):
726         layout = self.layout
727         toolsettings = context.tool_settings.image_paint
728         brush = toolsettings.brush
729
730         layout.prop(brush, "image_tool", text="")
731
732         row = layout.row(align=True)
733         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
734         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
735         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
736         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
737
738
739 class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
740     bl_label = "Paint Stroke"
741     bl_options = {'DEFAULT_CLOSED'}
742
743     def draw(self, context):
744         layout = self.layout
745
746         toolsettings = context.tool_settings.image_paint
747         brush = toolsettings.brush
748
749         layout.prop(brush, "use_airbrush")
750         row = layout.row()
751         row.active = brush.use_airbrush
752         row.prop(brush, "rate", slider=True)
753
754         layout.prop(brush, "use_space")
755         row = layout.row(align=True)
756         row.active = brush.use_space
757         row.prop(brush, "spacing", text="Distance", slider=True)
758         row.prop(brush, "use_pressure_spacing", toggle=True, text="")
759
760         layout.prop(brush, "use_wrap")
761
762
763 class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
764     bl_label = "Paint Curve"
765     bl_options = {'DEFAULT_CLOSED'}
766
767     def draw(self, context):
768         layout = self.layout
769
770         toolsettings = context.tool_settings.image_paint
771         brush = toolsettings.brush
772
773         layout.template_curve_mapping(brush, "curve")
774
775         row = layout.row(align=True)
776         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
777         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
778         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
779         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
780         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
781         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
782
783
784 class IMAGE_UV_sculpt_curve(Panel):
785     bl_space_type = 'IMAGE_EDITOR'
786     bl_region_type = 'UI'
787     bl_label = "UV Sculpt Curve"
788     bl_options = {'DEFAULT_CLOSED'}
789
790     @classmethod
791     def poll(cls, context):
792         sima = context.space_data
793         toolsettings = context.tool_settings.image_paint
794         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
795
796     def draw(self, context):
797         layout = self.layout
798
799         toolsettings = context.tool_settings
800         uvsculpt = toolsettings.uv_sculpt
801         brush = uvsculpt.brush
802
803         layout.template_curve_mapping(brush, "curve")
804
805         row = layout.row(align=True)
806         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
807         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
808         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
809         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
810         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
811         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
812
813
814 class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
815     bl_space_type = 'IMAGE_EDITOR'
816     bl_region_type = 'UI'
817     bl_label = "UV Sculpt"
818
819     @classmethod
820     def poll(cls, context):
821         sima = context.space_data
822         toolsettings = context.tool_settings.image_paint
823         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
824
825     def draw(self, context):
826         layout = self.layout
827
828         toolsettings = context.tool_settings
829         uvsculpt = toolsettings.uv_sculpt
830         brush = uvsculpt.brush
831
832         if brush:
833             col = layout.column()
834
835             row = col.row(align=True)
836             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
837             self.prop_unified_size(row, context, brush, "use_pressure_size")
838
839             row = col.row(align=True)
840             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
841             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
842
843         col = layout.column()
844         col.prop(toolsettings, "uv_sculpt_lock_borders")
845         col.prop(toolsettings, "uv_sculpt_all_islands")
846         col.prop(toolsettings, "uv_sculpt_tool")
847
848         if toolsettings.uv_sculpt_tool == 'RELAX':
849             col.prop(toolsettings, "uv_relax_method")
850
851
852 # -----------------------------------------------------------------------------
853 # Mask (similar code in space_clip.py, keep in sync)
854 # note! - panel placement does _not_ fit well with image panels... need to fix
855
856 from bl_ui.properties_mask_common import (MASK_PT_mask,
857                                           MASK_PT_layers,
858                                           MASK_PT_spline,
859                                           MASK_PT_point,
860                                           MASK_PT_display,
861                                           MASK_PT_tools)
862
863
864 class IMAGE_PT_mask(MASK_PT_mask, Panel):
865     bl_space_type = 'IMAGE_EDITOR'
866     bl_region_type = 'PREVIEW'
867
868
869 class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
870     bl_space_type = 'IMAGE_EDITOR'
871     bl_region_type = 'PREVIEW'
872
873
874 class IMAGE_PT_mask_display(MASK_PT_display, Panel):
875     bl_space_type = 'IMAGE_EDITOR'
876     bl_region_type = 'PREVIEW'
877
878
879 class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
880     bl_space_type = 'IMAGE_EDITOR'
881     bl_region_type = 'PREVIEW'
882
883
884 class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
885     bl_space_type = 'IMAGE_EDITOR'
886     bl_region_type = 'PREVIEW'
887
888
889 class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
890     bl_space_type = 'IMAGE_EDITOR'
891     bl_region_type = 'UI'  # is 'TOOLS' in the clip editor
892
893 # --- end mask ---
894
895 if __name__ == "__main__":  # only for live edit.
896     bpy.utils.register_module(__name__)