from imgui_bundle import imgui, immapp
import glfw
import OpenGL.GL as gl
from datatypes import *
from view import View

class GUI(object):
    def __init__(self):
        super().__init__() 
    
        #        self.io = imgui.get_io()

        # Global GUI Setting
        '''win_w, win_h = glfw.get_window_size(self.window)
        fb_w, fb_h = glfw.get_framebuffer_size(self.window)
        font_scaling_factor = max(float(fb_w) / win_w, float(fb_h) / win_h) 
        font_size_in_pixels = 30
        self.io.fonts.add_font_from_file_ttf("assets/MPLUSRounded1c-Regular.ttf", font_size_in_pixels * font_scaling_factor)
        self.io.font_global_scale /= font_scaling_factor'''

        self.view = View()
    
    def header(self):
        imgui.set_next_window_size(io.display_size.x, io.display_size.y*0.03)
        imgui.set_next_window_position(0, io.display_size.y*0.02)

        with imgui.begin("HEADER", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_TITLE_BAR):
            imgui.set_window_font_scale(1.3)
            text = "Student Analyzer"
            ww = imgui.get_window_size().x
            tw = imgui.calc_text_size(text).x
            imgui.set_cursor_pos_x((ww - tw) * 0.5)
            imgui.text("Student Analyzer")
 
    def __call__(self):
            self.view()



if __name__ == "__main__":
    immapp.run(
        gui_function=GUI(),
        window_title="Student Analyzer",
        window_size_auto=True,
        with_implot=True,
        with_markdown=True
    )
