1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
23 class BrushButtonsPanel():
24 bl_space_type = 'IMAGE_EDITOR'
28 def poll(cls, context):
29 sima = context.space_data
30 toolsettings = context.tool_settings.image_paint
31 return sima.show_paint and toolsettings.brush
34 class IMAGE_MT_view(bpy.types.Menu):
37 def draw(self, context):
40 sima = context.space_data
42 toolsettings = context.tool_settings
44 show_uvedit = sima.show_uvedit
46 layout.operator("image.properties", icon='MENU_PANEL')
47 layout.operator("image.scopes", icon='MENU_PANEL')
51 layout.prop(sima, "use_realtime_update")
53 layout.prop(toolsettings, "show_uv_local_view")
54 layout.prop(uv, "show_other_objects")
58 layout.operator("image.view_zoom_in")
59 layout.operator("image.view_zoom_out")
63 ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]
66 text = "Zoom %d:%d" % (a, b)
67 layout.operator("image.view_zoom_ratio", text=text).ratio = a / b
72 layout.operator("image.view_selected")
74 layout.operator("image.view_all")
78 layout.operator("screen.area_dupli")
79 layout.operator("screen.screen_full_area")
82 class IMAGE_MT_select(bpy.types.Menu):
85 def draw(self, context):
88 layout.operator("uv.select_border")
89 layout.operator("uv.select_border").pinned = True
93 layout.operator("uv.select_all")
94 layout.operator("uv.select_all", text="Inverse").action = 'INVERT'
95 layout.operator("uv.unlink_selected")
99 layout.operator("uv.select_pinned")
100 layout.operator("uv.select_linked")
103 class IMAGE_MT_image(bpy.types.Menu):
106 def draw(self, context):
109 sima = context.space_data
112 layout.operator("image.new")
113 layout.operator("image.open")
115 show_render = sima.show_render
119 layout.operator("image.replace")
120 layout.operator("image.reload")
122 layout.operator("image.save")
123 layout.operator("image.save_as")
124 layout.operator("image.save_as", text="Save a Copy").copy = True
126 if ima.source == 'SEQUENCE':
127 layout.operator("image.save_sequence")
129 layout.operator("image.external_edit", "Edit Externally")
133 layout.menu("IMAGE_MT_image_invert")
139 layout.operator("image.unpack")
141 layout.operator("image.pack")
143 # only for dirty && specific image types, perhaps
144 # this could be done in operator poll too
146 if ima.source in {'FILE', 'GENERATED'} and ima.type != 'MULTILAYER':
147 layout.operator("image.pack", text="Pack As PNG").as_png = True
151 layout.prop(sima, "use_image_paint")
154 class IMAGE_MT_image_invert(bpy.types.Menu):
157 def draw(self, context):
160 op = layout.operator("image.invert", text="Invert Image Colors")
167 op = layout.operator("image.invert", text="Invert Red Channel")
170 op = layout.operator("image.invert", text="Invert Green Channel")
173 op = layout.operator("image.invert", text="Invert Blue Channel")
176 op = layout.operator("image.invert", text="Invert Alpha Channel")
180 class IMAGE_MT_uvs_showhide(bpy.types.Menu):
181 bl_label = "Show/Hide Faces"
183 def draw(self, context):
186 layout.operator("uv.reveal")
187 layout.operator("uv.hide", text="Hide Selected")
188 layout.operator("uv.hide", text="Hide Unselected").unselected = True
191 class IMAGE_MT_uvs_transform(bpy.types.Menu):
192 bl_label = "Transform"
194 def draw(self, context):
197 layout.operator("transform.translate")
198 layout.operator("transform.rotate")
199 layout.operator("transform.resize")
202 class IMAGE_MT_uvs_snap(bpy.types.Menu):
205 def draw(self, context):
207 layout.operator_context = 'EXEC_REGION_WIN'
209 layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
210 layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
211 layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
215 layout.operator("uv.snap_cursor", text="Cursor to Pixels").target = 'PIXELS'
216 layout.operator("uv.snap_cursor", text="Cursor to Selected").target = 'SELECTED'
219 class IMAGE_MT_uvs_mirror(bpy.types.Menu):
222 def draw(self, context):
224 layout.operator_context = 'EXEC_REGION_WIN'
226 layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
227 layout.operator("transform.mirror", text="Y Axis").constraint_axis[1] = True
230 class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
231 bl_label = "Weld/Align"
233 def draw(self, context):
236 layout.operator("uv.weld") # W, 1
237 layout.operator_enum("uv.align", "axis") # W, 2/3/4
240 class IMAGE_MT_uvs(bpy.types.Menu):
243 def draw(self, context):
246 sima = context.space_data
248 toolsettings = context.tool_settings
250 layout.prop(uv, "use_snap_to_pixels")
251 layout.prop(uv, "lock_bounds")
255 layout.prop(uv, "use_live_unwrap")
256 layout.operator("uv.unwrap")
257 layout.operator("uv.pin", text="Unpin").clear = True
258 layout.operator("uv.pin")
262 layout.operator("uv.pack_islands")
263 layout.operator("uv.average_islands_scale")
264 layout.operator("uv.minimize_stretch")
265 layout.operator("uv.stitch")
266 layout.operator("mesh.faces_mirror_uv")
270 layout.menu("IMAGE_MT_uvs_transform")
271 layout.menu("IMAGE_MT_uvs_mirror")
272 layout.menu("IMAGE_MT_uvs_snap")
273 layout.menu("IMAGE_MT_uvs_weldalign")
277 layout.prop_menu_enum(toolsettings, "proportional_edit")
278 layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
282 layout.menu("IMAGE_MT_uvs_showhide")
285 class IMAGE_MT_uvs_select_mode(bpy.types.Menu):
286 bl_label = "UV Select Mode"
288 def draw(self, context):
291 layout.operator_context = 'INVOKE_REGION_WIN'
292 toolsettings = context.tool_settings
294 # do smart things depending on whether uv_select_sync is on
296 if toolsettings.use_uv_select_sync:
297 prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
298 prop.value = "(True, False, False)"
299 prop.data_path = "tool_settings.mesh_select_mode"
301 prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
302 prop.value = "(False, True, False)"
303 prop.data_path = "tool_settings.mesh_select_mode"
305 prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
306 prop.value = "(False, False, True)"
307 prop.data_path = "tool_settings.mesh_select_mode"
310 prop = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL')
311 prop.value = "VERTEX"
312 prop.data_path = "tool_settings.uv_select_mode"
314 prop = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL')
316 prop.data_path = "tool_settings.uv_select_mode"
318 prop = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL')
320 prop.data_path = "tool_settings.uv_select_mode"
322 prop = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL')
323 prop.value = "ISLAND"
324 prop.data_path = "tool_settings.uv_select_mode"
327 class IMAGE_HT_header(bpy.types.Header):
328 bl_space_type = 'IMAGE_EDITOR'
330 def draw(self, context):
333 sima = context.space_data
335 iuser = sima.image_user
336 toolsettings = context.tool_settings
338 show_render = sima.show_render
339 # show_paint = sima.show_paint
340 show_uvedit = sima.show_uvedit
342 row = layout.row(align=True)
343 row.template_header()
346 if context.area.show_menus:
347 sub = row.row(align=True)
348 sub.menu("IMAGE_MT_view")
351 sub.menu("IMAGE_MT_select")
353 if ima and ima.is_dirty:
354 sub.menu("IMAGE_MT_image", text="Image*")
356 sub.menu("IMAGE_MT_image", text="Image")
359 sub.menu("IMAGE_MT_uvs")
361 layout.template_ID(sima, "image", new="image.new")
363 layout.prop(sima, "use_image_pin", text="")
367 uvedit = sima.uv_editor
369 layout.prop(uvedit, "pivot_point", text="", icon_only=True)
370 layout.prop(toolsettings, "use_uv_select_sync", text="")
372 if toolsettings.use_uv_select_sync:
373 layout.template_edit_mode_selection()
375 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
376 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
378 row = layout.row(align=True)
379 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
380 if toolsettings.proportional_edit != 'DISABLED':
381 row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
383 row = layout.row(align=True)
384 row.prop(toolsettings, "use_snap", text="")
385 row.prop(toolsettings, "snap_element", text="", icon_only=True)
387 mesh = context.edit_object.data
388 layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
392 layout.template_image_layers(ima, iuser)
395 layout.prop(sima, "use_image_paint", text="")
398 row = layout.row(align=True)
399 row.prop(sima, "draw_channels", text="", expand=True)
401 row = layout.row(align=True)
402 if ima.type == 'COMPOSITE':
403 row.operator("image.record_composite", icon='REC')
404 if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
405 row.operator("image.play_composite", icon='PLAY')
407 if show_uvedit or sima.use_image_paint:
408 layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
411 class IMAGE_PT_image_properties(bpy.types.Panel):
412 bl_space_type = 'IMAGE_EDITOR'
413 bl_region_type = 'UI'
417 def poll(cls, context):
418 sima = context.space_data
421 def draw(self, context):
424 sima = context.space_data
425 iuser = sima.image_user
427 layout.template_image(sima, "image", iuser)
430 class IMAGE_PT_game_properties(bpy.types.Panel):
431 bl_space_type = 'IMAGE_EDITOR'
432 bl_region_type = 'UI'
433 bl_label = "Game Properties"
436 def poll(cls, context):
437 rd = context.scene.render
438 sima = context.space_data
439 # display even when not in game mode because these settings effect the 3d view
440 return (sima and sima.image) # and (rd.engine == 'BLENDER_GAME')
442 def draw(self, context):
445 sima = context.space_data
448 split = layout.split()
452 sub = col.column(align=True)
453 sub.prop(ima, "use_animation")
455 subsub = sub.column()
456 subsub.active = ima.use_animation
457 subsub.prop(ima, "frame_start", text="Start")
458 subsub.prop(ima, "frame_end", text="End")
459 subsub.prop(ima, "fps", text="Speed")
461 col.prop(ima, "use_tiles")
462 sub = col.column(align=True)
463 sub.active = ima.use_tiles or ima.use_animation
464 sub.prop(ima, "tiles_x", text="X")
465 sub.prop(ima, "tiles_y", text="Y")
468 col.label(text="Clamp:")
469 col.prop(ima, "use_clamp_x", text="X")
470 col.prop(ima, "use_clamp_y", text="Y")
472 col.prop(ima, "mapping", expand=True)
475 class IMAGE_PT_view_histogram(bpy.types.Panel):
476 bl_space_type = 'IMAGE_EDITOR'
477 bl_region_type = 'PREVIEW'
478 bl_label = "Histogram"
481 def poll(cls, context):
482 sima = context.space_data
483 return (sima and sima.image)
485 def draw(self, context):
488 sima = context.space_data
490 layout.template_histogram(sima.scopes, "histogram")
491 layout.prop(sima.scopes.histogram, "mode", icon_only=True)
494 class IMAGE_PT_view_waveform(bpy.types.Panel):
495 bl_space_type = 'IMAGE_EDITOR'
496 bl_region_type = 'PREVIEW'
497 bl_label = "Waveform"
500 def poll(cls, context):
501 sima = context.space_data
502 return (sima and sima.image)
504 def draw(self, context):
507 sima = context.space_data
508 layout.template_waveform(sima, "scopes")
509 sub = layout.row().split(percentage=0.75)
510 sub.prop(sima.scopes, "waveform_alpha")
511 sub.prop(sima.scopes, "waveform_mode", text="", icon_only=True)
514 class IMAGE_PT_view_vectorscope(bpy.types.Panel):
515 bl_space_type = 'IMAGE_EDITOR'
516 bl_region_type = 'PREVIEW'
517 bl_label = "Vectorscope"
520 def poll(cls, context):
521 sima = context.space_data
522 return (sima and sima.image)
524 def draw(self, context):
527 sima = context.space_data
528 layout.template_vectorscope(sima, "scopes")
529 layout.prop(sima.scopes, "vectorscope_alpha")
532 class IMAGE_PT_sample_line(bpy.types.Panel):
533 bl_space_type = 'IMAGE_EDITOR'
534 bl_region_type = 'PREVIEW'
535 bl_label = "Sample Line"
538 def poll(cls, context):
539 sima = context.space_data
540 return (sima and sima.image)
542 def draw(self, context):
544 layout.operator("image.sample_line")
545 sima = context.space_data
546 layout.template_histogram(sima, "sample_histogram")
547 layout.prop(sima.sample_histogram, "mode")
550 class IMAGE_PT_scope_sample(bpy.types.Panel):
551 bl_space_type = 'IMAGE_EDITOR'
552 bl_region_type = 'PREVIEW'
553 bl_label = "Scope Samples"
556 def poll(cls, context):
557 sima = context.space_data
560 def draw(self, context):
562 sima = context.space_data
563 split = layout.split()
565 row.prop(sima.scopes, "use_full_resolution")
567 row.active = not sima.scopes.use_full_resolution
568 row.prop(sima.scopes, "accuracy")
571 class IMAGE_PT_view_properties(bpy.types.Panel):
572 bl_space_type = 'IMAGE_EDITOR'
573 bl_region_type = 'UI'
577 def poll(cls, context):
578 sima = context.space_data
579 return (sima and (sima.image or sima.show_uvedit))
581 def draw(self, context):
584 sima = context.space_data
586 show_uvedit = sima.show_uvedit
587 uvedit = sima.uv_editor
589 split = layout.split()
593 col.prop(ima, "display_aspect", text="Aspect Ratio")
596 col.label(text="Coordinates:")
597 col.prop(sima, "show_repeat", text="Repeat")
599 col.prop(uvedit, "show_normalized_coords", text="Normalized")
602 col.label(text="Coordinates:")
603 col.prop(uvedit, "show_normalized_coords", text="Normalized")
607 col = layout.column()
608 col.label("Cursor Location")
610 row.prop(uvedit, "cursor_location", text="")
612 col = layout.column()
613 col.label(text="UVs:")
615 row.prop(uvedit, "edge_draw_type", expand=True)
617 split = layout.split()
619 col.prop(uvedit, "show_smooth_edges", text="Smooth")
620 col.prop(uvedit, "show_modified_edges", text="Modified")
621 #col.prop(uvedit, "show_edges")
622 #col.prop(uvedit, "show_faces")
625 col.prop(uvedit, "show_stretch", text="Stretch")
627 sub.active = uvedit.show_stretch
628 sub.row().prop(uvedit, "draw_stretch_type", expand=True)
631 class IMAGE_PT_paint(bpy.types.Panel):
632 bl_space_type = 'IMAGE_EDITOR'
633 bl_region_type = 'UI'
637 def poll(cls, context):
638 sima = context.space_data
639 return sima.show_paint
641 def draw(self, context):
644 toolsettings = context.tool_settings.image_paint
645 brush = toolsettings.brush
647 col = layout.split().column()
649 col.template_ID_preview(toolsettings, "brush", new="brush.add", rows=3, cols=8)
652 col = layout.column()
653 col.template_color_wheel(brush, "color", value_slider=True)
654 col.prop(brush, "color", text="")
656 row = col.row(align=True)
657 row.prop(brush, "size", slider=True)
658 row.prop(brush, "use_pressure_size", toggle=True, text="")
660 row = col.row(align=True)
661 row.prop(brush, "strength", slider=True)
662 row.prop(brush, "use_pressure_strength", toggle=True, text="")
664 row = col.row(align=True)
665 row.prop(brush, "jitter", slider=True)
666 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
668 col.prop(brush, "blend", text="Blend")
670 if brush.image_tool == 'CLONE':
672 col.prop(brush, "clone_image", text="Image")
673 col.prop(brush, "clone_alpha", text="Alpha")
676 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, bpy.types.Panel):
678 bl_options = {'DEFAULT_CLOSED'}
680 def draw(self, context):
683 toolsettings = context.tool_settings.image_paint
684 brush = toolsettings.brush
686 col = layout.column()
687 col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
688 col.prop(brush, "use_fixed_texture")
691 class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, bpy.types.Panel):
693 bl_options = {'DEFAULT_CLOSED'}
695 def draw(self, context):
697 settings = context.tool_settings.image_paint
698 brush = settings.brush
700 col = layout.column(align=True)
702 col.prop(brush, "image_tool", expand=False, text="")
704 row = layout.row(align=True)
705 row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT')
706 row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT')
707 row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT')
708 row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
711 class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel):
712 bl_label = "Paint Stroke"
713 bl_options = {'DEFAULT_CLOSED'}
715 def draw(self, context):
718 toolsettings = context.tool_settings.image_paint
719 brush = toolsettings.brush
721 layout.prop(brush, "use_airbrush")
722 col = layout.column()
723 col.active = brush.use_airbrush
724 col.prop(brush, "rate", slider=True)
726 layout.prop(brush, "use_space")
727 row = layout.row(align=True)
728 row.active = brush.use_space
729 row.prop(brush, "spacing", text="Distance", slider=True)
730 row.prop(brush, "use_pressure_spacing", toggle=True, text="")
732 layout.prop(brush, "use_wrap")
735 class IMAGE_PT_paint_curve(BrushButtonsPanel, bpy.types.Panel):
736 bl_label = "Paint Curve"
737 bl_options = {'DEFAULT_CLOSED'}
739 def draw(self, context):
742 toolsettings = context.tool_settings.image_paint
743 brush = toolsettings.brush
745 layout.template_curve_mapping(brush, "curve")
747 row = layout.row(align=True)
748 row.operator("brush.curve_preset", icon="SMOOTHCURVE", text="").shape = 'SMOOTH'
749 row.operator("brush.curve_preset", icon="SPHERECURVE", text="").shape = 'ROUND'
750 row.operator("brush.curve_preset", icon="ROOTCURVE", text="").shape = 'ROOT'
751 row.operator("brush.curve_preset", icon="SHARPCURVE", text="").shape = 'SHARP'
752 row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
753 row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
755 if __name__ == "__main__": # only for live edit.
756 bpy.utils.register_module(__name__)