Skip to content
ui.py 2.1 KiB
Newer Older
Dalai Felinto's avatar
Dalai Felinto committed
import bpy

Dalai Felinto's avatar
Dalai Felinto committed

Dalai Felinto's avatar
Dalai Felinto committed
# ############################################################
# User Interface
# ############################################################

class VirtualRealityPanel(bpy.types.Panel):
    bl_label = "Head Mounted Display"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = 'Virtual Reality'

    @staticmethod
    def draw(self, context):
        layout = self.layout
Dalai Felinto's avatar
Dalai Felinto committed
        wm = context.window_manager
        vr = wm.virtual_reality
Dalai Felinto's avatar
Dalai Felinto committed

        col = layout.column()
Dalai Felinto's avatar
Dalai Felinto committed
        if not vr.is_enabled:
Dalai Felinto's avatar
Dalai Felinto committed
            col.operator("view3d.virtual_reality_display", text="Virtual Reality").action='ENABLE'
        else:
Dalai Felinto's avatar
Dalai Felinto committed
            col.operator("view3d.virtual_reality_display", text="Virtual Reality", icon="X").action='DISABLE'
Dalai Felinto's avatar
Dalai Felinto committed

            box = col.box()
            col = box.column()
Dalai Felinto's avatar
Dalai Felinto committed
            if vr.is_slave_setup:
                col.operator("view3d.virtual_reality_display", text="Start", icon="CAMERA_STEREO").action='FULLSCREEN'
Dalai Felinto's avatar
Dalai Felinto committed
            else:
Dalai Felinto's avatar
Dalai Felinto committed
                if vr.is_paused:
                    col.operator("view3d.virtual_reality_display", text="Play", icon="PLAY").action='PLAY'
                else:
                    col.operator("view3d.virtual_reality_display", text="Pause", icon="PAUSE").action='PAUSE'
Dalai Felinto's avatar
Dalai Felinto committed
                    row = col.row()
                    row.prop(vr, "use_preview")
                    sub = row.column()
                    sub.active = vr.use_preview
                    sub.prop(vr, "preview_scale", text="Scale")
Dalai Felinto's avatar
Dalai Felinto committed
                    col.operator("view3d.virtual_reality_display", text="Re-Center").action='RECENTER'
Dalai Felinto's avatar
Dalai Felinto committed

Dalai Felinto's avatar
Dalai Felinto committed
                    col.label(text="Tracking:")
                    col.row().prop(vr, "tracking_mode", expand=True)
Dalai Felinto's avatar
Dalai Felinto committed

Dalai Felinto's avatar
Dalai Felinto committed
                    if vr.error_message:
                        col.separator()
                        col.label(text=vr.error_message)
Dalai Felinto's avatar
Dalai Felinto committed

# ############################################################
# Un/Registration
# ############################################################

def register():
    bpy.utils.register_class(VirtualRealityPanel)


def unregister():
    bpy.utils.unregister_class(VirtualRealityPanel)