diff options
author | Vilem Duha <vilem.duha@gmail.com> | 2021-05-17 20:12:43 +0300 |
---|---|---|
committer | Vilem Duha <vilem.duha@gmail.com> | 2021-05-17 20:12:43 +0300 |
commit | 1cbc6e28421fee3fb0aaa2cb7c3c9b257e8c6cb6 (patch) | |
tree | 490823e0b6326de71f44b77ce17e906cb22eace5 | |
parent | 4f961d71dc55b15e1ebe26c8302bcdd2800b60dd (diff) |
BlenderKit: minor UI fixes
-rw-r--r-- | blenderkit/ui_panels.py | 74 | ||||
-rw-r--r-- | blenderkit/upload.py | 8 | ||||
-rw-r--r-- | blenderkit/utils.py | 8 |
3 files changed, 57 insertions, 33 deletions
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index cb3b5a8b..c04068ce 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -1403,15 +1403,15 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): bl_idname = "wm.blenderkit_asset_popup" bl_label = "BlenderKit asset popup" - width = 700 + width = 800 @classmethod def poll(cls, context): return True def draw_menu(self, context, layout): - col = layout.column() - draw_asset_context_menu(col, context, self.asset_data, from_panel=False) + # layout = layout.column() + draw_asset_context_menu(layout, context, self.asset_data, from_panel=False) def draw_property(self, layout, left, right, icon=None, icon_value=None, url='', tooltip=''): right = str(right) @@ -1442,6 +1442,13 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): parameter = f"{parameter:,.1f}" self.draw_property(layout, pretext, parameter) + def draw_description(self, layout, width = 250): + if len(self.asset_data['description']) > 0: + box = layout.box() + box.scale_y = 0.8 + box.label(text='Description') + utils.label_multiline(box, self.asset_data['description'], width=width) + def draw_properties(self, layout, width=250): if type(self.asset_data['parameters']) == list: @@ -1449,13 +1456,6 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): else: mparams = self.asset_data['parameters'] - layout = layout.column() - if len(self.asset_data['description']) > 0: - box = layout.box() - box.scale_y = 0.8 - box.label(text='Description') - utils.label_multiline(box, self.asset_data['description'], width=width) - pcoll = icons.icon_collections["main"] box = layout.box() @@ -1644,7 +1644,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): utils.label_multiline(col, text=a['tooltip'], width=text_width) # check if author didn't fill any data about himself and prompt him if that's the case - if upload.user_is_owner(asset_data=self.asset_data) and a.get('aboutMe') is not None and len( + if utils.user_is_owner(asset_data=self.asset_data) and a.get('aboutMe') is not None and len( a.get('aboutMe', '')) == 0: row = col.row() row.enabled = False @@ -1673,14 +1673,13 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): op.keywords = '' op.author_id = self.asset_data['author']['id'] - def draw_thumbnail_box(self, layout): + def draw_thumbnail_box(self, layout, width = 250): layout.emboss = 'NORMAL' box_thumbnail = layout.box() box_thumbnail.scale_y = .4 - - box_thumbnail.template_icon(icon_value=self.img.preview.icon_id, scale=34.0) + box_thumbnail.template_icon(icon_value=self.img.preview.icon_id, scale=width*.12) # row = box_thumbnail.row() # row.scale_y = 3 @@ -1738,16 +1737,36 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): # left - tooltip & params row = box.row() split_factor = 0.7 - split_left_left = row.split(factor=split_factor) - self.draw_properties(split_left_left, width=int(width * split_factor)) + split_left = row.split(factor=split_factor) + col = split_left.column() + width_left = int(width * split_factor) + self.draw_description(col, width=width_left) + + self.draw_properties(col, width=width_left) # right - menu - col1 = split_left_left.split() - self.draw_menu(context, col1) + split_right = split_left.split() + col = split_right.column() + self.draw_menu(context, col) # author self.draw_author_area(context, box, width=width) + + # self.draw_author_area(context, box, width=width) + # + # col = box.column_flow(columns=2) + # self.draw_menu(context, col) + # + # + # # self.draw_description(box, width=int(width)) + # self.draw_properties(box, width=int(width)) + + + + + + def draw(self, context): ui_props = context.scene.blenderkitUI @@ -1765,17 +1784,22 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): # left side row = layout.row(align=True) - split_ratio = 0.5 - split_left = row.split(factor=0.5) - self.draw_thumbnail_box(split_left) - + split_ratio = 0.45 + split_left = row.split(factor=split_ratio) + left_column = split_left.column() + self.draw_thumbnail_box(left_column, width = int(self.width * split_ratio)) + # self.draw_description(left_column, width = int(self.width*split_ratio)) # right split split_right = split_left.split() - self.draw_menu_desc_author(context, split_right, width=int(self.width * split_ratio)) + self.draw_menu_desc_author(context, split_right, width=int(self.width * (1-split_ratio))) - ratings_box = layout.box() + if not utils.user_is_owner(asset_data=asset_data): + #Draw ratings, but not for owners of assets - doesn't make sense. + ratings_box = layout.box() + ratings.draw_ratings_menu(self, context, ratings_box) + # else: + # ratings_box.label('Here you should find ratings, but you can not rate your own assets ;)') - ratings.draw_ratings_menu(self, context, ratings_box) tip_box = layout.box() tip_box.label(text=self.tip) diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 9fd54187..b1d20f94 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -567,14 +567,6 @@ def update_free_full(self, context): " based on our fair share system. " \ "Part of subscription is sent to artists based on usage by paying users.") -def user_is_owner(asset_data=None): - '''Checks if the current logged in user is owner of the asset''' - profile = bpy.context.window_manager.get('bkit profile') - if profile is None: - return False - if int(asset_data['author']['id']) == int(profile['user']['id']): - return True - return False def can_edit_asset(active_index=-1, asset_data=None): if active_index < 0 and not asset_data: diff --git a/blenderkit/utils.py b/blenderkit/utils.py index d0f52cb2..bae1244d 100644 --- a/blenderkit/utils.py +++ b/blenderkit/utils.py @@ -784,6 +784,14 @@ def profile_is_validator(): return True return False +def user_is_owner(asset_data=None): + '''Checks if the current logged in user is owner of the asset''' + profile = bpy.context.window_manager.get('bkit profile') + if profile is None: + return False + if int(asset_data['author']['id']) == int(profile['user']['id']): + return True + return False def guard_from_crash(): ''' |