4 class IMAGE_MT_view(bpy.types.Menu):
5 __space_type__ = "IMAGE_EDITOR"
8 def draw(self, context):
10 sima = context.space_data
12 settings = context.scene.tool_settings
14 show_uvedit = sima.show_uvedit
16 layout.itemO("IMAGE_OT_properties") # icon
20 layout.itemR(sima, "update_automatically")
22 layout.itemR(settings, "uv_local_view") # Numpad /
26 layout.itemO("IMAGE_OT_view_zoom_in")
27 layout.itemO("IMAGE_OT_view_zoom_out")
31 ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]];
34 text = "Zoom %d:%d" % (a, b)
35 layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text)
40 layout.itemO("IMAGE_OT_view_selected")
42 layout.itemO("IMAGE_OT_view_all")
43 layout.itemO("SCREEN_OT_screen_full_area")
45 class IMAGE_MT_select(bpy.types.Menu):
46 __space_type__ = "IMAGE_EDITOR"
49 def draw(self, context):
52 layout.itemO("UV_OT_select_border")
53 layout.item_booleanO("UV_OT_select_border", "pinned", True)
57 layout.itemO("UV_OT_select_all_toggle")
58 layout.itemO("UV_OT_select_invert")
59 layout.itemO("UV_OT_unlink_selection")
63 layout.itemO("UV_OT_select_pinned")
64 layout.itemO("UV_OT_select_linked")
66 class IMAGE_MT_image(bpy.types.Menu):
67 __space_type__ = "IMAGE_EDITOR"
70 def draw(self, context):
72 sima = context.space_data
75 layout.itemO("IMAGE_OT_new")
76 layout.itemO("IMAGE_OT_open")
78 show_render = sima.show_render
82 layout.itemO("IMAGE_OT_replace")
83 layout.itemO("IMAGE_OT_reload")
85 layout.itemO("IMAGE_OT_save")
86 layout.itemO("IMAGE_OT_save_as")
88 if ima.source == "SEQUENCE":
89 layout.itemO("IMAGE_OT_save_sequence")
95 layout.itemO("IMAGE_OT_unpack")
97 layout.itemO("IMAGE_OT_pack")
99 # only for dirty && specific image types : XXX poll?
100 #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
102 if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER":
103 layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG")
107 layout.itemR(sima, "image_painting")
109 class IMAGE_MT_uvs_showhide(bpy.types.Menu):
110 __space_type__ = "IMAGE_EDITOR"
111 __label__ = "Show/Hide Faces"
113 def draw(self, context):
116 layout.itemO("UV_OT_reveal")
117 layout.itemO("UV_OT_hide")
118 layout.item_booleanO("UV_OT_hide", "unselected", True)
120 class IMAGE_MT_uvs_transform(bpy.types.Menu):
121 __space_type__ = "IMAGE_EDITOR"
122 __label__ = "Transform"
124 def draw(self, context):
127 layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION")
128 layout.item_enumO("TFM_OT_transform", "mode", "ROTATION")
129 layout.item_enumO("TFM_OT_transform", "mode", "RESIZE")
131 class IMAGE_MT_uvs_mirror(bpy.types.Menu):
132 __space_type__ = "IMAGE_EDITOR"
135 def draw(self, context):
138 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M,
139 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M,
141 class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
142 __space_type__ = "IMAGE_EDITOR"
143 __label__ = "Weld/Align"
145 def draw(self, context):
148 layout.itemO("UV_OT_weld") # W, 1
149 layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4
152 class IMAGE_MT_uvs(bpy.types.Menu):
153 __space_type__ = "IMAGE_EDITOR"
156 def draw(self, context):
158 sima = context.space_data
160 settings = context.scene.tool_settings
162 layout.itemR(uv, "snap_to_pixels")
163 layout.itemR(uv, "constrain_to_image_bounds")
167 layout.itemR(uv, "live_unwrap")
168 layout.itemO("UV_OT_unwrap")
169 layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin")
170 layout.itemO("UV_OT_pin")
174 layout.itemO("UV_OT_pack_islands")
175 layout.itemO("UV_OT_average_islands_scale")
176 layout.itemO("UV_OT_minimize_stretch")
177 layout.itemO("UV_OT_stitch")
181 layout.itemM("IMAGE_MT_uvs_transform")
182 layout.itemM("IMAGE_MT_uvs_mirror")
183 layout.itemM("IMAGE_MT_uvs_weldalign")
187 layout.itemR(settings, "proportional_editing")
188 layout.item_menu_enumR(settings, "proportional_editing_falloff")
192 layout.itemM("IMAGE_MT_uvs_showhide")
194 class IMAGE_HT_header(bpy.types.Header):
195 __space_type__ = "IMAGE_EDITOR"
197 def draw(self, context):
198 sima = context.space_data
200 iuser = sima.image_user
202 settings = context.scene.tool_settings
204 show_render = sima.show_render
205 show_paint = sima.show_paint
206 show_uvedit = sima.show_uvedit
208 layout.template_header()
211 if context.area.show_menus:
213 row.itemM("IMAGE_MT_view")
216 row.itemM("IMAGE_MT_select")
218 # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
219 row.itemM("IMAGE_MT_image")
222 row.itemM("IMAGE_MT_uvs")
224 layout.template_ID(sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
229 pinflag= (show_render)? 0: UI_ID_PIN;
230 xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco,
231 sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
236 if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
237 /* XXX this should not be a static var */
238 static int headerbuttons_packdummy;
240 headerbuttons_packdummy = 0;
242 if (ima->packedfile) {
243 headerbuttons_packdummy = 1;
245 if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
246 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
248 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
256 uvedit = sima.uv_editor
260 layout.itemR(uvedit, "pivot", text="")
261 layout.itemR(settings, "uv_sync_selection", text="")
263 if settings.uv_sync_selection:
264 layout.itemR(settings, "mesh_selection_mode", text="", expand=True)
266 layout.itemR(settings, "uv_selection_mode", text="", expand=True)
267 layout.itemR(uvedit, "sticky_selection_mode", text="")
270 row = layout.row(align=True)
271 row.itemR(settings, "snap", text="")
273 row.itemR(settings, "snap_mode", text="")
278 Object *obedit= CTX_data_edit_object(C);
279 char menustr[34*MAX_MTFACE];
282 image_menu_uvlayers(obedit, menustr, &act);
284 but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
285 // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
290 layout.template_image_layers(ima, iuser)
293 layout.itemR(sima, "image_painting", text="")
296 row = layout.row(align=True)
297 row.itemR(sima, "draw_channels", text="", expand=True)
299 row = layout.row(align=True)
300 if ima.type == "COMPOSITE":
301 row.itemO("IMAGE_OT_record_composite", icon="ICON_REC")
302 if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"):
303 row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY")
305 layout.itemR(sima, "update_automatically", text="")
307 class IMAGE_PT_game_properties(bpy.types.Panel):
308 __space_type__ = "IMAGE_EDITOR"
309 __region_type__ = "UI"
310 __label__ = "Game Properties"
312 def poll(self, context):
313 sima = context.space_data
314 return (sima and sima.image)
316 def draw(self, context):
317 sima = context.space_data
323 split = layout.split()
327 subcol = col.column(align=True)
328 subcol.itemR(ima, "clamp_x")
329 subcol.itemR(ima, "clamp_y")
331 col.itemR(ima, "mapping", expand=True)
332 col.itemR(ima, "tiles")
336 subcol = col.column(align=True)
337 subcol.itemR(ima, "animated")
339 subcol = subcol.column()
340 subcol.itemR(ima, "animation_start", text="Start")
341 subcol.itemR(ima, "animation_end", text="End")
342 subcol.itemR(ima, "animation_speed", text="Speed")
343 subcol.active = ima.animated
345 subrow = col.row(align=True)
346 subrow.itemR(ima, "tiles_x", text="X")
347 subrow.itemR(ima, "tiles_y", text="Y")
348 subrow.active = ima.tiles or ima.animated
350 class IMAGE_PT_view_properties(bpy.types.Panel):
351 __space_type__ = "IMAGE_EDITOR"
352 __region_type__ = "UI"
353 __label__ = "View Properties"
355 def draw(self, context):
356 sima = context.space_data
360 show_uvedit = sima.show_uvedit
361 uvedit = sima.uv_editor
363 split = layout.split()
367 col.itemR(ima, "display_aspect")
370 col.itemR(sima, "draw_repeated", text="Repeat")
372 col.itemR(uvedit, "normalized_coordinates")
375 col = layout.column()
377 row.itemR(uvedit, "edge_draw_type", expand=True)
379 row.itemR(uvedit, "draw_smooth_edges", text="Smooth")
380 row.itemR(uvedit, "draw_modified_edges", text="Modified")
383 row.itemR(uvedit, "draw_stretch", text="Stretch")
384 row.itemR(uvedit, "draw_stretch_type", text="")
385 #col.itemR(uvedit, "draw_edges")
386 #col.itemR(uvedit, "draw_faces")
388 class IMAGE_PT_curves(bpy.types.Panel):
389 __space_type__ = "IMAGE_EDITOR"
390 __region_type__ = "UI"
393 def poll(self, context):
394 sima = context.space_data
395 return (sima and sima.image)
397 def draw(self, context):
398 sima = context.space_data
401 layout.template_curve_mapping(sima.curves)
403 bpy.types.register(IMAGE_MT_view)
404 bpy.types.register(IMAGE_MT_select)
405 bpy.types.register(IMAGE_MT_image)
406 bpy.types.register(IMAGE_MT_uvs_showhide)
407 bpy.types.register(IMAGE_MT_uvs_transform)
408 bpy.types.register(IMAGE_MT_uvs_mirror)
409 bpy.types.register(IMAGE_MT_uvs_weldalign)
410 bpy.types.register(IMAGE_MT_uvs)
411 bpy.types.register(IMAGE_HT_header)
412 bpy.types.register(IMAGE_PT_game_properties)
413 bpy.types.register(IMAGE_PT_view_properties)
414 #bpy.types.register(IMAGE_PT_curves)