66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
from imgui_bundle import imgui, ImVec2
|
|
|
|
from datatypes import *
|
|
|
|
from main_menu import MainMenu
|
|
|
|
from database_editor import DatabaseEditor
|
|
|
|
from student_info import StudentInfo
|
|
|
|
def set_layout(size: tuple, pos: tuple) -> None:
|
|
io = imgui.get_io()
|
|
size = imgui.ImVec2(*size)
|
|
pos = imgui.ImVec2(*pos)
|
|
imgui.set_next_window_size(size)
|
|
imgui.set_next_window_pos(pos)
|
|
|
|
class GrapherLayout:
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
self.student_info = StudentInfo()
|
|
|
|
def set_layout(self):
|
|
pass
|
|
|
|
def __call__(self):
|
|
self.student_info()
|
|
|
|
class EditorLayout:
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.database_editor = DatabaseEditor()
|
|
|
|
def set_layout(self):
|
|
pass
|
|
|
|
def __call__(self):
|
|
self.database_editor()
|
|
|
|
class View:
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.current = LayoutOptions.GRAPHER
|
|
self.main_menu = MainMenu()
|
|
self.editor = EditorLayout()
|
|
self.grapher = GrapherLayout()
|
|
|
|
def switch_context(self, ctx: LayoutOptions) -> None:
|
|
match ctx:
|
|
case LayoutOptions.EDITOR:
|
|
self.editor.set_layout()
|
|
case LayoutOptions.GRAPHER:
|
|
self.grapher.set_layout()
|
|
|
|
def __call__(self):
|
|
option = self.main_menu()
|
|
if option:
|
|
self.current = option
|
|
|
|
if self.current == LayoutOptions.EDITOR:
|
|
self.editor()
|
|
|
|
if self.current == LayoutOptions.GRAPHER:
|
|
self.grapher()
|