comic/odin/src/shared/layout.odin
2026-05-22 03:51:50 +02:00

58 lines
1.1 KiB
Odin

package shared
Layout_Constants :: struct {
sidebar_width: i32,
right_margin: i32,
min_main_width: i32,
top_reserved_height: i32,
min_lower_y: i32,
compact_height: i32,
wide_width: i32,
}
LAYOUT :: Layout_Constants{
sidebar_width = 282,
right_margin = 20,
min_main_width = 960,
top_reserved_height = 252,
min_lower_y = 450,
compact_height = 860,
wide_width = 1920,
}
Screen_Profile :: enum {
Compact,
Standard,
Wide,
}
screen_profile :: proc(screen_w, screen_h: i32) -> Screen_Profile {
if screen_h < LAYOUT.compact_height {
return .Compact
}
if screen_w >= LAYOUT.wide_width {
return .Wide
}
return .Standard
}
compute_main_width :: proc(screen_w: i32) -> i32 {
w := screen_w - LAYOUT.sidebar_width - LAYOUT.right_margin
if w < LAYOUT.min_main_width {
return LAYOUT.min_main_width
}
return w
}
compute_lower_y :: proc(screen_h: i32) -> i32 {
y := screen_h - LAYOUT.top_reserved_height
if y < LAYOUT.min_lower_y {
return LAYOUT.min_lower_y
}
return y
}
is_compact :: proc(screen_h: i32) -> bool {
return screen_h < LAYOUT.compact_height
}