import imgui

from datatypes import *

class MainMenu:
    def __init__(self):
        super().__init__()

    def __call__(self):
        with imgui.begin_main_menu_bar() as main_menu_bar:
            if main_menu_bar:
                with imgui.begin_menu("File", True) as file_menu:
                    if file_menu.opened:
                        imgui.menu_item("New", " ", False, True)
                        imgui.menu_item("Open", " ", False, True)
                        imgui.menu_item("Save", " ", False, True)
                        imgui.menu_item("Save as", " ", False, True)
                with imgui.begin_menu("View", True) as view_menu:
                    if view_menu.opened:
                        with imgui.begin_menu("Change Layout", True) as open_layout_menu:
                            if open_layout_menu.opened:
                                layout_options = list(LayoutOptions)
                                for n, l in enumerate(layout_options):
                                    clicked, _ = imgui.menu_item(l.name.title(), None, False, True)
                                    if clicked:
                                        return l
