Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created July 21, 2025 15:22
Show Gist options
  • Select an option

  • Save naranyala/5879ce28cd1b57256e8c89f2dd131270 to your computer and use it in GitHub Desktop.

Select an option

Save naranyala/5879ce28cd1b57256e8c89f2dd131270 to your computer and use it in GitHub Desktop.
for the community, a dashboard layout made with odin programming
package main
import "core:fmt"
import "core:strings"
import rl "vendor:raylib"
// Configuration constants
SCREEN_WIDTH :: 1280
SCREEN_HEIGHT :: 720
TOGGLE_KEY :: rl.KeyboardKey.F1
Panel :: struct {
rect: rl.Rectangle,
color: rl.Color,
is_visible: bool,
name: string,
min_width: f32,
min_height: f32,
}
main :: proc() {
rl.InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Odin IDE Dashboard")
defer rl.CloseWindow()
rl.SetTargetFPS(60)
// Initialize panels with minimum dimensions
panels := [4]Panel {
{ // Left panel (Explorer)
rect = {0, 0, 200, SCREEN_HEIGHT},
color = rl.Color{40, 42, 54, 255},
is_visible = true,
name = "Explorer",
min_width = 150,
min_height = SCREEN_HEIGHT,
},
{ // Right panel (Properties)
rect = {SCREEN_WIDTH - 300, 0, 300, SCREEN_HEIGHT},
color = rl.Color{68, 71, 90, 255},
is_visible = true,
name = "Properties",
min_width = 200,
min_height = SCREEN_HEIGHT,
},
{ // Top panel (Toolbar)
rect = {200, 0, SCREEN_WIDTH - 500, 150},
color = rl.Color{98, 114, 164, 255},
is_visible = true,
name = "Toolbar",
min_width = SCREEN_WIDTH - 500,
min_height = 40,
},
{ // Bottom panel (Terminal)
rect = {200, SCREEN_HEIGHT - 200, SCREEN_WIDTH - 500, 200},
color = rl.Color{68, 71, 90, 255},
is_visible = true,
name = "Terminal",
min_width = SCREEN_WIDTH - 500,
min_height = 100,
},
}
show_all_panels := true
for !rl.WindowShouldClose() {
// Toggle all panels visibility
if rl.IsKeyPressed(TOGGLE_KEY) {
show_all_panels = !show_all_panels
for &panel in panels {
panel.is_visible = show_all_panels
}
}
// Individual panel toggle with F-keys
if rl.IsKeyPressed(.F2) {panels[0].is_visible = !panels[0].is_visible}
if rl.IsKeyPressed(.F3) {panels[1].is_visible = !panels[1].is_visible}
if rl.IsKeyPressed(.F4) {panels[2].is_visible = !panels[2].is_visible}
if rl.IsKeyPressed(.F5) {panels[3].is_visible = !panels[3].is_visible}
// Calculate dynamic layout
left_width := panels[0].is_visible ? panels[0].rect.width : 0
right_width := panels[1].is_visible ? panels[1].rect.width : 0
top_height := panels[2].is_visible ? panels[2].rect.height : 0
bottom_height := panels[3].is_visible ? panels[3].rect.height : 0
// Update panel positions and sizes
if panels[0].is_visible {
panels[0].rect = {0, 0, panels[0].rect.width, SCREEN_HEIGHT}
}
if panels[1].is_visible {
panels[1].rect = {SCREEN_WIDTH - right_width, 0, right_width, SCREEN_HEIGHT}
}
if panels[2].is_visible {
panels[2].rect = {left_width, 0, SCREEN_WIDTH - left_width - right_width, top_height}
}
if panels[3].is_visible {
panels[3].rect = {
left_width,
SCREEN_HEIGHT - bottom_height,
SCREEN_WIDTH - left_width - right_width,
bottom_height,
}
}
// Calculate main content area
main_area := rl.Rectangle {
left_width,
top_height,
SCREEN_WIDTH - left_width - right_width,
SCREEN_HEIGHT - top_height - bottom_height,
}
// Begin drawing
rl.BeginDrawing()
defer rl.EndDrawing()
rl.ClearBackground(rl.Color{30, 31, 38, 255})
// Draw visible panels
for panel, i in panels {
if panel.is_visible {
rl.DrawRectangleRec(panel.rect, panel.color)
fkey := i32(2 + i)
title := fmt.tprintf("%s (F%d)", panel.name, fkey)
rl.DrawText(
strings.clone_to_cstring(title),
i32(panel.rect.x + 10),
i32(panel.rect.y + 10),
20,
rl.WHITE,
)
}
}
// Draw main content area
rl.DrawRectangleRec(main_area, rl.Color{40, 42, 54, 255})
rl.DrawText(
"Main Content Area",
i32(main_area.x + 20),
i32(main_area.y + 20),
24,
rl.WHITE,
)
// Draw help text
help_text := fmt.tprintf("Press F1 to toggle all panels (Current: %v)", show_all_panels)
rl.DrawText(strings.clone_to_cstring(help_text), 10, SCREEN_HEIGHT - 30, 20, rl.RAYWHITE)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment