Skip to content

Commit

Permalink
Polish UI
Browse files Browse the repository at this point in the history
  • Loading branch information
atticus-lv committed Nov 9, 2021
1 parent 44bd5c2 commit e0b20db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
44 changes: 23 additions & 21 deletions preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,19 @@ def filter_items(self, context, data, propname):
items = getattr(data, propname)
ordered = []

filtered = bpy.types.UI_UL_list.filter_items_by_name(getattr(filter, 'filter_' + filter.filter_type),
self.bitflag_filter_item,
items,
filter.filter_type.removeprefix('filter_'),
reverse=filter.reverse)

try:
ordered = bpy.types.UI_UL_list.sort_items_helper(items, filter.filter_type.removeprefix('filter_'))
except:
pass

return filtered, ordered

# OLD STYLE
#################################################
# filtered = [self.bitflag_filter_item] * len(items)
Expand All @@ -373,19 +386,6 @@ def filter_items(self, context, data, propname):
# ordered = bpy.types.UI_UL_list.sort_items_helper(items, lambda i: len(i.extension), True)
#################################################

filtered = bpy.types.UI_UL_list.filter_items_by_name(getattr(filter, 'filter_' + filter.filter_type),
self.bitflag_filter_item,
items,
filter.filter_type.removeprefix('filter_'),
reverse=filter.reverse)

try:
ordered = bpy.types.UI_UL_list.sort_items_helper(items, filter.filter_type.removeprefix('filter_'))
except:
pass

return filtered, ordered


class SPIO_MT_ConfigIOMenu(bpy.types.Menu):
bl_label = "Config Import/Export"
Expand All @@ -404,9 +404,8 @@ class SPIO_Preference(bpy.types.AddonPreferences):
ui: EnumProperty(name='UI', items=[
('SETTINGS', 'Settings', '', 'PREFERENCES', 0),
('CONFIG', 'Config', '', 'PRESET', 1),
('KEYMAP', 'Keymap', '', 'KEYINGSET', 2),
('URL', 'Manual', '', 'URL', 3),
])
('URL', 'Help', '', 'URL', 2),
],default = 'CONFIG')
use_N_panel: BoolProperty(name='Use N Panel', default=True)

# Settings
Expand All @@ -433,19 +432,18 @@ def draw(self, context):
col = layout.column()
if self.ui == 'SETTINGS':
self.draw_settings(context, col)

elif self.ui == 'CONFIG':
self.draw_config(context, col)
elif self.ui == 'KEYMAP':
self.draw_keymap(context, col)

elif self.ui == 'URL':
self.draw_url(context, col)

def draw_url(self, context, layout):
box = layout.box()
box.label(text='Help', icon='HELP')
row = box.row()
row.operator('wm.url_open', text='中文').url = 'http://atticus-lv.gitee.io/super_io/#/zh-cn/'
row.operator('wm.url_open', text='English').url = 'http://atticus-lv.gitee.io/super_io/#/en-us/'
row.operator('wm.url_open', text='Manual').url = 'http://atticus-lv.gitee.io/super_io/#/'

box = layout.box()
box.label(text='Supporter: 只剩一瓶辣椒酱', icon='FUND')
Expand Down Expand Up @@ -481,9 +479,13 @@ def draw_settings(self, context, layout):
row.prop(self, 'disable_warning_rules', text='')
row.label(text='Close Warning Rules')

col = layout.column(align=True).box()
col.use_property_split = True
self.draw_keymap(context, col)

def draw_keymap(self, context, layout):
col = layout.box().column()
# col.label(text="Keymap", icon="KEYINGSET")
col.label(text="Keymap", icon="KEYINGSET")
km = None
wm = context.window_manager
kc = wm.keyconfigs.user
Expand Down
6 changes: 3 additions & 3 deletions ui/ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ def poll(cls, context):


class SPIO_PT_PrefPanel(SidebarSetup, bpy.types.Panel):
bl_label = 'Settings'
bl_label = ''
bl_options = {'HEADER_LAYOUT_EXPAND'}

def draw_header(self, context):
layout = self.layout
layout.alignment = "CENTER"
layout.alignment = "LEFT"
pref = get_pref()

row = layout
row = row.row(align=True)
row.prop(pref, 'ui', expand=True, text='', emboss=False)
row.prop(pref, 'ui', expand=True, emboss=False)

def draw(self, context):
layout = self.layout
Expand Down

0 comments on commit e0b20db

Please sign in to comment.