New icon tabbed interface so you don't need to click twice to change tab.

This commit is contained in:
Dion Moult
2023-07-15 13:22:13 +10:00
parent 0a840188bf
commit 90fce18042
3 changed files with 56 additions and 1 deletions
+15
View File
@@ -40,6 +40,21 @@ from mathutils import Vector, Matrix, Euler
from math import radians
class SetTab(bpy.types.Operator):
bl_idname = "bim.set_tab"
bl_label = "Set Tab"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Sets the current property tab"
tab: bpy.props.StringProperty()
def execute(self, context):
if context.area.spaces.active.search_filter:
return {"FINISHED"}
aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
aprops.tab = self.tab
return {"FINISHED"}
class SwitchTab(bpy.types.Operator):
bl_idname = "bim.switch_tab"
bl_label = "Switch Tab"
+2
View File
@@ -360,6 +360,8 @@ class BIMAreaProperties(PropertyGroup):
tab: EnumProperty(default=0, items=get_tab, name="Tab", update=update_tab)
previous_tab: StringProperty(default="PROJECT", name="Previous Tab")
alt_tab: StringProperty(default="OBJECT", name="Alt Tab")
active_tab: BoolProperty(default=True, name="Active Tab")
inactive_tab: BoolProperty(default=False, name="Inactive Tab")
class BIMProperties(PropertyGroup):
+39 -1
View File
@@ -281,9 +281,47 @@ class BIM_PT_root(Panel):
def draw(self, context):
try:
aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
row = self.layout.row()
row.scale_y = 0.5 # Yes, we actually do this.
row.operator(
"bim.set_tab", text="", emboss=False, icon_value=blenderbim.bim.icons["IFC"].icon_id
).tab = "PROJECT"
row.operator("bim.set_tab", text="", emboss=False, icon="FILE_3D").tab = "OBJECT"
row.operator("bim.set_tab", text="", emboss=False, icon="MATERIAL").tab = "MATERIALS"
row.operator("bim.set_tab", text="", emboss=False, icon="DOCUMENTS").tab = "DRAWINGS"
row.operator("bim.set_tab", text="", emboss=False, icon="NETWORK_DRIVE").tab = "SERVICES"
row.operator("bim.set_tab", text="", emboss=False, icon="EDITMODE_HLT").tab = "STRUCTURE"
row.operator("bim.set_tab", text="", emboss=False, icon="NLA").tab = "SCHEDULING"
row.operator("bim.set_tab", text="", emboss=False, icon="PACKAGE").tab = "FM"
row.operator("bim.set_tab", text="", emboss=False, icon="COLLAPSEMENU").tab = "OTHER"
row.operator("bim.set_tab", text="", emboss=False, icon="BLENDER").tab = "BLENDER"
row.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT")
# Yes, that's right, we're still doing this.
row = self.layout.row()
row.scale_y = 0.2
for tab in [
"PROJECT",
"OBJECT",
"MATERIALS",
"DRAWINGS",
"SERVICES",
"STRUCTURE",
"SCHEDULING",
"FM",
"OTHER",
"BLENDER",
"SWITCH",
]:
if aprops.tab == tab:
row.prop(aprops, "active_tab", text="", icon="BLANK1")
else:
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
row = self.layout.row(align=True)
row.prop(aprops, "tab", text="")
row.operator("bim.switch_tab", text="", icon="UV_SYNC_SELECT")
except:
pass # Prior to load_post, we may not have any area properties setup