content(style="course_edit") {
    layout = "center",
}



window(key="course_edit") > autofill {
    width = parent_width,
    height = parent_height,
    can_hover = true,

    on_mouse_move = "init#return true",
    on_mouse_move_over = "init#return true",
    on_mouse_move_out = "init#return true",
    on_mouse_up = "init#return true",
    on_mouse_down = "init#return true",

    background_color = rgba(0, 0, 0, 0.6),

    layout = "center",
}

autofill > info {
    layout = "center",
}
autofill > info > content {
    layout = "lined",
}

autofill > info > content > @text {
    font_size = 35,
    font_color = rgb(255, 255, 255),
    text_shadow = text_shadow(5.0, 5.0, "#000000", 5.0),
}

content(style="course_edit") > buttons {
    align_height = false,
    y = parent_height - 66,
    height  = 66,
    width = parent_width - 100,

    layout = "grid",
    columns = 2,
    spacing = 16,
    margin = 12,
}

content(style="course_edit") > buttons > button(id="save") {
    tint = rgb(20, 255, 120),
}

content(style="course_edit") > scroll_panel {
    align_height = false,
    align_width = false,
    x = 40,
    y = 40,
    height = parent_height - 100,
    width = parent_width - 50,
}

content(style="course_edit") > scroll_panel > content {
    layout = "rows",
}

content(style="course_edit") > header {
    align_height = false,
    align_width = false,
    layout = "center",
    height = 40,
    background_color = rgba(0, 0, 0, 0.1),
    y = 35,
    x = 35,
    width = parent_width - 35,
}
content(style="course_edit") > header > textbox {
    width = parent_width - 100,
    y = 0,
    on_init = "init#node:focus()",
}

content(style="course_edit") > info {
    align_height = false,
    align_width = false,
    x = 35,
    width = parent_width - 35,
    y = 85,
    height = 65,

    layout = "grid",
    rows = 2,
    columns = 2,
    spacing = 1,
}

content(style="course_edit") > info > info_text {
    layout = "lined",
    line_height = 30,
}

content(style="course_edit") > info > info_text > @text {
    font_size = 21,
}

content(style="course_edit") > info > info_text > textbox {
    width = 300,
    height = 30,
}

content(style="course_edit") > info > info_text > dropdown {
    width = 290,
    height = 30,
}

content(style="course_edit") > info > button(id="autofill") {
    tint = rgb(200, 255, 200),

    on_mouse_move_over = "ui.button#
        move_over(node, evt)
        local content = ui.builder(function()
            return content {
                'Attempts to automatically place lessons into the timetable.\\n\\n'
                .. 'This will repeat placed lessons enough times that meet the'
                .. ' requirements of the lesson type.\\n\\n'
                .. 'It will only use teachers that already teach that lesson type'
                .. ' on the course and will not select new teachers.\\n\\n'
                .. 'You can prevent periods from being autofilled by right clicking'
                .. ' them.'
            }
        end)
        ui.show_tooltip('course_autofill_key', content, evt.x, evt.y)
    ",
    on_mouse_move_out = "ui.button#
        move_out(node, evt)
        ui.hide_tooltip('course_autofill_key')
    ",
    on_mouse_move = "init#
        ui.move_tooltip('course_autofill_key', evt.x, evt.y)
        return true
    ",
}

content(style="course_edit") > course_timetable_overview {
    align_height = false,
    align_width = false,
    y = parent_height - 300,
    height = 240,
    width = parent_width - 40,
    x = 36,


    background_color = rgba(0, 0, 0, 0.1),

    layout = "grid",
    columns = 7,
    margin = 0,
    spacing = 2,
}

content(style="course_edit") > course_timetable_overview > course_day {
    background_color = rgba(0, 0, 0, 0.2),

    layout = "grid",
    rows = 5,
    spacing = 5,
    margin = 2,
}

content(style="course_edit") > course_timetable_overview > course_day > center > label {
    layout = "lined",
}
content(style="course_edit") > course_timetable_overview > course_day > center > label > @text {
    font_size = 18,
}
content(style="course_edit") > course_timetable_overview > course_day(weekend=true) > center > label > @text {
    font_color = rgb(50, 50, 0),
}

content(style="course_edit") > course_timetable_overview > course_day(weekend=true) {
    background_color = rgba(120, 0, 0, 0.2),
}

content(style="course_edit") > course_timetable_overview > course_day > course_period {
    background_color = rgba(120, 120, 120, 0.5),
    shadow = shadow(2.0, 2.0, rgba(0, 0, 0, 0.3), 3.0, 0.0, "outset"),

    can_hover = true,
    on_mouse_move_over = "ui.tooltip#
        ui.set_cursor('base:ui/cursor/interact')

        local tooltip = node:get_property_string('tooltip')

        local content = ui.new('content')
        add_text(content, tooltip)

        ui.show_tooltip('course_period_entry', content, evt.x, evt.y)
        return true
    ",
    on_mouse_move_out = "ui.tooltip#
        ui.set_cursor('base:ui/cursor/normal')
        ui.hide_tooltip('course_period_entry')
    ",
    on_mouse_move = "ui.tooltip#
        ui.move_tooltip('course_period_entry', evt.x, evt.y)
        return true
    ",
}

content(style="course_edit") > course_timetable_overview > course_day > course_period(hover=true) {
    background_color = rgba(120, 120, 120, 0.8),
    shadow = shadow(2.0, 2.0, rgba(0, 0, 0, 0.8), 3.0, 0.0, "outset"),
}

content(style="course_edit") > course_timetable_overview > course_day > course_period(blocked=true) {
    background_color = rgba(200, 0, 40, 1.0),
    shadow = shadow(2.0, 2.0, rgba(0, 0, 0, 0.9), 3.0, 0.0, "outset"),
}
content(style="course_edit") > course_timetable_overview > course_day > course_period(blocked=true, hover=true) {
    background_color = rgba(200, 0, 00, 1.0),
    shadow = shadow(2.0, 2.0, rgba(0, 50, 50, 0.9), 3.0, 0.0, "outset"),
}

content(style="course_edit") > course_timetable_overview > course_day > course_period(booked=true) {
    background_color = rgba(0, 200, 100, 1.0),
    shadow = shadow(2.0, 2.0, rgba(0, 20, 0, 0.3), 3.0, 0.0, "outset"),
}

content(style="course_edit") > course_timetable_overview > course_day > course_period(booked=true, hover=true) {
    background_color = rgba(0, 240, 60, 1.0),
    shadow = shadow(2.0, 2.0, rgba(0, 0, 0, 0.8), 3.0, 0.0, "outset"),
}

content(style="course_edit") > course_timetable_overview > course_day > course_period(on_click=click) {
    on_mouse_up = list(click, "init#
        audio.play_sound('click')
        return true
    "),
}