From 9fd605c0502d991af30a4d4b91681b4116658f45 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 23 Jun 2009 00:45:41 +0000 Subject: [PATCH] 2.5: Image Editor * Menu and header more complete now. * Clean up Game Properties panel and moved View Properties panel to python. * Fix some drawing issues when combining tiles, repeat and aspect, some also from 2.4x, these options didn't work together 100%. --- release/ui/space_image.py | 581 +++--------------- source/blender/editors/include/UI_icons.h | 2 +- source/blender/editors/include/UI_interface.h | 3 + .../editors/space_image/image_buttons.c | 42 +- .../blender/editors/space_image/image_draw.c | 28 +- .../blender/editors/space_image/space_image.c | 8 +- .../editors/transform/transform_generics.c | 3 +- source/blender/makesrna/intern/rna_image.c | 26 +- source/blender/makesrna/intern/rna_space.c | 53 +- source/blender/makesrna/intern/rna_ui_api.c | 7 + 10 files changed, 186 insertions(+), 567 deletions(-) diff --git a/release/ui/space_image.py b/release/ui/space_image.py index dc20ee2d6cd..e49172fd3f1 100644 --- a/release/ui/space_image.py +++ b/release/ui/space_image.py @@ -9,6 +9,7 @@ class IMAGE_MT_view(bpy.types.Menu): layout = self.layout sima = context.space_data uv = sima.uv_editor + settings = context.scene.tool_settings show_uvedit = sima.show_uvedit @@ -17,8 +18,8 @@ class IMAGE_MT_view(bpy.types.Menu): layout.itemS() layout.itemR(sima, "update_automatically") - # XXX if show_uvedit: - # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad / + if show_uvedit: + layout.itemR(settings, "uv_local_view") # Numpad / layout.itemS() @@ -156,7 +157,7 @@ class IMAGE_MT_uvs(bpy.types.Menu): layout = self.layout sima = context.space_data uv = sima.uv_editor - scene = context.scene + settings = context.scene.tool_settings layout.itemR(uv, "snap_to_pixels") layout.itemR(uv, "constrain_to_image_bounds") @@ -183,8 +184,8 @@ class IMAGE_MT_uvs(bpy.types.Menu): layout.itemS() - # XXX layout.itemR(scene, "proportional_editing") - layout.item_menu_enumR(scene, "proportional_editing_falloff") + layout.itemR(settings, "proportional_editing") + layout.item_menu_enumR(settings, "proportional_editing_falloff") layout.itemS() @@ -196,7 +197,9 @@ class IMAGE_HT_header(bpy.types.Header): def draw(self, context): sima = context.space_data ima = sima.image + iuser = sima.image_user layout = self.layout + settings = context.scene.tool_settings show_render = sima.show_render show_paint = sima.show_paint @@ -250,75 +253,26 @@ class IMAGE_HT_header(bpy.types.Header): # 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; + uvedit = sima.uv_editor - 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)"); - } + layout.itemS() - 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; - } + layout.itemR(uvedit, "pivot", text="") + layout.itemR(settings, "uv_sync_selection", text="") + + if settings.uv_sync_selection: + layout.itemR(settings, "mesh_selection_mode", text="", expand=True) + else: + layout.itemR(settings, "uv_selection_mode", text="", expand=True) + layout.itemR(uvedit, "sticky_selection_mode", text="") + pass - uiBlockEndAlign(block); - xco+= 8; + row = layout.row(align=True) + row.itemR(settings, "snap", text="") + if settings.snap: + row.itemR(settings, "snap_mode", text="") + """ /* uv layers */ { Object *obedit= CTX_data_edit_object(C); @@ -329,29 +283,11 @@ class IMAGE_HT_header(bpy.types.Header): 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; - } - """ + # layers + layout.template_image_layers(ima, iuser) # painting layout.itemR(sima, "image_painting", text="") @@ -373,6 +309,10 @@ class IMAGE_PT_game_properties(bpy.types.Panel): __region_type__ = "UI" __label__ = "Game Properties" + def poll(self, context): + sima = context.space_data + return (sima and sima.image) + def draw(self, context): sima = context.space_data layout = self.layout @@ -382,446 +322,83 @@ class IMAGE_PT_game_properties(bpy.types.Panel): if ima: split = layout.split() - col = split.column(align=True) - col.itemR(ima, "animated") + col = split.column() + + subcol = col.column(align=True) + subcol.itemR(ima, "clamp_x") + subcol.itemR(ima, "clamp_y") + + col.itemR(ima, "mapping", expand=True) + col.itemR(ima, "tiles") - subcol = col.column() + col = split.column() + + subcol = col.column(align=True) + subcol.itemR(ima, "animated") + + subcol = subcol.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) - + subrow.active = ima.tiles or ima.animated -import bpy - -class IMAGE_MT_view(bpy.types.Menu): +class IMAGE_PT_view_properties(bpy.types.Panel): __space_type__ = "IMAGE_EDITOR" - __label__ = "View" + __region_type__ = "UI" + __label__ = "View Properties" 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("IMAGE_MT_uvs_transform") - layout.itemM("IMAGE_MT_uvs_mirror") - layout.itemM("IMAGE_MT_uvs_weldalign") - - layout.itemS() - - # XXX layout.itemR(scene, "proportional_editing") - layout.item_menu_enumR(scene, "proportional_editing_falloff") - - layout.itemS() - - layout.itemM("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 + uvedit = sima.uv_editor - layout.template_header() - - # menus - if context.area.show_menus: - row = layout.row() - row.itemM("IMAGE_MT_view") - - if show_uvedit: - row.itemM("IMAGE_MT_select") - - # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image"; - row.itemM("IMAGE_MT_image") - - if show_uvedit: - row.itemM("IMAGE_MT_uvs") - - layout.template_ID(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; - } - """ + split = layout.split() + col = split.column() 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) + col.itemR(ima, "display_aspect") - 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="") + col = split.column() + col.itemR(sima, "draw_repeated", text="Repeat") + if show_uvedit: + col.itemR(uvedit, "normalized_coordinates") -class IMAGE_PT_game_properties(bpy.types.Panel): + if show_uvedit: + col = layout.column() + row = col.row() + row.itemR(uvedit, "edge_draw_type", expand=True) + row = col.row() + row.itemR(uvedit, "draw_smooth_edges", text="Smooth") + row.itemR(uvedit, "draw_modified_edges", text="Modified") + + row = col.row() + row.itemR(uvedit, "draw_stretch", text="Stretch") + row.itemR(uvedit, "draw_stretch_type", text="") + #col.itemR(uvedit, "draw_edges") + #col.itemR(uvedit, "draw_faces") + +class IMAGE_PT_curves(bpy.types.Panel): __space_type__ = "IMAGE_EDITOR" __region_type__ = "UI" - __label__ = "Game Properties" + __label__ = "Curves" + + def poll(self, context): + sima = context.space_data + return (sima and sima.image) 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) + layout.template_curve_mapping(sima.curves) bpy.types.register(IMAGE_MT_view) bpy.types.register(IMAGE_MT_select) @@ -833,4 +410,6 @@ 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) +bpy.types.register(IMAGE_PT_view_properties) +#bpy.types.register(IMAGE_PT_curves) diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 884020ae7dc..602e94838b7 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -658,12 +658,12 @@ DEF_ICON(ICON_SNAP_VERTEX) DEF_ICON(ICON_SNAP_EDGE) DEF_ICON(ICON_SNAP_FACE) DEF_ICON(ICON_SNAP_VOLUME) +DEF_ICON(ICON_UVS_FACE) DEF_ICON(ICON_STICKY_UVS_LOC) DEF_ICON(ICON_STICKY_UVS_DISABLE) DEF_ICON(ICON_STICKY_UVS_VERT) DEF_ICON(ICON_CLIPUV_DEHLT) DEF_ICON(ICON_CLIPUV_HLT) -DEF_ICON(ICON_BLANK219) DEF_ICON(ICON_SNAP_PEEL_OBJECT) DEF_ICON(ICON_BLANK221) DEF_ICON(ICON_GRID) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 62469686e7f..80e57f5e5be 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -53,6 +53,8 @@ struct uiStyle; struct uiFontStyle; struct ColorBand; struct CurveMapping; +struct Image; +struct ImageUser; typedef struct uiBut uiBut; typedef struct uiBlock uiBlock; @@ -614,6 +616,7 @@ void uiTemplatePreview(uiLayout *layout, struct ID *id); void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); +void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); /* items */ void uiItemO(uiLayout *layout, char *name, int icon, char *opname); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index b5df0257e71..8aa955f0b34 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1023,42 +1023,53 @@ static void image_load_fs_cb(bContext *C, void *ima_pp_v, void *iuser_v) static void image_multi_cb(bContext *C, void *rr_v, void *iuser_v) { BKE_image_multilayer_index(rr_v, iuser_v); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) { RenderResult *rr= rr_v; ImageUser *iuser= iuser_v; int tot= BLI_countlist(&rr->layers) + (rr->rectf?1:0); /* fake compo result layer */ - if(iuser->layerlayerlayer++; - BKE_image_multilayer_index(rr, iuser); + BKE_image_multilayer_index(rr, iuser); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); + } } static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; - if(iuser->layer>0) + + if(iuser->layer>0) { iuser->layer--; - BKE_image_multilayer_index(rr_v, iuser); + BKE_image_multilayer_index(rr_v, iuser); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); + } } static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v) { RenderResult *rr= rr_v; ImageUser *iuser= iuser_v; RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer); + if(rl) { int tot= BLI_countlist(&rl->passes) + (rl->rectf?1:0); /* builtin render result has no combined pass in list */ if(iuser->passpass++; BKE_image_multilayer_index(rr, iuser); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } } } static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; + if(iuser->pass>0) { iuser->pass--; BKE_image_multilayer_index(rr_v, iuser); + WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); } } @@ -1353,6 +1364,23 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I uiBlockEndAlign(block); } +void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser) +{ + uiBlock *block= uiLayoutFreeBlock(layout); + Scene *scene= CTX_data_scene(C); + RenderResult *rr; + + /* render layers and passes */ + if(ima && iuser) { + rr= BKE_image_get_renderresult(scene, ima); + + if(rr) { + uiBlockBeginAlign(block); + uiblock_layer_pass_buttons(block, rr, iuser, 0, 0, 0, 160); + uiBlockEndAlign(block); + } + } +} static void image_panel_properties(const bContext *C, Panel *pa) { @@ -1377,12 +1405,6 @@ void image_buttons_register(ARegionType *art) pt->draw= image_panel_properties; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image view properties"); - strcpy(pt->idname, "IMAGE_PT_view_properties"); - strcpy(pt->label, "View Properties"); - pt->draw= image_panel_view_properties; - BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image panel paint"); strcpy(pt->idname, "IMAGE_PT_paint"); strcpy(pt->label, "Paint"); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 122e298baaa..e61931f2fad 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -311,12 +311,14 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl // glColorMask(1, 1, 1, 1); } +#ifdef WITH_LCMS static void sima_draw_colorcorrected_pixels(float x1, float y1, ImBuf *ibuf) { colorcorrection_do_ibuf(ibuf, "MONOSCNR.ICM"); /* path is hardcoded here, find some place better */ glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->crect); } +#endif static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti) { @@ -450,7 +452,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, return rectmain; } -static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) +static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) { unsigned int *rect; int dx, dy, sx, sy, x, y; @@ -477,7 +479,7 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Image *ima, I /* draw repeated */ for(sy=0; sy+dy<=ibuf->y; sy+= dy) { for(sx=0; sx+dx<=ibuf->x; sx+= dx) { - UI_view2d_view_to_region(&ar->v2d, (float)sx/(float)ibuf->x, (float)sy/(float)ibuf->y, &x, &y); + UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx/(float)ibuf->x, fy + (float)sy/(float)ibuf->y, &x, &y); glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect); } @@ -488,16 +490,19 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Image *ima, I MEM_freeN(rect); } -static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float zoomx, float zoomy) +static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) { float x, y; double time_current; time_current = PIL_check_seconds_timer(); - for(x=ar->v2d.cur.xmin; xv2d.cur.xmax; x += zoomx) { - for(y=ar->v2d.cur.ymin; yv2d.cur.ymax; y += zoomy) { - draw_image_buffer(sima, ar, scene, ibuf, x, y, zoomx, zoomy); + for(x=floor(ar->v2d.cur.xmin); xv2d.cur.xmax; x += 1.0f) { + for(y=floor(ar->v2d.cur.ymin); yv2d.cur.ymax; y += 1.0f) { + if(ima && (ima->tpageflag & IMA_TILES)) + draw_image_buffer_tiled(sima, ar, ima, ibuf, x, y, zoomx, zoomy); + else + draw_image_buffer(sima, ar, scene, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ if((PIL_check_seconds_timer() - time_current) > 0.25) @@ -667,9 +672,9 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) if(ibuf==NULL) draw_image_grid(ar, zoomx, zoomy); else if(sima->flag & SI_DRAW_TILE) - draw_image_buffer_repeated(sima, ar, scene, ibuf, zoomx, zoomy); + draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy); else if(ima && (ima->tpageflag & IMA_TILES)) - draw_image_buffer_tiled(sima, ar, ima, ibuf, zoomx, zoomy); + draw_image_buffer_tiled(sima, ar, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); else draw_image_buffer(sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); @@ -699,12 +704,5 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) } } #endif - -#if 0 - /* it is important to end a view in a transform compatible with buttons */ - bwin_scalematrix(sa->win, sima->blockscale, sima->blockscale, sima->blockscale); - if(!(G.rendering && show_render)) - image_blockhandlers(sa); -#endif } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 49f950fe67b..7d6faa00dfc 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -327,12 +327,10 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar, Scene *sce #endif if(sima->image) { ImBuf *ibuf= ED_space_image_buffer(sima); - float xuser_asp, yuser_asp; - ED_image_aspect(sima->image, &xuser_asp, &yuser_asp); if(ibuf) { - width= ibuf->x*xuser_asp; - height= ibuf->y*yuser_asp; + width= ibuf->x; + height= ibuf->y; } else if(sima->image->type==IMA_TYPE_R_RESULT) { /* not very important, just nice */ @@ -683,7 +681,7 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy) *aspx= *aspy= 1.0; if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || - (ima->tpageflag & IMA_TILES) || (ima->aspx==0.0 || ima->aspy==0.0)) + (ima->aspx==0.0 || ima->aspy==0.0)) return; /* x is always 1 */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index f4cb5afc3c2..e157d7f68f9 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -754,9 +754,10 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } else if(t->spacetype==SPACE_IMAGE || t->spacetype==SPACE_NODE) { + SpaceImage *sima = sa->spacedata.first; // XXX for now, get View2D from the active region t->view = &ar->v2d; - t->around = ar->v2d.around; + t->around = sima->around; } else { diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 252cd633b69..4a6fdf5a734 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -35,6 +35,8 @@ #include "BKE_context.h" #include "BKE_image.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME static void rna_Image_animated_update(bContext *C, PointerRNA *ptr) @@ -133,16 +135,19 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */ RNA_def_property_ui_text(prop, "Filename", "Image/Movie file name."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_source_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */ RNA_def_property_ui_text(prop, "Source", "Where the image comes from."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* imagechanged */ RNA_def_property_ui_text(prop, "Type", "How to generate the image."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); @@ -152,90 +157,105 @@ static void rna_def_image(BlenderRNA *brna) prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); RNA_def_property_ui_text(prop, "Fields", "Use fields of the image."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "odd_fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_STD_FIELD); RNA_def_property_ui_text(prop, "Odd Fields", "Standard field toggle."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "antialias", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANTIALI); RNA_def_property_ui_text(prop, "Anti-alias", "Toggles image anti-aliasing, only works with solid colors"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* generated image (image_generated_change_cb) */ prop= RNA_def_property(srna, "generated_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "gen_type"); RNA_def_property_enum_items(prop, prop_generated_type_items); RNA_def_property_ui_text(prop, "Generated Type", "Generated image type."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_x"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Width", "Generated image width."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_y"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Height", "Generated image height."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* realtime properties */ prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_mapping_items); RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "aspx"); RNA_def_property_array(prop, 2); RNA_def_property_range(prop, 0.1f, 5000.0f); RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "animated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM); RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine."); - RNA_def_property_update(prop, 0, "rna_Image_animated_update"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_start", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "twsta"); RNA_def_property_range(prop, 0, 128); RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture."); - RNA_def_property_update(prop, 0, "rna_Image_animated_update"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_end", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "twend"); RNA_def_property_range(prop, 0, 128); RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture."); - RNA_def_property_update(prop, 0, "rna_Image_animated_update"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "animspeed"); RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES); RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xrep"); RNA_def_property_range(prop, 1, 16); RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "yrep"); RNA_def_property_range(prop, 1, 16); RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "clamp_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U); RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "clamp_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V); RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); } void RNA_def_image(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 66d98d98834..d5ac0d6e427 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -246,19 +246,10 @@ static void rna_def_space_image_uv(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; -#if 0 - static EnumPropertyItem select_mode_items[] = { - {SI_SELECT_VERTEX, "VERTEX", 0, "Vertex", "Vertex selection mode."}, - //{SI_SELECT_EDGE, "Edge", 0, "Edge", "Edge selection mode."}, - {SI_SELECT_FACE, "FACE", 0, "Face", "Face selection mode."}, - {SI_SELECT_ISLAND, "ISLAND", 0, "Island", "Island selection mode."}, - {0, NULL, 0, NULL, NULL}}; -#endif - static EnumPropertyItem sticky_mode_items[] = { - {SI_STICKY_DISABLE, "DISABLED", 0, "Disabled", "Sticky vertex selection disabled."}, - {SI_STICKY_LOC, "SHARED_LOCATION", 0, "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."}, - {SI_STICKY_VERTEX, "SHARED_VERTEX", 0, "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."}, + {SI_STICKY_DISABLE, "DISABLED", ICON_STICKY_UVS_DISABLE, "Disabled", "Sticky vertex selection disabled."}, + {SI_STICKY_LOC, "SHARED_LOCATION", ICON_STICKY_UVS_LOC, "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."}, + {SI_STICKY_VERTEX, "SHARED_VERTEX", ICON_STICKY_UVS_VERT, "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dt_uv_items[] = { @@ -273,17 +264,18 @@ static void rna_def_space_image_uv(BlenderRNA *brna) {SI_UVDT_STRETCH_AREA, "AREA", 0, "Area", "Area distortion between UV and 3D faces."}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem pivot_items[] = { + {V3D_CENTER, "CENTER", ICON_ROTATE, "Bounding Box Center", ""}, + {V3D_CENTROID, "MEDIAN", ICON_ROTATECENTER, "Median Point", ""}, + {V3D_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "SpaceUVEditor", NULL); RNA_def_struct_sdna(srna, "SpaceImage"); RNA_def_struct_nested(brna, srna, "SpaceImageEditor"); RNA_def_struct_ui_text(srna, "Space UV Editor", "UV editor data for the image editor space."); /* selection */ - /*prop= RNA_def_property(srna, "selection_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "selectmode"); - RNA_def_property_enum_items(prop, select_mode_items); - RNA_def_property_ui_text(prop, "Selection Mode", "UV selection and display mode.");*/ - prop= RNA_def_property(srna, "sticky_selection_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "sticky"); RNA_def_property_enum_items(prop, sticky_mode_items); @@ -313,16 +305,15 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw."); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - prop= RNA_def_property(srna, "draw_modified_edges", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch"); - RNA_def_property_enum_items(prop, dt_uvstretch_items); - RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges from the final mesh after object modifier evaluation."); + prop= RNA_def_property(srna, "draw_modified_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWSHADOW); + RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges after modifiers are applied."); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - /*prop= RNA_def_property(srna, "local_view", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LOCAL_UV); - RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned."); - RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);*/ + prop= RNA_def_property(srna, "draw_other_objects", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_OTHER); + RNA_def_property_ui_text(prop, "Draw Other Objects", "Draw other selected objects that share the same image."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "normalized_coordinates", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS); @@ -331,12 +322,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna) /* todo: move edge and face drawing options here from G.f */ - /* editing */ - /*prop= RNA_def_property(srna, "sync_selection", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SYNC_UVSEL); - RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync."); - RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);*/ - prop= RNA_def_property(srna, "snap_to_pixels", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP); RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixel locations while editing."); @@ -348,6 +333,12 @@ static void rna_def_space_image_uv(BlenderRNA *brna) prop= RNA_def_property(srna, "live_unwrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LIVE_UNWRAP); RNA_def_property_ui_text(prop, "Live Unwrap", "Continuously unwrap the selected UV island while transforming pinned vertices."); + + prop= RNA_def_property(srna, "pivot", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "around"); + RNA_def_property_enum_items(prop, pivot_items); + RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); } static void rna_def_space_outliner(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index c1c2f9a100a..d8648e05153 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -242,6 +242,13 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "template_layers", "uiTemplateLayers"); api_ui_item_rna_common(func); + + func= RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm= RNA_def_pointer(func, "image", "Image", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "image_user", "ImageUser", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); } #endif -- 2.28.0