diff --git a/CHANGELOG.md b/CHANGELOG.md index b600509..b367cf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - Distinguish between 'please subscribe' (to get a new subscription) and 'please renew' (to renew an existing subscription). - When re-opening the Texture Browser it now opens in the same folder as where it was when closed. +- In the texture browser, draw the components of the texture (i.e. which map types are available), + such as 'bump, normal, specular'. ## Version 1.7.5 (2017-10-06) diff --git a/blender_cloud/texture_browser.py b/blender_cloud/texture_browser.py index 46e6e95..de265e6 100644 --- a/blender_cloud/texture_browser.py +++ b/blender_cloud/texture_browser.py @@ -76,8 +76,9 @@ class MenuItem: icon_margin_y = 4 text_margin_x = 6 - text_height = 16 - text_width = 72 + text_size = 16 + text_size_small = 13 + text_dpi = 72 DEFAULT_ICONS = { 'FOLDER': os.path.join(library_icons_path, 'folder.png'), @@ -214,12 +215,31 @@ class MenuItem: # draw some text font_id = 0 - blf.position(font_id, - self.x + self.icon_margin_x + ICON_WIDTH + self.text_margin_x, - self.y + ICON_HEIGHT * 0.5 - 0.25 * self.text_height, 0) - blf.size(font_id, self.text_height, self.text_width) + text_x = self.x + self.icon_margin_x + ICON_WIDTH + self.text_margin_x + text_y = self.y + ICON_HEIGHT * 0.5 - 0.25 * self.text_size + blf.position(font_id, text_x, text_y, 0) + blf.size(font_id, self.text_size, self.text_dpi) blf.draw(font_id, self.label_text) + # Draw the components of the texture (i.e. which map types are available) + try: + node_files = self.node.properties.files + except AttributeError: + # Happens for nodes that don't have .properties.files. + node_files = None + if not node_files: + return + + map_types = {f['map_type'] for f in node_files} + map_types.discard('color') # all textures have colour + if not map_types: + return + + bgl.glColor4f(1.0, 1.0, 1.0, 0.5) + blf.size(font_id, self.text_size_small, self.text_dpi) + blf.position(font_id, text_x, self.y + 0.5 * self.text_size_small, 0) + blf.draw(font_id, ', '.join(sorted(map_types))) + def hits(self, mouse_x: int, mouse_y: int) -> bool: return self.x < mouse_x < self.x + self.width and self.y < mouse_y < self.y + self.height