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