--- /dev/null
+
+import bpy
+
+class IMAGE_MT_view(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "View"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ uv = sima.uv_editor
+
+ show_uvedit = sima.show_uvedit
+
+ layout.itemO("IMAGE_OT_properties") # icon
+
+ layout.itemS()
+
+ layout.itemR(sima, "update_automatically")
+ # XXX if show_uvedit:
+ # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad /
+
+ layout.itemS()
+
+ layout.itemO("IMAGE_OT_view_zoom_in")
+ layout.itemO("IMAGE_OT_view_zoom_out")
+
+ layout.itemS()
+
+ ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]];
+
+ for a, b in ratios:
+ text = "Zoom %d:%d" % (a, b)
+ layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text)
+
+ layout.itemS()
+
+ if show_uvedit:
+ layout.itemO("IMAGE_OT_view_selected")
+
+ layout.itemO("IMAGE_OT_view_all")
+ layout.itemO("SCREEN_OT_screen_full_area")
+
+class IMAGE_MT_select(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Select"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_select_border")
+ layout.item_booleanO("UV_OT_select_border", "pinned", True)
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_select_all_toggle")
+ layout.itemO("UV_OT_select_invert")
+ layout.itemO("UV_OT_unlink_selection")
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_select_pinned")
+ layout.itemO("UV_OT_select_linked")
+
+class IMAGE_MT_image(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Image"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ ima = sima.image
+
+ layout.itemO("IMAGE_OT_new")
+ layout.itemO("IMAGE_OT_open")
+
+ show_render = sima.show_render
+
+ if ima:
+ if show_render:
+ layout.itemO("IMAGE_OT_replace")
+ layout.itemO("IMAGE_OT_reload")
+
+ layout.itemO("IMAGE_OT_save")
+ layout.itemO("IMAGE_OT_save_as")
+
+ if ima.source == "SEQUENCE":
+ layout.itemO("IMAGE_OT_save_sequence")
+
+ if not show_render:
+ layout.itemS()
+
+ if ima.packed_file:
+ layout.itemO("IMAGE_OT_unpack")
+ else:
+ layout.itemO("IMAGE_OT_pack")
+
+ # only for dirty && specific image types : XXX poll?
+ #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
+ if False:
+ if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER":
+ layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG")
+
+ layout.itemS()
+
+ layout.itemR(sima, "image_painting")
+
+class IMAGE_MT_uvs_showhide(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Show/Hide Faces"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_reveal")
+ layout.itemO("UV_OT_hide")
+ layout.item_booleanO("UV_OT_hide", "unselected", True)
+
+class IMAGE_MT_uvs_transform(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Transform"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION")
+ layout.item_enumO("TFM_OT_transform", "mode", "ROTATION")
+ layout.item_enumO("TFM_OT_transform", "mode", "RESIZE")
+
+class IMAGE_MT_uvs_mirror(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Mirror"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M,
+ layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M,
+
+class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Weld/Align"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_weld") # W, 1
+ layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4
+
+
+class IMAGE_MT_uvs(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "UVs"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ uv = sima.uv_editor
+ scene = context.scene
+
+ layout.itemR(uv, "snap_to_pixels")
+ layout.itemR(uv, "constrain_to_image_bounds")
+
+ layout.itemS()
+
+ layout.itemR(uv, "live_unwrap")
+ layout.itemO("UV_OT_unwrap")
+ layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin")
+ layout.itemO("UV_OT_pin")
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_pack_islands")
+ layout.itemO("UV_OT_average_islands_scale")
+ layout.itemO("UV_OT_minimize_stretch")
+ layout.itemO("UV_OT_stitch")
+
+ layout.itemS()
+
+ layout.itemM(context, "IMAGE_MT_uvs_transform")
+ layout.itemM(context, "IMAGE_MT_uvs_mirror")
+ layout.itemM(context, "IMAGE_MT_uvs_weldalign")
+
+ layout.itemS()
+
+ # XXX layout.itemR(scene, "proportional_editing")
+ layout.item_menu_enumR(scene, "proportional_editing_falloff")
+
+ layout.itemS()
+
+ layout.itemM(context, "IMAGE_MT_uvs_showhide")
+
+class IMAGE_HT_header(bpy.types.Header):
+ __space_type__ = "IMAGE_EDITOR"
+
+ def draw(self, context):
+ sima = context.space_data
+ ima = sima.image
+ layout = self.layout
+
+ show_render = sima.show_render
+ show_paint = sima.show_paint
+ show_uvedit = sima.show_uvedit
+
+ layout.template_header(context)
+
+ # menus
+ if context.area.show_menus:
+ row = layout.row()
+ row.itemM(context, "IMAGE_MT_view")
+
+ if show_uvedit:
+ row.itemM(context, "IMAGE_MT_select")
+
+ # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
+ row.itemM(context, "IMAGE_MT_image")
+
+ if show_uvedit:
+ row.itemM(context, "IMAGE_MT_uvs")
+
+ layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
+
+ """
+ /* image select */
+
+ pinflag= (show_render)? 0: UI_ID_PIN;
+ xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco,
+ sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
+ xco += 8;
+ """
+
+ """
+ if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
+ /* XXX this should not be a static var */
+ static int headerbuttons_packdummy;
+
+ headerbuttons_packdummy = 0;
+
+ if (ima->packedfile) {
+ headerbuttons_packdummy = 1;
+ }
+ if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
+ 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");
+ else
+ uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
+
+ xco+= XIC+8;
+ }
+ """
+
+ # uv editing
+ if show_uvedit:
+ pass
+
+ """
+ /* uv editing */
+ if(show_uvedit) {
+ /* pivot */
+ uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE,
+ "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1",
+ xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0,
+ "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)");
+ xco+= XIC + 18;
+
+ /* selection modes */
+ uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection");
+ xco+= XIC+8;
+
+ if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
+ uiBlockBeginAlign(block);
+
+ uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL,
+ xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
+ uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
+ uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
+
+ uiBlockEndAlign(block);
+ }
+ else {
+ uiBlockBeginAlign(block);
+
+ uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL,
+ xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode");
+
+ uiBlockEndAlign(block);
+
+ /* would use these if const's could go in strings
+ * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
+ but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
+ "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2",
+ xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0,
+ "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)");
+ }
+
+ xco+= XIC + 16;
+
+ /* snap options, identical to options in 3d view header */
+ uiBlockBeginAlign(block);
+
+ if (scene->snap_flag & SCE_SNAP) {
+ uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab).");
+ xco+= XIC;
+ uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode.");
+ xco+= 70;
+ }
+ else {
+ uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab).");
+ xco+= XIC;
+ }
+
+ uiBlockEndAlign(block);
+ xco+= 8;
+
+ /* uv layers */
+ {
+ Object *obedit= CTX_data_edit_object(C);
+ char menustr[34*MAX_MTFACE];
+ static int act;
+
+ image_menu_uvlayers(obedit, menustr, &act);
+
+ but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
+ // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
+
+ xco+= 85;
+ }
+
+ xco+= 8;
+ }
+ """
+
+ if ima:
+ """
+ RenderResult *rr;
+
+ /* render layers and passes */
+ rr= BKE_image_get_renderresult(scene, ima);
+ if(rr) {
+ uiBlockBeginAlign(block);
+#if 0
+ uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160);
+#endif
+ uiBlockEndAlign(block);
+ xco+= 166;
+ }
+ """
+
+ # painting
+ layout.itemR(sima, "image_painting", text="")
+
+ # draw options
+ row = layout.row(align=True)
+ row.itemR(sima, "draw_channels", text="", expand=True)
+
+ row = layout.row(align=True)
+ if ima.type == "COMPOSITE":
+ row.itemO("IMAGE_OT_record_composite", icon="ICON_REC")
+ if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"):
+ row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY")
+
+ layout.itemR(sima, "update_automatically", text="")
+
+class IMAGE_PT_game_properties(bpy.types.Panel):
+ __space_type__ = "IMAGE_EDITOR"
+ __region_type__ = "UI"
+ __label__ = "Game Properties"
+
+ def draw(self, context):
+ sima = context.space_data
+ layout = self.layout
+
+ ima = sima.image
+
+ if ima:
+ split = layout.split()
+
+ col = split.column(align=True)
+ col.itemR(ima, "animated")
+
+ subcol = col.column()
+ subcol.itemR(ima, "animation_start", text="Start")
+ subcol.itemR(ima, "animation_end", text="End")
+ subcol.itemR(ima, "animation_speed", text="Speed")
+ subcol.active = ima.animated
+
+ col = split.column()
+ col.itemR(ima, "tiles")
+
+ subrow = col.row(align=True)
+ subrow.itemR(ima, "tiles_x", text="X")
+ subrow.itemR(ima, "tiles_y", text="Y")
+ subrow.active = ima.tiles
+
+ col.itemS()
+ col.itemR(ima, "clamp_x")
+ col.itemR(ima, "clamp_y")
+
+ col.itemR(ima, "mapping", expand=True)
+
+bpy.types.register(IMAGE_MT_view)
+bpy.types.register(IMAGE_MT_select)
+bpy.types.register(IMAGE_MT_image)
+bpy.types.register(IMAGE_MT_uvs_showhide)
+bpy.types.register(IMAGE_MT_uvs_transform)
+bpy.types.register(IMAGE_MT_uvs_mirror)
+bpy.types.register(IMAGE_MT_uvs_weldalign)
+bpy.types.register(IMAGE_MT_uvs)
+bpy.types.register(IMAGE_HT_header)
+bpy.types.register(IMAGE_PT_game_properties)
+
+
+import bpy
+
+class IMAGE_MT_view(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "View"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ uv = sima.uv_editor
+
+ show_uvedit = sima.show_uvedit
+
+ layout.itemO("IMAGE_OT_properties") # icon
+
+ layout.itemS()
+
+ layout.itemR(sima, "update_automatically")
+ # XXX if show_uvedit:
+ # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad /
+
+ layout.itemS()
+
+ layout.itemO("IMAGE_OT_view_zoom_in")
+ layout.itemO("IMAGE_OT_view_zoom_out")
+
+ layout.itemS()
+
+ ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]];
+
+ for a, b in ratios:
+ text = "Zoom %d:%d" % (a, b)
+ layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text)
+
+ layout.itemS()
+
+ if show_uvedit:
+ layout.itemO("IMAGE_OT_view_selected")
+
+ layout.itemO("IMAGE_OT_view_all")
+ layout.itemO("SCREEN_OT_screen_full_area")
+
+class IMAGE_MT_select(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Select"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_select_border")
+ layout.item_booleanO("UV_OT_select_border", "pinned", True)
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_select_all_toggle")
+ layout.itemO("UV_OT_select_invert")
+ layout.itemO("UV_OT_unlink_selection")
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_select_pinned")
+ layout.itemO("UV_OT_select_linked")
+
+class IMAGE_MT_image(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Image"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ ima = sima.image
+
+ layout.itemO("IMAGE_OT_new")
+ layout.itemO("IMAGE_OT_open")
+
+ show_render = sima.show_render
+
+ if ima:
+ if show_render:
+ layout.itemO("IMAGE_OT_replace")
+ layout.itemO("IMAGE_OT_reload")
+
+ layout.itemO("IMAGE_OT_save")
+ layout.itemO("IMAGE_OT_save_as")
+
+ if ima.source == "SEQUENCE":
+ layout.itemO("IMAGE_OT_save_sequence")
+
+ if not show_render:
+ layout.itemS()
+
+ if ima.packed_file:
+ layout.itemO("IMAGE_OT_unpack")
+ else:
+ layout.itemO("IMAGE_OT_pack")
+
+ # only for dirty && specific image types : XXX poll?
+ #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
+ if False:
+ if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER":
+ layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG")
+
+ layout.itemS()
+
+ layout.itemR(sima, "image_painting")
+
+class IMAGE_MT_uvs_showhide(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Show/Hide Faces"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_reveal")
+ layout.itemO("UV_OT_hide")
+ layout.item_booleanO("UV_OT_hide", "unselected", True)
+
+class IMAGE_MT_uvs_transform(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Transform"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION")
+ layout.item_enumO("TFM_OT_transform", "mode", "ROTATION")
+ layout.item_enumO("TFM_OT_transform", "mode", "RESIZE")
+
+class IMAGE_MT_uvs_mirror(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Mirror"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M,
+ layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M,
+
+class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "Weld/Align"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.itemO("UV_OT_weld") # W, 1
+ layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4
+
+
+class IMAGE_MT_uvs(bpy.types.Menu):
+ __space_type__ = "IMAGE_EDITOR"
+ __label__ = "UVs"
+
+ def draw(self, context):
+ layout = self.layout
+ sima = context.space_data
+ uv = sima.uv_editor
+ scene = context.scene
+
+ layout.itemR(uv, "snap_to_pixels")
+ layout.itemR(uv, "constrain_to_image_bounds")
+
+ layout.itemS()
+
+ layout.itemR(uv, "live_unwrap")
+ layout.itemO("UV_OT_unwrap")
+ layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin")
+ layout.itemO("UV_OT_pin")
+
+ layout.itemS()
+
+ layout.itemO("UV_OT_pack_islands")
+ layout.itemO("UV_OT_average_islands_scale")
+ layout.itemO("UV_OT_minimize_stretch")
+ layout.itemO("UV_OT_stitch")
+
+ layout.itemS()
+
+ layout.itemM(context, "IMAGE_MT_uvs_transform")
+ layout.itemM(context, "IMAGE_MT_uvs_mirror")
+ layout.itemM(context, "IMAGE_MT_uvs_weldalign")
+
+ layout.itemS()
+
+ # XXX layout.itemR(scene, "proportional_editing")
+ layout.item_menu_enumR(scene, "proportional_editing_falloff")
+
+ layout.itemS()
+
+ layout.itemM(context, "IMAGE_MT_uvs_showhide")
+
+class IMAGE_HT_header(bpy.types.Header):
+ __space_type__ = "IMAGE_EDITOR"
+
+ def draw(self, context):
+ sima = context.space_data
+ ima = sima.image
+ layout = self.layout
+
+ show_render = sima.show_render
+ show_paint = sima.show_paint
+ show_uvedit = sima.show_uvedit
+
+ layout.template_header(context)
+
+ # menus
+ if context.area.show_menus:
+ row = layout.row()
+ row.itemM(context, "IMAGE_MT_view")
+
+ if show_uvedit:
+ row.itemM(context, "IMAGE_MT_select")
+
+ # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
+ row.itemM(context, "IMAGE_MT_image")
+
+ if show_uvedit:
+ row.itemM(context, "IMAGE_MT_uvs")
+
+ layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
+
+ """
+ /* image select */
+
+ pinflag= (show_render)? 0: UI_ID_PIN;
+ xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco,
+ sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
+ xco += 8;
+ """
+
+ """
+ if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
+ /* XXX this should not be a static var */
+ static int headerbuttons_packdummy;
+
+ headerbuttons_packdummy = 0;
+
+ if (ima->packedfile) {
+ headerbuttons_packdummy = 1;
+ }
+ if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
+ 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");
+ else
+ uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
+
+ xco+= XIC+8;
+ }
+ """
+
+ # uv editing
+ if show_uvedit:
+ pass
+
+ """
+ /* uv editing */
+ if(show_uvedit) {
+ /* pivot */
+ uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE,
+ "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1",
+ xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0,
+ "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)");
+ xco+= XIC + 18;
+
+ /* selection modes */
+ uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection");
+ xco+= XIC+8;
+
+ if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
+ uiBlockBeginAlign(block);
+
+ uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL,
+ xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
+ uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
+ uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
+
+ uiBlockEndAlign(block);
+ }
+ else {
+ uiBlockBeginAlign(block);
+
+ uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL,
+ xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode");
+ uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL,
+ xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode");
+
+ uiBlockEndAlign(block);
+
+ /* would use these if const's could go in strings
+ * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
+ but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
+ "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2",
+ xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0,
+ "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)");
+ }
+
+ xco+= XIC + 16;
+
+ /* snap options, identical to options in 3d view header */
+ uiBlockBeginAlign(block);
+
+ if (scene->snap_flag & SCE_SNAP) {
+ uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab).");
+ xco+= XIC;
+ uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode.");
+ xco+= 70;
+ }
+ else {
+ uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab).");
+ xco+= XIC;
+ }
+
+ uiBlockEndAlign(block);
+ xco+= 8;
+
+ /* uv layers */
+ {
+ Object *obedit= CTX_data_edit_object(C);
+ char menustr[34*MAX_MTFACE];
+ static int act;
+
+ image_menu_uvlayers(obedit, menustr, &act);
+
+ but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
+ // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
+
+ xco+= 85;
+ }
+
+ xco+= 8;
+ }
+ """
+
+ if ima:
+ """
+ RenderResult *rr;
+
+ /* render layers and passes */
+ rr= BKE_image_get_renderresult(scene, ima);
+ if(rr) {
+ uiBlockBeginAlign(block);
+#if 0
+ uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160);
+#endif
+ uiBlockEndAlign(block);
+ xco+= 166;
+ }
+ """
+
+ # painting
+ layout.itemR(sima, "image_painting", text="")
+
+ # draw options
+ row = layout.row(align=True)
+ row.itemR(sima, "draw_channels", text="", expand=True)
+
+ row = layout.row(align=True)
+ if ima.type == "COMPOSITE":
+ row.itemO("IMAGE_OT_record_composite", icon="ICON_REC")
+ if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"):
+ row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY")
+
+ layout.itemR(sima, "update_automatically", text="")
+
+class IMAGE_PT_game_properties(bpy.types.Panel):
+ __space_type__ = "IMAGE_EDITOR"
+ __region_type__ = "UI"
+ __label__ = "Game Properties"
+
+ def draw(self, context):
+ sima = context.space_data
+ layout = self.layout
+
+ ima = sima.image
+
+ if ima:
+ split = layout.split()
+
+ col = split.column(align=True)
+ col.itemR(ima, "animated")
+
+ subcol = col.column()
+ subcol.itemR(ima, "animation_start", text="Start")
+ subcol.itemR(ima, "animation_end", text="End")
+ subcol.itemR(ima, "animation_speed", text="Speed")
+ subcol.active = ima.animated
+
+ col = split.column()
+ col.itemR(ima, "tiles")
+
+ subrow = col.row(align=True)
+ subrow.itemR(ima, "tiles_x", text="X")
+ subrow.itemR(ima, "tiles_y", text="Y")
+ subrow.active = ima.tiles
+
+ col.itemS()
+ col.itemR(ima, "clamp_x")
+ col.itemR(ima, "clamp_y")
+
+ col.itemR(ima, "mapping", expand=True)
+
+bpy.types.register(IMAGE_MT_view)
+bpy.types.register(IMAGE_MT_select)
+bpy.types.register(IMAGE_MT_image)
+bpy.types.register(IMAGE_MT_uvs_showhide)
+bpy.types.register(IMAGE_MT_uvs_transform)
+bpy.types.register(IMAGE_MT_uvs_mirror)
+bpy.types.register(IMAGE_MT_uvs_weldalign)
+bpy.types.register(IMAGE_MT_uvs)
+bpy.types.register(IMAGE_HT_header)
+bpy.types.register(IMAGE_PT_game_properties)
+
+++ /dev/null
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "GL/glew.h"
-
-#include "GPC_PolygonMaterial.h"
-#include "MT_Vector3.h"
-#include "RAS_IRasterizer.h"
-#include "RAS_GLExtensionManager.h"
-
-/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
-
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_mesh.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "IMB_imbuf_types.h"
-/* end of blender include block */
-
-static Image *fCurpage=0;
-static int fCurtile=0, fCurmode=0, fCurTileXRep=0, fCurTileYRep=0;
-static short fTexWindx, fTexWindy, fTexWinsx, fTexWinsy;
-static int fDoMipMap = 1;
-static int fLinearMipMap=1;
-static int fAlphamode= -1;
-
- /* (n&(n-1)) zeros the least significant bit of n */
-static int is_pow2(int num) {
- return ((num)&(num-1))==0;
-}
-static int smaller_pow2(int num) {
- while (!is_pow2(num))
- num= num&(num-1);
- return num;
-}
-
-static void my_make_repbind(Image *ima)
-{
- if(ima==0 || ima->ibufs.first==0) return;
-
- if(ima->repbind) {
- glDeleteTextures(ima->totbind, (GLuint*)ima->repbind);
- delete (ima->repbind);
- ima->repbind= 0;
- }
- ima->totbind= ima->xrep*ima->yrep;
- if(ima->totbind>1) {
- ima->repbind= (unsigned int *) malloc(sizeof(int)*ima->totbind);
- for (int i=0;i<ima->totbind;i++)
- ((int*)ima->repbind)[i] = 0;
- }
-}
-
-extern "C" int set_tpage(MTFace *tface);
-
-int set_tpage(MTFace *tface)
-{
- static MTFace *lasttface= 0;
- Image *ima;
- unsigned int *rect, *bind;
- int tpx, tpy, tilemode, tileXRep,tileYRep;
-
- /* disable */
- if(tface==0) {
- if(lasttface==0) return 0;
-
- lasttface= 0;
- fCurtile= 0;
- fCurpage= 0;
- if(fCurmode!=0) {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- }
- fCurmode= 0;
- fCurTileXRep=0;
- fCurTileYRep=0;
- fAlphamode= -1;
-
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- return 0;
- }
- lasttface= tface;
-
- if( fAlphamode != tface->transp) {
- fAlphamode= tface->transp;
-
- if(fAlphamode) {
- if(fAlphamode==TF_ADD) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- glDisable ( GL_ALPHA_TEST );
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- }
- else if(fAlphamode==TF_ALPHA) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable ( GL_ALPHA_TEST );
- /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
- }
- else if (fAlphamode==TF_CLIP){
- glDisable(GL_BLEND);
- glEnable ( GL_ALPHA_TEST );
- glAlphaFunc(GL_GREATER, 0.5f);
- }
- /* else { */
- /* glBlendFunc(GL_ONE, GL_ONE); */
- /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */
- /* } */
- }
- else glDisable(GL_BLEND);
- }
-
- ima= (struct Image *) tface->tpage;
-
- /* Enable or disable environment mapping */
- if (ima && (ima->flag & IMA_REFLECT)){
-
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
-
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- }
- else{
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- }
-
- tilemode= tface->mode & TF_TILES;
- tileXRep = 0;
- tileYRep = 0;
- if (ima)
- {
- tileXRep = ima->xrep;
- tileYRep = ima->yrep;
- }
-
-
- if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurTileXRep==tileXRep && fCurTileYRep == tileYRep) return ima!=0;
-
- if(tilemode!=fCurmode || fCurTileXRep!=tileXRep || fCurTileYRep != tileYRep)
- {
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- if(tilemode && ima!=0)
- glScalef(ima->xrep, ima->yrep, 1.0);
-
- glMatrixMode(GL_MODELVIEW);
- }
-
- if(ima==0 || ima->ok==0) {
- glDisable(GL_TEXTURE_2D);
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- return 0;
- }
-
- ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
-
- if(ibuf==0) {
- ima->ok= 0;
-
- fCurtile= tface->tile;
- fCurpage= 0;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- glDisable(GL_TEXTURE_2D);
- return 0;
- }
-
- if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe;
- else fCurtile= tface->tile;
-
- if(tilemode) {
-
- if(ima->repbind==0) my_make_repbind(ima);
-
- if(fCurtile>=ima->totbind) fCurtile= 0;
-
- /* this happens when you change repeat buttons */
- if(ima->repbind) bind= ima->repbind+fCurtile;
- else bind= &ima->bindcode;
-
- if(*bind==0) {
-
- fTexWindx= ibuf->x/ima->xrep;
- fTexWindy= ibuf->y/ima->yrep;
-
- if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1;
-
- fTexWinsy= fCurtile / ima->xrep;
- fTexWinsx= fCurtile - fTexWinsy*ima->xrep;
-
- fTexWinsx*= fTexWindx;
- fTexWinsy*= fTexWindy;
-
- tpx= fTexWindx;
- tpy= fTexWindy;
-
- rect= ibuf->rect + fTexWinsy*ibuf->x + fTexWinsx;
- }
- }
- else {
- bind= &ima->bindcode;
-
- if(*bind==0) {
- tpx= ibuf->x;
- tpy= ibuf->y;
- rect= ibuf->rect;
- }
- }
-
- if(*bind==0) {
- int rectw= tpx, recth= tpy;
- unsigned int *tilerect= NULL, *scalerect= NULL;
-
- /*
- * Maarten:
- * According to Ton this code is not needed anymore. It was used only
- * in really old Blenders.
- * Reevan:
- * Actually it is needed for backwards compatibility. Simpledemo 6 does not display correctly without it.
- */
-#if 1
- if (tilemode) {
- int y;
-
- tilerect= (unsigned int*)MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
- for (y=0; y<recth; y++) {
- unsigned int *rectrow= &rect[y*ibuf->x];
- unsigned int *tilerectrow= &tilerect[y*rectw];
-
- memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow));
- }
-
- rect= tilerect;
- }
-#endif
- if (!is_pow2(rectw) || !is_pow2(recth)) {
- rectw= smaller_pow2(rectw);
- recth= smaller_pow2(recth);
-
- scalerect= (unsigned int *)MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect");
- gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect);
- rect= scalerect;
- }
-
- glGenTextures(1, (GLuint*)bind);
-
- /*
- if(G.f & G_DEBUG) {
- printf("var1: %s\n", ima->id.name+2);
- printf("var1: %d, var2: %d\n", *bind, tpx);
- printf("var1: %d, var2: %d\n", fCurtile, tilemode);
- }
- */
- glBindTexture( GL_TEXTURE_2D, *bind);
-
- if (!fDoMipMap)
- {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- } else
- {
- int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST;
-
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (tilerect)
- MEM_freeN(tilerect);
- if (scalerect)
- MEM_freeN(scalerect);
- }
- else glBindTexture( GL_TEXTURE_2D, *bind);
-
-
-
- glEnable(GL_TEXTURE_2D);
-
- fCurpage= ima;
- fCurmode= tilemode;
- fCurTileXRep = tileXRep;
- fCurTileYRep = tileYRep;
-
- return 1;
-}
-
-#if 0
-GPC_PolygonMaterial::GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname,
- int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort,
- int lightlayer, bool bIsTriangle, void* clientobject, void* tpage) :
- RAS_IPolyMaterial(texname, ba, matname, tile, tileXrep, tileYrep, mode,
- transparant, zsort, lightlayer, bIsTriangle, clientobject), m_tface((struct MTFace*)tpage)
-{
- // clear local caching info
- my_set_tpage(0);
-}
-
-
-GPC_PolygonMaterial::~GPC_PolygonMaterial(void)
-{
-}
-
-
-void GPC_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
-{
- if (GetCachingInfo() != cachingInfo)
- {
- if (!cachingInfo)
- {
- my_set_tpage(0);
- }
- cachingInfo = GetCachingInfo();
-
- if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) )
- {
- update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime());
- my_set_tpage(m_tface);
- rasty->EnableTextures(true);
- } else
- {
- my_set_tpage(0);
- rasty->EnableTextures(false);
- }
-
- //TF_TWOSIDE == 512, todo, make this a ketsji enum
- if(m_drawingmode & 512) {
- rasty->SetCullFace(false);
- }
-
- else
- {
- rasty->SetCullFace(true);//glEnable(GL_CULL_FACE);
- //else glDisable(GL_CULL_FACE);
- }
- }
- rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
- rasty->SetShinyness(m_shininess);
- rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0);
-}
-
-#endif
-void GPC_PolygonMaterial::SetMipMappingEnabled(bool enabled)
-{
- fDoMipMap = enabled ? 1 : 0;
-}