from imgui_bundle import hello_imgui, imgui
from typing import List

from .student_list import student_list
from .student_graph import student_graph
from .group_graph import group_graph
from .class_graph import class_graph


def analyzer_docking_splits() -> List[hello_imgui.DockingSplit]:
    split_main_misc = hello_imgui.DockingSplit()
    split_main_misc.initial_dock = "MainDockSpace"
    split_main_misc.new_dock = "MiscSpace"
    split_main_misc.direction = imgui.Dir.down
    split_main_misc.ratio = 0.25

    # Then, add a space to the left which occupies a column whose width is 25% of the app width
    split_main_command = hello_imgui.DockingSplit()
    split_main_command.initial_dock = "MainDockSpace"
    split_main_command.new_dock = "CommandSpace"
    split_main_command.direction = imgui.Dir.left
    split_main_command.ratio = 0.2

    # Then, add CommandSpace2 below MainDockSpace
    split_main_command2 = hello_imgui.DockingSplit()
    split_main_command2.initial_dock = "MainDockSpace"
    split_main_command2.new_dock = "CommandSpace2"
    split_main_command2.direction = imgui.Dir.down
    split_main_command2.ratio = 0.25

    splits = [split_main_misc, split_main_command, split_main_command2]
    return splits

def set_analyzer_layout() -> List[hello_imgui.DockableWindow]:
    student_selector = hello_imgui.DockableWindow()
    student_selector.label = "Class list"
    student_selector.dock_space_name = "CommandSpace"
    student_selector.gui_function = lambda: student_list()
    
    student_info = hello_imgui.DockableWindow()
    student_info.label = "Student Analyzer"
    student_info.dock_space_name = "MainDockSpace"
    student_info.gui_function = lambda: student_graph()

    group_info = hello_imgui.DockableWindow()
    group_info.label = "Group Analyzer"
    group_info.dock_space_name = "MainDockSpace"
    group_info.gui_function = lambda: group_graph()

    class_info = hello_imgui.DockableWindow()
    class_info.label = "Class Analyzer"
    class_info.dock_space_name = "MainDockSpace"
    class_info.gui_function = lambda: class_graph()

    #student_ranking = hello_imgui.DockableWindow()
    #student_ranking.label = "Ranking"
    #student_ranking.dock_space_name = "MainDockSpace"
    #student_ranking.gui_function = lambda: ranking()

    return [
        student_selector,
        student_info,
        group_info,
        class_info
    ]

def analyzer_layout() -> hello_imgui.DockingParams:
    docking_params = hello_imgui.DockingParams()
    docking_params.layout_name = "Analyzer"
    docking_params.docking_splits = analyzer_docking_splits() 
    docking_params.dockable_windows = set_analyzer_layout()
    return docking_params

