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