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