From 7b32a4b6b077492509ccdbfa0bc98d14ce32ddbf Mon Sep 17 00:00:00 2001 From: Rombout Versluijs Date: Fri, 11 Jan 2019 23:43:12 -0400 Subject: [PATCH 1/4] - Added support for Blender 2.80 --- CHANGELOG.md | 6 +- README.md | 18 ++-- __init__.py | 172 +++++++++++++++++++++++++------------ icons/image_empty_128x.png | Bin 0 -> 2684 bytes 4 files changed, 136 insertions(+), 60 deletions(-) create mode 100644 icons/image_empty_128x.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e2ac3a..9ac1dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## [0.2.2_2.80] - 2019-01-29 +### Added +- Added support for Blender 2.80 + ## [0.2.2] - 2018-09-26 ### Added -- Option to clear all images with no users, set this as start choice which is more save - Extra safety to clean image using a bool - Show texture name above dimensions for easier reading path and chosen texture @@ -23,4 +26,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +[0.2.2_2.80]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.2_2.80 [0.2.2]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.2 diff --git a/README.md b/README.md index f89af8d..4511bce 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,14 @@ I added a cleaner look to the panel and added the panel settings to option bool. I also added source image so users can pick image sequence or sinle image. I Also added is showing the image texture name above its size, this is very convienent because the source path only shows a very small section. This makes it much easier to identify the used texture. -!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list.jpg?v26-09-2018) +!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list-update_bl280.png?v11-01-2019) ## Extra Image List -Have you ever struggled with the tiny pop-up list in the UV/Image Editor? So have I! +This addon makes it possible to save rig setup to a preset folder. The function was already existing but would generate a text inside Blender. I simply added some new functions so these presets can directly be saved in the Blender preset folder of Metarigs. Presets can be added to a folder as well as new folders can be created. -Therefore, I made an addon that enables to pop-up an extra image list with specified number of rows and columns. Optionally, you can display all images in a plain list. - -Moreover, the addon contains a button to clear all users for the selected image datablock. So, the image datablock can disappear after save and reload of the blend file and you can easily get rid of unwanted image datablocks. +The added presets can then be loaded directly using the add menu. To get the new preset to show, you need to either restart blender or reload the all the addons pressing F8. Its also now possible save Rigify main settings as presets. These can be loaded at any time, no need for a refresh. >Addon documentation can be found at: [MeshLogic / Extra Image List](https://meshlogic.github.io/posts/blender/addons/extra-image-list/) @@ -49,3 +47,13 @@ Moreover, the addon contains a button to clear all users for the selected image ### Changelog [Full Changelog](CHANGELOG.md) + + + + + + diff --git a/__init__.py b/__init__.py index 14885cd..3e15255 100644 --- a/__init__.py +++ b/__init__.py @@ -9,14 +9,26 @@ # Revised: 30.05.2017 # Author: Miki (meshlogic) #------------------------------------------------------------------------------- + +####################################################### + +## Exra Image List ###### +## +## v0.2.3 +## 10-10-09 - Got 2.80 working + +####################################################### + + + bl_info = { "name": "Extra Image List", "author": "Miki (meshlogic) - Rombout Versluijs (updated panel)", "category": "UV", "description": "An alternative image list for UV/Image Editor.", "location": "UV/Image Editor > Tools > Image List", - "version": (0, 2, 2), - "blender": (2, 78, 0), + "version": (0, 2, 3), + "blender": (2, 80, 0), "wiki_url": "https://meshlogic.github.io/posts/blender/addons/extra-image-list/", "tracker_url": "https://github.com/schroef/Extra-Image-List", } @@ -24,16 +36,22 @@ import bpy import os from bpy.props import * -from bpy.types import Menu, Operator, Panel, UIList + +from bpy.types import ( + Panel, AddonPreferences, Menu, Operator, Scene, UIList, PropertyGroup + ) +from bpy.props import ( + EnumProperty, StringProperty, BoolProperty, IntProperty, PointerProperty + ) from bpy.app.handlers import persistent #------------------------------------------------------------------------------- # UI PANEL - Extra Image List #------------------------------------------------------------------------------- -class ExtraImageList_PT_ImagePreview(Panel): +class EIL_PT_ImageListPanel(Panel): bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'TOOLS' + bl_region_type = 'UI' bl_category = "Image List" bl_label = "Extra Image List" @@ -51,33 +69,33 @@ def draw(self, context): #----------------------------------------------------------------------- #--- List style buttons #--- Num. of rows & cols for image preview list - row = layout.row(True) + row = layout.row(align=True) row.prop(props,"options", icon="PREFERENCES") if props.options: layout = layout.box() split = layout.split() colm = split.column() - column = colm.column(True) - column.label("Preview Style:") + column = colm.column(align=True) + column.label(text="Preview Style:") if props.style =='PREVIEW': - column.label(" ") - column.label(" ") - column.label(" ") + column.label(text=" ") + column.label(text=" ") + column.label(text=" ") column.prop(props,"clean_enabled") colm = split.column() - column = colm.column(True) + column = colm.column(align=True) column.prop(props, "style", text="") if props.style =='PREVIEW': column.prop(props, "rows") column.prop(props, "cols") - column.label(" ") + column.label(text=" ") - columr = colm.column(True) + columr = colm.column(align=True) sub = columr sub.prop(props, "clear_mode", text="") - sub.operator("extra_image_list.clear", text="Clear", icon='RADIO') + sub.operator("extra_image_list.clear", text="Clear", icon='ERROR') sub.active = props.clean_enabled == True sub.enabled = props.clean_enabled == True @@ -118,8 +136,8 @@ def draw(self, context): row = layout.row() row.prop(img, "source") - #row.label("Image Source:", icon='DISK_DRIVE') - row = layout.row(True) + #row.label(text="Image Source:", icon='DISK_DRIVE') + row = layout.row(align=True) if img.source == 'FILE': if img.packed_file: @@ -130,32 +148,32 @@ def draw(self, context): row.prop(img, "filepath", text="") row.operator("image.reload", text="", icon='FILE_REFRESH') else: - row.label(img.source + " : " + img.type) + row.label(text=img.source + " : " + img.type) #--- Image size - col = layout.column(True) - row = layout.row(True) + col = layout.column(align=True) + row = layout.row(align=True) row.alignment = 'LEFT' if img.has_data: filename = os.path.basename(img.filepath) #--- Image name - col.label(filename, icon='FILE_IMAGE') + col.label(text=filename, icon='FILE_IMAGE') #--- Image size - row.label("Size:", icon='TEXTURE') - row.label("%d x %d x %db" % (img.size[0], img.size[1], img.depth)) + row.label(text="Size:", icon='TEXTURE') + row.label(text="%d x %d x %db" % (img.size[0], img.size[1], img.depth)) else: - row.label("Can't load image file!", icon='ERROR') + row.label(text="Can't load image file!", icon='ERROR') row = layout.row() - split = row.split(percentage=0.5) + split = row.split(factor=0.5) #--- Navigation button PREV sub = split.column() sub.scale_y = 2 - sub.operator("extra_image_list.nav", text="", icon='BACK').dir = 'PREV' + sub.operator("extra_image_list.nav", text="", icon='BACK').direction = 'PREV' # Disable button for the first image or for no images sub.enabled = (img!=img_list[0] if (img!=None and len(img_list)>0) else False) @@ -163,7 +181,7 @@ def draw(self, context): #--- Navigation button NEXT sub = split.column() sub.scale_y = 2 - sub.operator("extra_image_list.nav", text="", icon='FORWARD').dir = 'NEXT' + sub.operator("extra_image_list.nav", text="", icon='FORWARD').direction = 'NEXT' # Disable button for the last image or for no images sub.enabled = (img!=img_list[-1] if (img!=None and len(img_list)>0) else False) @@ -171,24 +189,33 @@ def draw(self, context): #------------------------------------------------------------------------------- # CUSTOM TEMPLATE_LIST FOR IMAGES #------------------------------------------------------------------------------- -class ExtraImageList_UL(UIList): +class EIL_UL_ImageList(UIList): bl_idname = "extra_image_list.image_list" def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): + ##NEW BL280 + # 'DEFAULT' and 'COMPACT' layout types should usually use the same draw code. + if self.layout_type in {'DEFAULT', 'COMPACT'}: + pass + # 'GRID' layout type should be as compact as possible (typically a single icon!). + elif self.layout_type in {'GRID'}: + pass # Image name and icon - row = layout.row(True) + row = layout.row(align=True) + if data == None: + row.prop(item, "name", text="", emboss=False, icon_value=custom_icons["image_empty"].icon_id) row.prop(item, "name", text="", emboss=False, icon_value=icon) # Image status (fake user, zero users, packed file) - row = row.row(True) + row = row.row(align=True) row.alignment = 'RIGHT' if item.use_fake_user: - row.label("F") + row.label(text="F") else: if item.users == 0: - row.label("0") + row.label(text="0") if item.packed_file: #row.label(icon='PACKAGE') @@ -210,17 +237,17 @@ def update_active_image(self, context): #------------------------------------------------------------------------------- # IMAGE NAVIGATION OPERATOR #------------------------------------------------------------------------------- -class ExtraImageList_PT_Nav(Operator): +class EIL_OT_Nav(Operator): bl_idname = "extra_image_list.nav" bl_label = "Nav" bl_description = "Navigation button" - dir = EnumProperty( + direction : EnumProperty( items = [ ('NEXT', "PREV", "PREV"), ('PREV', "PREV", "PREV") ], - name = "dir", + name = "direction", default = 'NEXT') def execute(self, context): @@ -236,11 +263,11 @@ def execute(self, context): return{'FINISHED'} # Navigate - if self.dir == 'NEXT': + if self.direction == 'NEXT': if id+1 < len(img_list): context.space_data.image = img_list[id+1] - if self.dir == 'PREV': + if self.direction == 'PREV': if id > 0: context.space_data.image = img_list[id-1] @@ -255,7 +282,7 @@ def execute(self, context): 'FULL', 'NORMALS', 'TEXTURE', 'DISPLACEMENT', 'DERIVATIVE', 'VERTEX_COLORS', 'EMIT', 'ALPHA', 'MIRROR_INTENSITY', 'MIRROR_COLOR', 'SPEC_INTENSITY', 'SPEC_COLOR') -class ExtraImageList_PT_Clear(Operator): +class EIL_OT_Clear(Operator): bl_idname = "extra_image_list.clear" bl_label = "Clear Users" bl_description = """Use with caution !!\nClear all users for selected image datablocks.\nSo the image datablock can disappear after save and reload of the blend file.""" @@ -334,7 +361,7 @@ def execute(self, context): #------------------------------------------------------------------------------- IMG_NODES = ("ShaderNodeTexImage", "ShaderNodeTexEnvironment") -class ShowNodeImage_PT(Operator): +class EIL_OT_ShowNodeImage(Operator): bl_idname = "node.show_image" bl_label = "Show node image in the UV/Image Editor" @@ -357,7 +384,7 @@ def execute(self, context): #------------------------------------------------------------------------------- -# CUSTOM HANDLER (scene_update_post) +# CUSTOM HANDLER (scene_update_post) #NEW name bl 2.80 depsgraph_update_post # - This handler is invoked after the scene updates # - Keeps template_list synced with the active image #------------------------------------------------------------------------------- @@ -385,9 +412,9 @@ def update_image_list(context): #------------------------------------------------------------------------------- # CUSTOM SCENE PROPS #------------------------------------------------------------------------------- -class ExtraImageList_Props(bpy.types.PropertyGroup): +class ExtraImageList_Props(PropertyGroup): - style = EnumProperty( + style : EnumProperty( items = [ ('PREVIEW', "Preview", "", 0), ('LIST', "List", "", 1), @@ -396,12 +423,12 @@ class ExtraImageList_Props(bpy.types.PropertyGroup): name = "Style", description = "Image list style") - clean_enabled = BoolProperty( + clean_enabled : BoolProperty( default=False, name="Clean:", description="Enables option to clear scene of image textures. Be careful!") - clear_mode = EnumProperty( + clear_mode : EnumProperty( items = [ ('NO USERS', "No Users", "Clears all images with no users", 0), ('SELECTED', "Selected Image", "Clear the image selected in the editor", 1), @@ -414,56 +441,93 @@ class ExtraImageList_Props(bpy.types.PropertyGroup): name = "Image Selection", description = "Select images to be cleared") - rows = IntProperty( + rows : IntProperty( name = "Rows", description = "Num. of rows in the preview list", default = 4, min = 1, max = 15) - cols = IntProperty( + cols : IntProperty( name = "Cols", description = "Num. of columns in the preview list", default = 8, min = 1, max = 30) # Index of the active image in the template_list - image_id = IntProperty( + image_id : IntProperty( + name = "Image ID", default = 0, update = update_active_image) - options = BoolProperty( + options : BoolProperty( name="Options", default=False) - settings = BoolProperty( + settings : BoolProperty( name="Settings", default=False) +def icon_Load(): + # importing icons + import bpy.utils.previews + global custom_icons + custom_icons = bpy.utils.previews.new() + + # path to the folder where the icon is + # the path is calculated relative to this py file inside the addon folder + icons_dir = os.path.join(os.path.dirname(__file__), "icons") + + # load a preview thumbnail of a file and store in the previews collection + custom_icons.load("empty", os.path.join(icons_dir, "empty_image_128x.png"), 'IMAGE') + +# global variable to store icons in +custom_icons = None #------------------------------------------------------------------------------- # REGISTER/UNREGISTER ADDON CLASSES #------------------------------------------------------------------------------- keymaps = [] +#Classes for register and unregister +classes = ( + EIL_PT_ImageListPanel, + EIL_UL_ImageList, + EIL_OT_ShowNodeImage, + ##NW bl280 PropertyGroup Needs to be added now? + ExtraImageList_Props, + EIL_OT_Clear, + EIL_OT_Nav, + ) + def register(): - bpy.utils.register_module(__name__) + for cls in classes: + bpy.utils.register_class(cls) + bpy.types.Scene.extra_image_list = PointerProperty(type=ExtraImageList_Props) - bpy.app.handlers.scene_update_post.append(update_image_list) + #bpy.app.handlers.depsgraph_update_post.append(update_image_list) + # Add custom shortcut (image node double click) kc = bpy.context.window_manager.keyconfigs.addon km = kc.keymaps.new(name="Node Editor", space_type='NODE_EDITOR') - kmi = km.keymap_items.new("node.show_image", 'ACTIONMOUSE', 'DOUBLE_CLICK') + kmi = km.keymap_items.new("node.show_image", 'RIGHTMOUSE', 'DOUBLE_CLICK') keymaps.append((km, kmi)) + icon_Load() def unregister(): - bpy.utils.unregister_module(__name__) + global custom_icons + bpy.utils.previews.remove(custom_icons) + del bpy.types.Scene.extra_image_list - bpy.app.handlers.scene_update_post.remove(update_image_list) + #bpy.app.handlers.depsgraph_update_post.remove(update_image_list) # Remove custom shortcuts for km, kmi in keymaps: km.keymap_items.remove(kmi) keymaps.clear() + for cls in reversed(classes): + bpy.utils.unregister_class(cls) + + if __name__ == "__main__": register() diff --git a/icons/image_empty_128x.png b/icons/image_empty_128x.png new file mode 100644 index 0000000000000000000000000000000000000000..47c435e038354e1acb14c6b7d207f5c2a3a56ee1 GIT binary patch literal 2684 zcmbVMX;f2L621XtF^JkKE-Z#1(D4s1OvU1 z!ohQ7EJ!HwN|r-`$-Z1ca*Ti$fp&35IVIBJ0AfhVM;nH{|0}V6%oPt=!;d~7&QG6*BTrylDUxp)K@i?(qpVudA zg)#v84~=hHE4WEA2p0e;r15eAd>@f^Q_gVh{u)Sc2(zKDmy6&_;m5M2f_O0`QF^l( zX!r{@LKH!Fq!7rFG(Hg%L4{}-vIBvL2`7-K7(SUMz*8Ir6e2{Nit{ahl7}OUMDuXP zv#AsU!JX#nN+z?2BsUg~?CMS=v8H^zB?={9B7ml_MKJakU)o>#(phqduawHUQfcf| z7x)RKN~uC9m7!QH)N&4AAd=|MEA)5tIb}8^7j1(gJmgX_>Qj;FqHhrR-;)3AAMyVd z4+oRN={x1WI%i4+x1)ahbq?Ue*GYmT@c78#IXP0;U;}{BNpH3*H?g@lf3wgkXyMKE zzj0Y&|9PbuKXQGT+^P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28@@cijwXyk(q+&ny9|YXM*VyV*X+n3NFY@ z;P%j2$TtFRkDN_42X2&@lLxOj&)5VHjxEBifXJ+=bbQX@f zA_D<@$?+$m;TYKbMb#G^hU!Aqc@y=WiN}YnwD+?+-(^qsM_YE^H&AsebjkAr9@qB- z=5`>(F9Y&>hgR^;`029j8b}9E*a!D3p4Pl zYq$rFx~_@5Kd=MpavV-hARD$rRf4X6E)9+>+;gGE2H4z7`~EW7Jbm@#S>Ba2&#eOv zL1XF-44^xUEl&2cpA~(+NW3`%x2%O7Uv{W<-Q$fF4jbc-$yXvyfB#AyJf`vtHcCRPD>dAs|v%iVZ8{siNEMWp}$ literal 0 HcmV?d00001 From 88ab1d659bff349237f6454f105c26e6d53f84c8 Mon Sep 17 00:00:00 2001 From: Rombout Versluijs Date: Fri, 11 Jan 2019 23:46:52 -0400 Subject: [PATCH 2/4] - Corrected wiki url preview image readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4511bce..6516a1d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ I added a cleaner look to the panel and added the panel settings to option bool. I also added source image so users can pick image sequence or sinle image. I Also added is showing the image texture name above its size, this is very convienent because the source path only shows a very small section. This makes it much easier to identify the used texture. -!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list-update_bl280.png?v11-01-2019) +!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list-update_bl280.jpg?v11-01-2019) ## Extra Image List From b14ffbba8404134c0d06133db78a4a8cad6eb808 Mon Sep 17 00:00:00 2001 From: Rombout Versluijs Date: Sat, 12 Jan 2019 00:06:05 -0400 Subject: [PATCH 3/4] - Adjusted readme.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6516a1d..ed90bf8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Extra Image List update +# Extra Image List update [bl 2.80] >Original addon from MeshLogic @@ -27,8 +27,8 @@ The added presets can then be loaded directly using the add menu. To get the new | **OS** | **Blender** | | ------------- | ------------- | -| OSX | Blender 2.78+ | -| Windows | Blender 2.78+ | +| OSX | Blender 2.80 | +| Windows | Blender 2.80 | | Linux | Not Tested | From 2c143363ecaacc6029c0d6b48e28603c390c558b Mon Sep 17 00:00:00 2001 From: Rombout Versluijs Date: Sat, 12 Jan 2019 16:00:25 -0400 Subject: [PATCH 4/4] - Cleaned readme.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ac1dd4..e54e672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ All notable changes to this project will be documented in this file. ## Notes The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - [0.2.2_2.80]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.2_2.80 [0.2.2]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.2