Merging r58464 through r58474 from trunk into soc-2013-depsgraph_mt
[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, brush_texture_settings, brush_mask_texture_settings
23 from bpy.app.translations import pgettext_iface as iface_
24
25
26 class ImagePaintPanel(UnifiedPaintPanel):
27     bl_space_type = 'IMAGE_EDITOR'
28     bl_region_type = 'UI'
29
30
31 class BrushButtonsPanel:
32     bl_space_type = 'IMAGE_EDITOR'
33     bl_region_type = 'UI'
34
35     @classmethod
36     def poll(cls, context):
37         sima = context.space_data
38         toolsettings = context.tool_settings.image_paint
39         return sima.show_paint and toolsettings.brush
40
41
42 class IMAGE_MT_view(Menu):
43     bl_label = "View"
44
45     def draw(self, context):
46         layout = self.layout
47
48         sima = context.space_data
49         uv = sima.uv_editor
50         toolsettings = context.tool_settings
51
52         show_uvedit = sima.show_uvedit
53         show_render = sima.show_render
54
55         layout.operator("image.properties", icon='MENU_PANEL')
56         layout.operator("image.scopes", icon='MENU_PANEL')
57
58         layout.separator()
59
60         layout.prop(sima, "use_realtime_update")
61         if show_uvedit:
62             layout.prop(toolsettings, "show_uv_local_view")
63
64         layout.prop(uv, "show_other_objects")
65
66         layout.separator()
67
68         layout.operator("image.view_zoom_in")
69         layout.operator("image.view_zoom_out")
70
71         layout.separator()
72
73         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
74
75         for a, b in ratios:
76             layout.operator("image.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
77
78         layout.separator()
79
80         if show_uvedit:
81             layout.operator("image.view_selected")
82
83         layout.operator("image.view_all")
84
85         layout.separator()
86
87         if show_render:
88             layout.operator("image.cycle_render_slot", text="Render Slot Cycle Next")
89             layout.operator("image.cycle_render_slot", text="Render Slot Cycle Previous").reverse = True
90             layout.separator()
91
92         layout.operator("screen.area_dupli")
93         layout.operator("screen.screen_full_area")
94
95
96 class IMAGE_MT_select(Menu):
97     bl_label = "Select"
98
99     def draw(self, context):
100         layout = self.layout
101
102         layout.operator("uv.select_border").pinned = False
103         layout.operator("uv.select_border", text="Border Select Pinned").pinned = True
104
105         layout.separator()
106
107         layout.operator("uv.select_all").action = 'TOGGLE'
108         layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
109         layout.operator("uv.select_split")
110
111         layout.separator()
112
113         layout.operator("uv.select_pinned")
114         layout.operator("uv.select_linked")
115
116         layout.separator()
117
118         layout.operator("uv.select_less", text="Less")
119         layout.operator("uv.select_more", text="More")
120
121         layout.separator()
122
123         layout.operator("uv.select_split")
124
125
126 class IMAGE_MT_image(Menu):
127     bl_label = "Image"
128
129     def draw(self, context):
130         layout = self.layout
131
132         sima = context.space_data
133         ima = sima.image
134
135         layout.operator("image.new")
136         layout.operator("image.open")
137
138         show_render = sima.show_render
139
140         if ima:
141             if not show_render:
142                 layout.operator("image.replace")
143                 layout.operator("image.reload")
144
145             layout.operator("image.save")
146             layout.operator("image.save_as")
147             layout.operator("image.save_as", text="Save a Copy").copy = True
148
149             if ima.source == 'SEQUENCE':
150                 layout.operator("image.save_sequence")
151
152             layout.operator("image.external_edit", "Edit Externally")
153
154             layout.separator()
155
156             layout.menu("IMAGE_MT_image_invert")
157
158             if not show_render:
159                 layout.separator()
160
161                 if not ima.packed_file:
162                     layout.operator("image.pack")
163
164                 # only for dirty && specific image types, perhaps
165                 # this could be done in operator poll too
166                 if ima.is_dirty:
167                     if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
168                         layout.operator("image.pack", text="Pack As PNG").as_png = True
169
170             layout.separator()
171
172
173 class IMAGE_MT_image_invert(Menu):
174     bl_label = "Invert"
175
176     def draw(self, context):
177         layout = self.layout
178
179         props = layout.operator("image.invert", text="Invert Image Colors")
180         props.invert_r = True
181         props.invert_g = True
182         props.invert_b = True
183
184         layout.separator()
185
186         props = layout.operator("image.invert", text="Invert Red Channel")
187         props.invert_r = True
188
189         props = layout.operator("image.invert", text="Invert Green Channel")
190         props.invert_g = True
191
192         props = layout.operator("image.invert", text="Invert Blue Channel")
193         props.invert_b = True
194
195         props = layout.operator("image.invert", text="Invert Alpha Channel")
196         props.invert_a = True
197
198
199 class IMAGE_MT_uvs_showhide(Menu):
200     bl_label = "Show/Hide Faces"
201
202     def draw(self, context):
203         layout = self.layout
204
205         layout.operator("uv.reveal")
206         layout.operator("uv.hide", text="Hide Selected").unselected = False
207         layout.operator("uv.hide", text="Hide Unselected").unselected = True
208
209
210 class IMAGE_MT_uvs_transform(Menu):
211     bl_label = "Transform"
212
213     def draw(self, context):
214         layout = self.layout
215
216         layout.operator("transform.translate")
217         layout.operator("transform.rotate")
218         layout.operator("transform.resize")
219
220         layout.separator()
221
222         layout.operator("transform.shear")
223
224
225 class IMAGE_MT_uvs_snap(Menu):
226     bl_label = "Snap"
227
228     def draw(self, context):
229         layout = self.layout
230
231         layout.operator_context = 'EXEC_REGION_WIN'
232
233         layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
234         layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
235         layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
236
237         layout.separator()
238
239         layout.operator("uv.snap_cursor", text="Cursor to Pixels").target = 'PIXELS'
240         layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED'
241
242
243 class IMAGE_MT_uvs_mirror(Menu):
244     bl_label = "Mirror"
245
246     def draw(self, context):
247         layout = self.layout
248
249         layout.operator_context = 'EXEC_REGION_WIN'
250
251         layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
252         layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True
253
254
255 class IMAGE_MT_uvs_weldalign(Menu):
256     bl_label = "Weld/Align"
257
258     def draw(self, context):
259         layout = self.layout
260
261         layout.operator("uv.weld")  # W, 1
262         layout.operator("uv.remove_doubles")
263         layout.operator_enum("uv.align", "axis")  # W, 2/3/4
264
265
266 class IMAGE_MT_uvs(Menu):
267     bl_label = "UVs"
268
269     def draw(self, context):
270         layout = self.layout
271
272         sima = context.space_data
273         uv = sima.uv_editor
274         toolsettings = context.tool_settings
275
276         layout.prop(uv, "use_snap_to_pixels")
277         layout.prop(uv, "lock_bounds")
278
279         layout.separator()
280
281         layout.prop(toolsettings, "use_uv_sculpt")
282
283         layout.separator()
284
285         layout.prop(uv, "use_live_unwrap")
286         layout.operator("uv.unwrap")
287         layout.operator("uv.pin", text="Unpin").clear = True
288         layout.operator("uv.pin")
289
290         layout.separator()
291
292         layout.operator("uv.pack_islands")
293         layout.operator("uv.average_islands_scale")
294         layout.operator("uv.minimize_stretch")
295         layout.operator("uv.stitch")
296         layout.operator("uv.mark_seam")
297         layout.operator("uv.seams_from_islands")
298         layout.operator("mesh.faces_mirror_uv")
299
300         layout.separator()
301
302         layout.menu("IMAGE_MT_uvs_transform")
303         layout.menu("IMAGE_MT_uvs_mirror")
304         layout.menu("IMAGE_MT_uvs_snap")
305         layout.menu("IMAGE_MT_uvs_weldalign")
306
307         layout.separator()
308
309         layout.prop_menu_enum(toolsettings, "proportional_edit")
310         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
311
312         layout.separator()
313
314         layout.menu("IMAGE_MT_uvs_showhide")
315
316
317 class IMAGE_MT_uvs_select_mode(Menu):
318     bl_label = "UV Select Mode"
319
320     def draw(self, context):
321         layout = self.layout
322
323         layout.operator_context = 'INVOKE_REGION_WIN'
324         toolsettings = context.tool_settings
325
326         # do smart things depending on whether uv_select_sync is on
327
328         if toolsettings.use_uv_select_sync:
329             props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
330             props.value = "(True, False, False)"
331             props.data_path = "tool_settings.mesh_select_mode"
332
333             props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
334             props.value = "(False, True, False)"
335             props.data_path = "tool_settings.mesh_select_mode"
336
337             props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
338             props.value = "(False, False, True)"
339             props.data_path = "tool_settings.mesh_select_mode"
340
341         else:
342             props = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
343             props.value = 'VERTEX'
344             props.data_path = "tool_settings.uv_select_mode"
345
346             props = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
347             props.value = 'EDGE'
348             props.data_path = "tool_settings.uv_select_mode"
349
350             props = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
351             props.value = 'FACE'
352             props.data_path = "tool_settings.uv_select_mode"
353
354             props = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
355             props.value = 'ISLAND'
356             props.data_path = "tool_settings.uv_select_mode"
357
358
359 class IMAGE_HT_header(Header):
360     bl_space_type = 'IMAGE_EDITOR'
361
362     def draw(self, context):
363         layout = self.layout
364
365         sima = context.space_data
366         ima = sima.image
367         iuser = sima.image_user
368         toolsettings = context.tool_settings
369         mode = sima.mode
370
371         show_render = sima.show_render
372         # show_paint = sima.show_paint
373         show_uvedit = sima.show_uvedit
374         show_maskedit = sima.show_maskedit
375
376         row = layout.row(align=True)
377         row.template_header()
378
379         # menus
380         if context.area.show_menus:
381             sub = row.row(align=True)
382             sub.menu("IMAGE_MT_view")
383
384             if show_uvedit:
385                 sub.menu("IMAGE_MT_select")
386             if show_maskedit:
387                 sub.menu("MASK_MT_select")
388
389             if ima and ima.is_dirty:
390                 sub.menu("IMAGE_MT_image", text="Image*")
391             else:
392                 sub.menu("IMAGE_MT_image", text="Image")
393
394             if show_uvedit:
395                 sub.menu("IMAGE_MT_uvs")
396             if show_maskedit:
397                 sub.menu("MASK_MT_mask")
398
399         layout.template_ID(sima, "image", new="image.new")
400         if not show_render:
401             layout.prop(sima, "use_image_pin", text="")
402
403         layout.prop(sima, "mode", text="")
404
405         if show_maskedit:
406             row = layout.row()
407             row.template_ID(sima, "mask", new="mask.new")
408
409         if show_uvedit or show_maskedit:
410             layout.prop(sima, "pivot_point", text="", icon_only=True)
411
412         # uv editing
413         if show_uvedit:
414             uvedit = sima.uv_editor
415
416             layout.prop(toolsettings, "use_uv_select_sync", text="")
417
418             if toolsettings.use_uv_select_sync:
419                 layout.template_edit_mode_selection()
420             else:
421                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
422                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
423
424             row = layout.row(align=True)
425             row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
426             if toolsettings.proportional_edit != 'DISABLED':
427                 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
428
429             row = layout.row(align=True)
430             row.prop(toolsettings, "use_snap", text="")
431             row.prop(toolsettings, "snap_uv_element", text="", icon_only=True)
432             if toolsettings.snap_uv_element != 'INCREMENT':
433                 row.prop(toolsettings, "snap_target", text="")
434
435             mesh = context.edit_object.data
436             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
437
438         if ima:
439             # layers
440             layout.template_image_layers(ima, iuser)
441
442             # draw options
443             row = layout.row(align=True)
444             row.prop(sima, "draw_channels", text="", expand=True)
445
446             row = layout.row(align=True)
447             if ima.type == 'COMPOSITE':
448                 row.operator("image.record_composite", icon='REC')
449             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
450                 row.operator("image.play_composite", icon='PLAY')
451
452         if show_uvedit or show_maskedit or mode == 'PAINT':
453             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
454
455
456 class IMAGE_PT_image_properties(Panel):
457     bl_space_type = 'IMAGE_EDITOR'
458     bl_region_type = 'UI'
459     bl_label = "Image"
460
461     @classmethod
462     def poll(cls, context):
463         sima = context.space_data
464         return (sima.image)
465
466     def draw(self, context):
467         layout = self.layout
468
469         sima = context.space_data
470         iuser = sima.image_user
471
472         layout.template_image(sima, "image", iuser)
473
474
475 class IMAGE_PT_game_properties(Panel):
476     bl_space_type = 'IMAGE_EDITOR'
477     bl_region_type = 'UI'
478     bl_label = "Game Properties"
479
480     @classmethod
481     def poll(cls, context):
482         sima = context.space_data
483         # display even when not in game mode because these settings effect the 3d view
484         return (sima and sima.image)  # and (rd.engine == 'BLENDER_GAME')
485
486     def draw(self, context):
487         layout = self.layout
488
489         sima = context.space_data
490         ima = sima.image
491
492         split = layout.split()
493
494         col = split.column()
495         col.prop(ima, "use_animation")
496         sub = col.column(align=True)
497         sub.active = ima.use_animation
498         sub.prop(ima, "frame_start", text="Start")
499         sub.prop(ima, "frame_end", text="End")
500         sub.prop(ima, "fps", text="Speed")
501
502         col.prop(ima, "use_tiles")
503         sub = col.column(align=True)
504         sub.active = ima.use_tiles or ima.use_animation
505         sub.prop(ima, "tiles_x", text="X")
506         sub.prop(ima, "tiles_y", text="Y")
507
508         col = split.column()
509         col.label(text="Clamp:")
510         col.prop(ima, "use_clamp_x", text="X")
511         col.prop(ima, "use_clamp_y", text="Y")
512         col.separator()
513         col.prop(ima, "mapping", expand=True)
514
515
516 class IMAGE_PT_view_histogram(Panel):
517     bl_space_type = 'IMAGE_EDITOR'
518     bl_region_type = 'PREVIEW'
519     bl_label = "Histogram"
520
521     @classmethod
522     def poll(cls, context):
523         sima = context.space_data
524         return (sima and sima.image)
525
526     def draw(self, context):
527         layout = self.layout
528
529         sima = context.space_data
530         hist = sima.scopes.histogram
531
532         layout.template_histogram(sima.scopes, "histogram")
533         row = layout.row(align=True)
534         row.prop(hist, "mode", icon_only=True, expand=True)
535         row.prop(hist, "show_line", text="")
536
537
538 class IMAGE_PT_view_waveform(Panel):
539     bl_space_type = 'IMAGE_EDITOR'
540     bl_region_type = 'PREVIEW'
541     bl_label = "Waveform"
542
543     @classmethod
544     def poll(cls, context):
545         sima = context.space_data
546         return (sima and sima.image)
547
548     def draw(self, context):
549         layout = self.layout
550
551         sima = context.space_data
552
553         layout.template_waveform(sima, "scopes")
554         row = layout.split(percentage=0.75)
555         row.prop(sima.scopes, "waveform_alpha")
556         row.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
557
558
559 class IMAGE_PT_view_vectorscope(Panel):
560     bl_space_type = 'IMAGE_EDITOR'
561     bl_region_type = 'PREVIEW'
562     bl_label = "Vectorscope"
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         layout.template_vectorscope(sima, "scopes")
574         layout.prop(sima.scopes, "vectorscope_alpha")
575
576
577 class IMAGE_PT_sample_line(Panel):
578     bl_space_type = 'IMAGE_EDITOR'
579     bl_region_type = 'PREVIEW'
580     bl_label = "Sample Line"
581
582     @classmethod
583     def poll(cls, context):
584         sima = context.space_data
585         return (sima and sima.image)
586
587     def draw(self, context):
588         layout = self.layout
589
590         sima = context.space_data
591         hist = sima.sample_histogram
592
593         layout.operator("image.sample_line")
594         layout.template_histogram(sima, "sample_histogram")
595         row = layout.row(align=True)
596         row.prop(hist, "mode", expand=True)
597         row.prop(hist, "show_line", text="")
598
599
600 class IMAGE_PT_scope_sample(Panel):
601     bl_space_type = 'IMAGE_EDITOR'
602     bl_region_type = 'PREVIEW'
603     bl_label = "Scope Samples"
604
605     @classmethod
606     def poll(cls, context):
607         sima = context.space_data
608         return sima
609
610     def draw(self, context):
611         layout = self.layout
612
613         sima = context.space_data
614
615         row = layout.row()
616         row.prop(sima.scopes, "use_full_resolution")
617         sub = row.row()
618         sub.active = not sima.scopes.use_full_resolution
619         sub.prop(sima.scopes, "accuracy")
620
621
622 class IMAGE_PT_view_properties(Panel):
623     bl_space_type = 'IMAGE_EDITOR'
624     bl_region_type = 'UI'
625     bl_label = "Display"
626
627     @classmethod
628     def poll(cls, context):
629         sima = context.space_data
630         return (sima and (sima.image or sima.show_uvedit))
631
632     def draw(self, context):
633         layout = self.layout
634
635         sima = context.space_data
636         ima = sima.image
637         show_uvedit = sima.show_uvedit
638         show_maskedit = sima.show_maskedit
639         uvedit = sima.uv_editor
640
641         split = layout.split()
642
643         col = split.column()
644         if ima:
645             col.prop(ima, "display_aspect", text="Aspect Ratio")
646
647             col = split.column()
648             col.label(text="Coordinates:")
649             col.prop(sima, "show_repeat", text="Repeat")
650             if show_uvedit:
651                 col.prop(uvedit, "show_normalized_coords", text="Normalized")
652
653         elif show_uvedit:
654             col.label(text="Coordinates:")
655             col.prop(uvedit, "show_normalized_coords", text="Normalized")
656
657         if show_uvedit or show_maskedit:
658             col = layout.column()
659             col.label("Cursor Location:")
660             col.row().prop(sima, "cursor_location", text="")
661
662         if show_uvedit:
663             col.separator()
664
665             col.label(text="UVs:")
666             col.row().prop(uvedit, "edge_draw_type", expand=True)
667
668             split = layout.split()
669
670             col = split.column()
671             col.prop(uvedit, "show_faces")
672             col.prop(uvedit, "show_smooth_edges", text="Smooth")
673             col.prop(uvedit, "show_modified_edges", text="Modified")
674
675             col = split.column()
676             col.prop(uvedit, "show_stretch", text="Stretch")
677             sub = col.column()
678             sub.active = uvedit.show_stretch
679             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
680
681
682 class IMAGE_PT_paint(Panel, ImagePaintPanel):
683     bl_space_type = 'IMAGE_EDITOR'
684     bl_region_type = 'UI'
685     bl_label = "Paint"
686
687     @classmethod
688     def poll(cls, context):
689         sima = context.space_data
690         return sima.show_paint
691
692     def draw(self, context):
693         layout = self.layout
694
695         toolsettings = context.tool_settings.image_paint
696         brush = toolsettings.brush
697
698         col = layout.column()
699         col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=2, cols=6)
700
701         if brush:
702             col = layout.column()
703
704             if brush.image_tool == 'DRAW' and brush.blend not in ('ERASE_ALPHA', 'ADD_ALPHA'):
705                 col.template_color_picker(brush, "color", value_slider=True)
706                 col.prop(brush, "color", text="")
707
708             row = col.row(align=True)
709             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
710             self.prop_unified_size(row, context, brush, "use_pressure_size")
711
712             row = col.row(align=True)
713             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
714             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
715
716             row = col.row(align=True)
717
718             col.prop(brush, "blend", text="Blend")
719
720             if brush.image_tool == 'CLONE':
721                 col.separator()
722                 col.prop(brush, "clone_image", text="Image")
723                 col.prop(brush, "clone_alpha", text="Alpha")
724
725
726 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
727     bl_label = "Texture"
728     bl_options = {'DEFAULT_CLOSED'}
729
730     def draw(self, context):
731         layout = self.layout
732
733         toolsettings = context.tool_settings.image_paint
734         brush = toolsettings.brush
735         tex_slot = brush.texture_slot
736
737         col = layout.column()
738         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
739
740         brush_texture_settings(col, brush, 0)
741
742         # use_texture_overlay and texture_overlay_alpha
743         col = layout.column(align=True)
744         col.active = brush.brush_capabilities.has_overlay
745         col.label(text="Overlay:")
746
747         row = col.row()
748         if tex_slot.map_mode != 'STENCIL':
749             if brush.use_primary_overlay:
750                 row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
751             else:
752                 row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
753
754         sub = row.row()
755         sub.prop(brush, "texture_overlay_alpha", text="Alpha")
756         sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
757
758
759 class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
760     bl_label = "Texture Mask"
761     bl_options = {'DEFAULT_CLOSED'}
762
763     def draw(self, context):
764         layout = self.layout
765
766         brush = context.tool_settings.image_paint.brush
767         tex_slot_alpha = brush.mask_texture_slot
768
769         col = layout.column()
770
771         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
772
773         brush_mask_texture_settings(col, brush)
774
775         col = layout.column(align=True)
776         col.active = brush.brush_capabilities.has_overlay
777         col.label(text="Overlay:")
778
779         row = col.row()
780         if tex_slot_alpha.map_mode != 'STENCIL':
781             if brush.use_secondary_overlay:
782                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
783             else:
784                 row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
785
786         sub = row.row()
787         sub.prop(brush, "mask_overlay_alpha", text="Alpha")
788         sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
789
790
791 class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
792     bl_label = "Tool"
793     bl_options = {'DEFAULT_CLOSED'}
794
795     def draw(self, context):
796         layout = self.layout
797         toolsettings = context.tool_settings.image_paint
798         brush = toolsettings.brush
799
800         layout.prop(brush, "image_tool", text="")
801
802         row = layout.row(align=True)
803         row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
804         row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
805         row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
806         row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
807
808
809 class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
810     bl_label = "Paint Stroke"
811     bl_options = {'DEFAULT_CLOSED'}
812
813     def draw(self, context):
814         layout = self.layout
815
816         toolsettings = context.tool_settings.image_paint
817         brush = toolsettings.brush
818
819         col = layout.column()
820         col.prop(toolsettings, "input_samples")
821
822         col = layout.column()
823
824         col.label(text="Stroke Method:")
825
826         col.prop(brush, "stroke_method", text="")
827
828         if brush.use_anchor:
829             col.separator()
830             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
831
832         if brush.use_airbrush:
833             col.separator()
834             col.prop(brush, "rate", text="Rate", slider=True)
835
836         if brush.use_space:
837             col.separator()
838             row = col.row(align=True)
839             row.active = brush.use_space
840             row.prop(brush, "spacing", text="Spacing")
841             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
842
843         col = layout.column()
844         col.separator()
845
846         col.prop(brush, "use_smooth_stroke")
847
848         sub = col.column()
849         sub.active = brush.use_smooth_stroke
850         sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
851         sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
852
853         col.separator()
854
855         row = col.row(align=True)
856         if brush.use_relative_jitter:
857             row.prop(brush, "use_relative_jitter", text="", icon='LOCKED')
858             row.prop(brush, "jitter", slider=True)
859         else:
860             row.prop(brush, "use_relative_jitter", text="", icon='UNLOCKED')
861             row.prop(brush, "jitter_absolute")
862         row.prop(brush, "use_pressure_jitter", toggle=True, text="")
863
864         col.prop(brush, "use_wrap")
865
866
867 class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
868     bl_label = "Paint Curve"
869     bl_options = {'DEFAULT_CLOSED'}
870
871     def draw(self, context):
872         layout = self.layout
873
874         toolsettings = context.tool_settings.image_paint
875         brush = toolsettings.brush
876
877         layout.template_curve_mapping(brush, "curve")
878
879         row = layout.row(align=True)
880         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
881         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
882         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
883         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
884         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
885         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
886
887
888 class IMAGE_PT_tools_brush_appearance(BrushButtonsPanel, Panel):
889     bl_label = "Appearance"
890     bl_options = {'DEFAULT_CLOSED'}
891
892     def draw(self, context):
893         layout = self.layout
894
895         toolsettings = context.tool_settings.image_paint
896         brush = toolsettings.brush
897
898         if brush is None:  # unlikely but can happen
899             layout.label(text="Brush Unset")
900             return
901
902         col = layout.column()
903         col.prop(toolsettings, "show_brush")
904
905         col = col.column()
906         col.prop(brush, "cursor_color_add", text="")
907         col.active = toolsettings.show_brush
908
909         layout.separator()
910
911         col = layout.column(align=True)
912         col.prop(brush, "use_custom_icon")
913         if brush.use_custom_icon:
914             col.prop(brush, "icon_filepath", text="")
915
916
917 class IMAGE_UV_sculpt_curve(Panel):
918     bl_space_type = 'IMAGE_EDITOR'
919     bl_region_type = 'UI'
920     bl_label = "UV Sculpt Curve"
921     bl_options = {'DEFAULT_CLOSED'}
922
923     @classmethod
924     def poll(cls, context):
925         sima = context.space_data
926         toolsettings = context.tool_settings.image_paint
927         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
928
929     def draw(self, context):
930         layout = self.layout
931
932         toolsettings = context.tool_settings
933         uvsculpt = toolsettings.uv_sculpt
934         brush = uvsculpt.brush
935
936         layout.template_curve_mapping(brush, "curve")
937
938         row = layout.row(align=True)
939         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
940         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
941         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
942         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
943         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
944         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
945
946
947 class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
948     bl_space_type = 'IMAGE_EDITOR'
949     bl_region_type = 'UI'
950     bl_label = "UV Sculpt"
951
952     @classmethod
953     def poll(cls, context):
954         sima = context.space_data
955         toolsettings = context.tool_settings.image_paint
956         return sima.show_uvedit and context.tool_settings.use_uv_sculpt and not (sima.show_paint and toolsettings.brush)
957
958     def draw(self, context):
959         layout = self.layout
960
961         toolsettings = context.tool_settings
962         uvsculpt = toolsettings.uv_sculpt
963         brush = uvsculpt.brush
964
965         if brush:
966             col = layout.column()
967
968             row = col.row(align=True)
969             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
970             self.prop_unified_size(row, context, brush, "use_pressure_size")
971
972             row = col.row(align=True)
973             self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
974             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
975
976         col = layout.column()
977         col.prop(toolsettings, "uv_sculpt_lock_borders")
978         col.prop(toolsettings, "uv_sculpt_all_islands")
979         col.prop(toolsettings, "uv_sculpt_tool")
980
981         if toolsettings.uv_sculpt_tool == 'RELAX':
982             col.prop(toolsettings, "uv_relax_method")
983
984
985 # -----------------------------------------------------------------------------
986 # Mask (similar code in space_clip.py, keep in sync)
987 # note! - panel placement does _not_ fit well with image panels... need to fix
988
989 from bl_ui.properties_mask_common import (MASK_PT_mask,
990                                           MASK_PT_layers,
991                                           MASK_PT_spline,
992                                           MASK_PT_point,
993                                           MASK_PT_display,
994                                           MASK_PT_tools)
995
996
997 class IMAGE_PT_mask(MASK_PT_mask, Panel):
998     bl_space_type = 'IMAGE_EDITOR'
999     bl_region_type = 'PREVIEW'
1000
1001
1002 class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
1003     bl_space_type = 'IMAGE_EDITOR'
1004     bl_region_type = 'PREVIEW'
1005
1006
1007 class IMAGE_PT_mask_display(MASK_PT_display, Panel):
1008     bl_space_type = 'IMAGE_EDITOR'
1009     bl_region_type = 'PREVIEW'
1010
1011
1012 class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
1013     bl_space_type = 'IMAGE_EDITOR'
1014     bl_region_type = 'PREVIEW'
1015
1016
1017 class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
1018     bl_space_type = 'IMAGE_EDITOR'
1019     bl_region_type = 'PREVIEW'
1020
1021
1022 class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
1023     bl_space_type = 'IMAGE_EDITOR'
1024     bl_region_type = 'UI'  # is 'TOOLS' in the clip editor
1025
1026 # --- end mask ---
1027
1028 if __name__ == "__main__":  # only for live edit.
1029     bpy.utils.register_module(__name__)