mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Implement Ctrl-Tab in properties to conveniently toggle between two tabs.
This commit is contained in:
@@ -93,6 +93,7 @@ classes = [
|
||||
operator.ConfigureVisibility,
|
||||
operator.OpenUpstream,
|
||||
operator.OpenUri,
|
||||
operator.SwitchTab,
|
||||
operator.ReloadIfcFile,
|
||||
operator.RemoveIfcFile,
|
||||
operator.SelectDataDir,
|
||||
@@ -146,7 +147,7 @@ classes = [
|
||||
for mod in modules.values():
|
||||
classes.extend(mod.classes)
|
||||
|
||||
|
||||
addon_keymaps = []
|
||||
icons = None
|
||||
|
||||
|
||||
@@ -184,6 +185,12 @@ def register():
|
||||
for mod in modules.values():
|
||||
mod.register()
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
if wm.keyconfigs.addon:
|
||||
km = wm.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY')
|
||||
kmi = km.keymap_items.new('bim.switch_tab', 'TAB', 'PRESS', ctrl=True)
|
||||
addon_keymaps.append((km, kmi))
|
||||
|
||||
global icons
|
||||
|
||||
icons_dir = os.path.join(cwd, "data", "icons")
|
||||
@@ -237,3 +244,10 @@ def unregister():
|
||||
|
||||
for mod in reversed(list(modules.values())):
|
||||
mod.unregister()
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
kc = wm.keyconfigs.addon
|
||||
if kc:
|
||||
for km, kmi in addon_keymaps:
|
||||
km.keymap_items.remove(kmi)
|
||||
addon_keymaps.clear()
|
||||
|
||||
@@ -79,6 +79,7 @@ def register():
|
||||
def unregister():
|
||||
bpy.types.TOPBAR_MT_file.remove(ui.file_menu)
|
||||
del bpy.types.Scene.BIMProjectProperties
|
||||
|
||||
wm = bpy.context.window_manager
|
||||
kc = wm.keyconfigs.addon
|
||||
if kc:
|
||||
|
||||
@@ -40,6 +40,18 @@ from mathutils import Vector, Matrix, Euler
|
||||
from math import radians
|
||||
|
||||
|
||||
class SwitchTab(bpy.types.Operator):
|
||||
bl_idname = "bim.switch_tab"
|
||||
bl_label = "Switch Tab"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Switches to the last used tab"
|
||||
|
||||
def execute(self, context):
|
||||
aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
|
||||
aprops.tab = aprops.alt_tab
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class OpenUri(bpy.types.Operator):
|
||||
bl_idname = "bim.open_uri"
|
||||
bl_label = "Open URI"
|
||||
|
||||
@@ -53,6 +53,11 @@ cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
materialpsetnames_enum = []
|
||||
|
||||
|
||||
def update_tab(self, context):
|
||||
self.alt_tab = self.previous_tab
|
||||
self.previous_tab = self.tab
|
||||
|
||||
|
||||
def update_preset(self, context):
|
||||
from blenderbim.bim.data.ui.presets import presets
|
||||
|
||||
@@ -352,7 +357,9 @@ def get_tab(self, context):
|
||||
|
||||
|
||||
class BIMAreaProperties(PropertyGroup):
|
||||
tab: EnumProperty(default=0, items=get_tab, name="Tab")
|
||||
tab: EnumProperty(default=0, items=get_tab, name="Tab", update=update_tab)
|
||||
previous_tab: StringProperty(default="PROJECT", name="Previous Tab")
|
||||
alt_tab: StringProperty(default="PROJECT", name="Alt Tab")
|
||||
|
||||
|
||||
class BIMProperties(PropertyGroup):
|
||||
|
||||
@@ -279,7 +279,9 @@ class BIM_PT_root(Panel):
|
||||
|
||||
def draw(self, context):
|
||||
aprops = context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
|
||||
self.layout.prop(aprops, "tab", text="")
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(aprops, "tab", text="")
|
||||
row.operator("bim.switch_tab", text="", icon="UV_SYNC_SELECT")
|
||||
|
||||
|
||||
class BIM_PT_project_info(Panel):
|
||||
|
||||
Reference in New Issue
Block a user