2024-02-10 00:40:53 -08:00
|
|
|
package sectr
|
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
import "base:runtime"
|
2024-02-13 14:16:39 -08:00
|
|
|
import "core:math"
|
2024-03-08 00:34:21 -08:00
|
|
|
import "core:math/linalg"
|
2024-03-10 17:09:04 -07:00
|
|
|
import "core:os"
|
2024-03-14 21:02:28 -07:00
|
|
|
import str "core:strings"
|
2024-02-10 00:40:53 -08:00
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
|
|
|
|
|
|
|
DebugActions :: struct {
|
|
|
|
load_project : b32,
|
|
|
|
save_project : b32,
|
|
|
|
pause_renderer : b32,
|
|
|
|
|
|
|
|
load_auto_snapshot : b32,
|
|
|
|
record_replay : b32,
|
|
|
|
play_replay : b32,
|
|
|
|
|
|
|
|
show_mouse_pos : b32,
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
mouse_select : b32,
|
|
|
|
|
2024-02-10 00:40:53 -08:00
|
|
|
cam_move_up : b32,
|
|
|
|
cam_move_left : b32,
|
|
|
|
cam_move_down : b32,
|
|
|
|
cam_move_right : b32,
|
2024-02-11 20:00:06 -08:00
|
|
|
cam_mouse_pan : b32,
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
poll_debug_actions :: proc( actions : ^ DebugActions, input : ^ InputState )
|
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
2024-02-10 00:40:53 -08:00
|
|
|
using actions
|
|
|
|
using input
|
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
modifier_active := keyboard.right_alt.ended_down ||
|
|
|
|
keyboard.right_control.ended_down ||
|
|
|
|
keyboard.right_shift.ended_down ||
|
|
|
|
keyboard.left_alt.ended_down ||
|
|
|
|
keyboard.left_control.ended_down ||
|
|
|
|
keyboard.left_shift.ended_down
|
|
|
|
|
2024-02-10 00:40:53 -08:00
|
|
|
load_project = keyboard.left_control.ended_down && pressed( keyboard.O )
|
|
|
|
save_project = keyboard.left_control.ended_down && pressed( keyboard.S )
|
|
|
|
|
|
|
|
base_replay_bind := keyboard.right_alt.ended_down && pressed( keyboard.L)
|
|
|
|
record_replay = base_replay_bind && keyboard.right_shift.ended_down
|
|
|
|
play_replay = base_replay_bind && ! keyboard.right_shift.ended_down
|
|
|
|
|
|
|
|
show_mouse_pos = keyboard.right_alt.ended_down && pressed(keyboard.M)
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
mouse_select = pressed(mouse.left)
|
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
cam_move_up = keyboard.W.ended_down && ( ! modifier_active || keyboard.left_shift.ended_down )
|
|
|
|
cam_move_left = keyboard.A.ended_down && ( ! modifier_active || keyboard.left_shift.ended_down )
|
|
|
|
cam_move_down = keyboard.S.ended_down && ( ! modifier_active || keyboard.left_shift.ended_down )
|
|
|
|
cam_move_right = keyboard.D.ended_down && ( ! modifier_active || keyboard.left_shift.ended_down )
|
|
|
|
|
|
|
|
cam_mouse_pan = mouse.right.ended_down && ! pressed(mouse.right)
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
|
|
|
|
2024-03-08 00:34:21 -08:00
|
|
|
frametime_delta32 :: #force_inline proc "contextless" () -> f32 {
|
|
|
|
return cast(f32) get_state().frametime_delta_seconds
|
|
|
|
}
|
|
|
|
|
2024-02-10 00:40:53 -08:00
|
|
|
update :: proc( delta_time : f64 ) -> b32
|
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
profile(#procedure)
|
2024-02-10 00:40:53 -08:00
|
|
|
state := get_state(); using state
|
2024-02-27 04:50:57 -08:00
|
|
|
replay := & Memory_App.replay
|
2024-03-08 00:34:21 -08:00
|
|
|
workspace := & project.workspace
|
|
|
|
cam := & workspace.cam
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
if rl.IsWindowResized() {
|
|
|
|
window := & state.app_window
|
|
|
|
window.extent.x = f32(rl.GetScreenWidth()) * 0.5
|
|
|
|
window.extent.y = f32(rl.GetScreenHeight()) * 0.5
|
|
|
|
|
|
|
|
project.workspace.cam.offset = transmute(Vec2) window.extent
|
|
|
|
}
|
|
|
|
|
2024-02-10 00:40:53 -08:00
|
|
|
state.input, state.input_prev = swap( state.input, state.input_prev )
|
|
|
|
poll_input( state.input_prev, state.input )
|
|
|
|
|
|
|
|
debug_actions : DebugActions = {}
|
|
|
|
poll_debug_actions( & debug_actions, state.input )
|
|
|
|
|
|
|
|
// Saving & Loading
|
|
|
|
{
|
|
|
|
if debug_actions.save_project {
|
|
|
|
project_save( & project )
|
|
|
|
}
|
|
|
|
if debug_actions.load_project {
|
2024-02-27 04:50:57 -08:00
|
|
|
project_load( str_tmp_from_any( project.path, project.name, ".sectr_proj", sep = "" ), & project )
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-22 18:19:29 -08:00
|
|
|
//region Input Replay
|
2024-03-07 12:57:05 -08:00
|
|
|
// TODO(Ed) : Implment host memory mapping api
|
|
|
|
when false
|
2024-02-10 00:40:53 -08:00
|
|
|
{
|
|
|
|
if debug_actions.record_replay { #partial switch replay.mode
|
|
|
|
{
|
|
|
|
case ReplayMode.Off : {
|
2024-03-07 12:57:05 -08:00
|
|
|
save_snapshot( & Memory_App.snapshot )
|
2024-02-10 00:40:53 -08:00
|
|
|
replay_recording_begin( Path_Input_Replay )
|
|
|
|
}
|
|
|
|
case ReplayMode.Record : {
|
|
|
|
replay_recording_end()
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
|
|
|
|
if debug_actions.play_replay { switch replay.mode
|
|
|
|
{
|
|
|
|
case ReplayMode.Off : {
|
|
|
|
if ! file_exists( Path_Input_Replay ) {
|
2024-03-07 12:57:05 -08:00
|
|
|
save_snapshot( & Memory_App.snapshot )
|
2024-02-10 00:40:53 -08:00
|
|
|
replay_recording_begin( Path_Input_Replay )
|
|
|
|
}
|
|
|
|
else {
|
2024-03-07 12:57:05 -08:00
|
|
|
load_snapshot( & Memory_App.snapshot )
|
2024-02-10 00:40:53 -08:00
|
|
|
replay_playback_begin( Path_Input_Replay )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case ReplayMode.Playback : {
|
|
|
|
replay_playback_end()
|
2024-03-07 12:57:05 -08:00
|
|
|
load_snapshot( & Memory_App.snapshot )
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
|
|
|
case ReplayMode.Record : {
|
|
|
|
replay_recording_end()
|
2024-03-07 12:57:05 -08:00
|
|
|
load_snapshot( & Memory_App.snapshot )
|
2024-02-10 00:40:53 -08:00
|
|
|
replay_playback_begin( Path_Input_Replay )
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
|
|
|
|
if replay.mode == ReplayMode.Record {
|
|
|
|
record_input( replay.active_file, input )
|
|
|
|
}
|
|
|
|
else if replay.mode == ReplayMode.Playback {
|
|
|
|
play_input( replay.active_file, input )
|
|
|
|
}
|
|
|
|
}
|
2024-02-22 18:19:29 -08:00
|
|
|
//endregion Input Replay
|
2024-02-10 00:40:53 -08:00
|
|
|
|
|
|
|
if debug_actions.show_mouse_pos {
|
|
|
|
debug.mouse_vis = !debug.mouse_vis
|
|
|
|
}
|
|
|
|
|
2024-03-18 08:44:58 -07:00
|
|
|
//region 2D Camera Manual Nav
|
2024-05-09 01:02:33 -07:00
|
|
|
// TODO(Ed): This should be per workspace view
|
2024-02-10 00:40:53 -08:00
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile("Camera Manual Nav")
|
2024-02-11 20:00:06 -08:00
|
|
|
digital_move_speed : f32 = 200.0
|
2024-02-13 15:50:22 -08:00
|
|
|
|
2024-03-08 00:34:21 -08:00
|
|
|
if workspace.zoom_target == 0.0 {
|
|
|
|
workspace.zoom_target = cam.zoom
|
2024-02-13 15:50:22 -08:00
|
|
|
}
|
|
|
|
|
2024-03-08 00:34:21 -08:00
|
|
|
switch config.cam_zoom_mode
|
|
|
|
{
|
|
|
|
case .Smooth:
|
|
|
|
zoom_delta := input.mouse.vertical_wheel * config.cam_zoom_sensitivity_smooth
|
|
|
|
workspace.zoom_target *= 1 + zoom_delta * f32(delta_time)
|
2024-03-19 05:36:58 -07:00
|
|
|
workspace.zoom_target = clamp(workspace.zoom_target, config.cam_min_zoom, config.cam_max_zoom)
|
2024-03-08 00:34:21 -08:00
|
|
|
|
|
|
|
// Linearly interpolate cam.zoom towards zoom_target
|
|
|
|
lerp_factor := config.cam_zoom_smooth_snappiness // Adjust this value to control the interpolation speed
|
|
|
|
cam.zoom += (workspace.zoom_target - cam.zoom) * lerp_factor * f32(delta_time)
|
2024-03-19 05:36:58 -07:00
|
|
|
cam.zoom = clamp(cam.zoom, config.cam_min_zoom, config.cam_max_zoom) // Ensure cam.zoom stays within bounds
|
2024-03-08 00:34:21 -08:00
|
|
|
case .Digital:
|
|
|
|
zoom_delta := input.mouse.vertical_wheel * config.cam_zoom_sensitivity_digital
|
2024-03-19 05:36:58 -07:00
|
|
|
workspace.zoom_target = clamp(workspace.zoom_target + zoom_delta, config.cam_min_zoom, config.cam_max_zoom)
|
2024-03-08 00:34:21 -08:00
|
|
|
cam.zoom = workspace.zoom_target
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
|
|
|
|
move_velocity : Vec2 = {
|
|
|
|
- cast(f32) i32(debug_actions.cam_move_left) + cast(f32) i32(debug_actions.cam_move_right),
|
|
|
|
- cast(f32) i32(debug_actions.cam_move_up) + cast(f32) i32(debug_actions.cam_move_down),
|
|
|
|
}
|
2024-02-11 20:00:06 -08:00
|
|
|
move_velocity *= digital_move_speed * f32(delta_time)
|
2024-02-10 00:40:53 -08:00
|
|
|
cam.target += move_velocity
|
2024-02-11 20:00:06 -08:00
|
|
|
|
|
|
|
if debug_actions.cam_mouse_pan
|
|
|
|
{
|
|
|
|
if is_within_screenspace(input.mouse.pos) {
|
2024-05-09 01:02:33 -07:00
|
|
|
pan_velocity := input.mouse.delta * vec2(1, -1) * ( 1 / cam.zoom )
|
2024-02-11 20:00:06 -08:00
|
|
|
cam.target -= pan_velocity
|
|
|
|
}
|
|
|
|
}
|
2024-02-10 00:40:53 -08:00
|
|
|
}
|
2024-03-18 08:44:58 -07:00
|
|
|
//endregion 2D Camera Manual Nav
|
2024-02-10 00:40:53 -08:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
// TODO(Ed): We need input buffer so that we can consume input actions based on the UI with priority
|
|
|
|
|
|
|
|
//region App UI Tick
|
2024-02-27 04:50:57 -08:00
|
|
|
{
|
2024-05-09 01:02:33 -07:00
|
|
|
profile("App Screenspace Imgui")
|
2024-03-10 23:05:18 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
ui_graph_build( & state.app_ui )
|
2024-03-08 16:51:46 -08:00
|
|
|
ui := ui_context
|
2024-02-22 20:15:29 -08:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
/*
|
|
|
|
Prototype app menu
|
|
|
|
This is a menu bar for the app for now inside the same ui as the workspace's UI state
|
|
|
|
Eventually this will get moved out to its own UI state for the app itself.
|
|
|
|
*/
|
|
|
|
if true
|
2024-03-12 17:55:29 -07:00
|
|
|
{
|
2024-05-10 01:16:04 -07:00
|
|
|
profile("App Menu Bar")
|
2024-05-07 23:26:39 -07:00
|
|
|
fmt :: str_fmt_alloc
|
2024-03-12 17:55:29 -07:00
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
@static bar_pos := Vec2{0, 100}
|
2024-05-07 23:26:39 -07:00
|
|
|
bar_size := vec2( 400, 40 )
|
|
|
|
|
|
|
|
menu_bar : UI_Widget
|
2024-03-12 17:55:29 -07:00
|
|
|
{
|
2024-05-07 23:26:39 -07:00
|
|
|
theme := UI_Style {
|
|
|
|
flags = {
|
|
|
|
},
|
2024-05-09 23:08:36 -07:00
|
|
|
bg_color = { 0, 0, 0, 30 },
|
2024-05-07 23:26:39 -07:00
|
|
|
border_color = { 0, 0, 0, 200 },
|
|
|
|
|
|
|
|
font = default_font,
|
|
|
|
text_color = Color_White,
|
|
|
|
|
|
|
|
layout = UI_Layout {
|
|
|
|
anchor = {},
|
2024-05-09 01:02:33 -07:00
|
|
|
border_width = 1.0,
|
2024-05-09 23:08:36 -07:00
|
|
|
font_size = 12,
|
2024-05-09 01:02:33 -07:00
|
|
|
pos = bar_pos,
|
|
|
|
size = range2( bar_size, {}),
|
2024-05-07 23:26:39 -07:00
|
|
|
// padding = { 10, 10, 10, 10 },
|
|
|
|
},
|
2024-03-12 17:55:29 -07:00
|
|
|
}
|
2024-05-09 23:08:36 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
ui_theme_via_style(theme)
|
2024-05-10 01:16:04 -07:00
|
|
|
menu_bar = ui_widget("App Menu Bar", { .Mouse_Clickable} )
|
2024-05-09 23:08:36 -07:00
|
|
|
menu_bar.text = to_str_runes_pair( fmt("%v", bar_pos))
|
2024-05-09 01:02:33 -07:00
|
|
|
|
|
|
|
if (menu_bar.first_frame) {
|
2024-05-09 23:08:36 -07:00
|
|
|
// bar_pos = screen_get_corners().top_right - vec2(0, app_window.extent.y * 0.5)
|
2024-05-09 01:02:33 -07:00
|
|
|
}
|
2024-05-07 23:26:39 -07:00
|
|
|
}
|
|
|
|
// Setup Children
|
|
|
|
settings_btn : UI_Widget
|
|
|
|
{
|
|
|
|
ui_parent(menu_bar)
|
|
|
|
|
|
|
|
style := UI_Style {
|
|
|
|
flags = {
|
|
|
|
// .Origin_At_Anchor_Center
|
|
|
|
.Fixed_Height
|
|
|
|
},
|
|
|
|
bg_color = Color_Frame_Disabled,
|
|
|
|
|
|
|
|
font = default_font,
|
|
|
|
text_color = Color_White,
|
|
|
|
|
|
|
|
layout = UI_Layout {
|
|
|
|
anchor = range2( {0, 0}, {0.0, 0} ),
|
|
|
|
alignment = { 0.0, 1.0 },
|
2024-05-09 23:08:36 -07:00
|
|
|
font_size = 18,
|
2024-05-07 23:26:39 -07:00
|
|
|
text_alignment = { 0.5, 0.5 },
|
|
|
|
pos = { 0, 0 },
|
2024-05-09 01:02:33 -07:00
|
|
|
size = range2( {25, bar_size.y}, {0, 0})
|
2024-05-07 23:26:39 -07:00
|
|
|
}
|
2024-03-12 17:55:29 -07:00
|
|
|
}
|
2024-05-09 23:08:36 -07:00
|
|
|
theme := to_ui_styletheme(style)
|
2024-05-07 23:26:39 -07:00
|
|
|
theme.disabled.bg_color = Color_Frame_Disabled
|
2024-05-09 23:08:36 -07:00
|
|
|
theme.hot.bg_color = Color_Red
|
2024-05-07 23:26:39 -07:00
|
|
|
theme.active.bg_color = Color_Frame_Select
|
|
|
|
ui_style_theme(theme)
|
|
|
|
|
|
|
|
move_box : UI_Widget
|
2024-03-13 21:00:22 -07:00
|
|
|
{
|
2024-05-07 23:26:39 -07:00
|
|
|
move_box = ui_button("Move Box")
|
2024-05-09 23:08:36 -07:00
|
|
|
if move_box.active {
|
2024-05-09 01:02:33 -07:00
|
|
|
bar_pos += input.mouse.delta
|
2024-05-07 23:26:39 -07:00
|
|
|
}
|
2024-05-10 01:16:04 -07:00
|
|
|
using move_box
|
|
|
|
hot := ui_box_from_key(ui.curr_cache, ui.hot)
|
|
|
|
if hot != nil {
|
|
|
|
text = to_str_runes_pair(str_fmt_tmp("Hot box: %v %v", hot.label.str, hot.hot_delta))
|
|
|
|
style.font = default_font
|
|
|
|
style.font_size = 12
|
|
|
|
style.text_color = Color_White
|
|
|
|
style.text_alignment = {0, 1}
|
|
|
|
}
|
2024-03-13 21:00:22 -07:00
|
|
|
}
|
2024-03-12 17:55:29 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
move_settings_spacer := ui_widget("Move-Settings Spacer", {})
|
|
|
|
{
|
2024-05-09 23:08:36 -07:00
|
|
|
using move_settings_spacer
|
|
|
|
text = str_intern("spacer")
|
|
|
|
style.bg_color = Color_Transparent
|
|
|
|
style.layout.font_size = 10
|
|
|
|
}
|
|
|
|
|
|
|
|
settings_btn = ui_button("Settings Btn")
|
|
|
|
settings_btn.text = str_intern("Settings")
|
|
|
|
settings_btn.style.flags = {
|
|
|
|
.Scale_Width_By_Height_Ratio,
|
2024-05-07 23:26:39 -07:00
|
|
|
}
|
2024-03-10 17:09:04 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
// HBox layout calculation?
|
|
|
|
{
|
|
|
|
hb_space_ratio_move_box := 0.1
|
|
|
|
hb_space_ratio_move_settings_spacer := 0.05
|
|
|
|
hb_space_ratio_settings_btn := 1.0
|
2024-03-10 07:31:21 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
style := & move_box.box.style
|
|
|
|
style.anchor.max.x = 0.9
|
2024-03-10 07:31:21 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
style = & move_settings_spacer.box.style
|
|
|
|
style.anchor.min.x = 0.1
|
|
|
|
style.anchor.max.x = 0.8
|
2024-03-10 07:31:21 -07:00
|
|
|
|
2024-05-07 23:26:39 -07:00
|
|
|
style = & settings_btn.box.style
|
|
|
|
style.anchor.min.x = 0.2
|
|
|
|
style.anchor.max.x = 0.55
|
|
|
|
}
|
|
|
|
}
|
2024-03-10 07:31:21 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
@static settings_open := true
|
2024-05-09 23:08:36 -07:00
|
|
|
if settings_btn.pressed || settings_open
|
2024-03-10 07:31:21 -07:00
|
|
|
{
|
2024-05-10 01:16:04 -07:00
|
|
|
profile("Settings Menu")
|
2024-05-07 23:26:39 -07:00
|
|
|
settings_open = true
|
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
resize_border_width : f32 = 20
|
|
|
|
@static pos := Vec2 {0, 0}
|
|
|
|
@static size := Vec2 { 200, 200 }
|
|
|
|
if size.x < 200 {
|
|
|
|
size.x = 200
|
2024-05-09 01:02:33 -07:00
|
|
|
}
|
2024-05-09 23:08:36 -07:00
|
|
|
if size.y < 200 {
|
|
|
|
size.y = 200
|
2024-05-09 01:02:33 -07:00
|
|
|
}
|
2024-05-09 23:08:36 -07:00
|
|
|
settings_menu := ui_widget("Settings Menu", {.Mouse_Clickable})
|
2024-05-09 01:02:33 -07:00
|
|
|
{
|
|
|
|
using settings_menu
|
2024-05-09 23:08:36 -07:00
|
|
|
style.flags = {
|
|
|
|
// .Origin_At_Anchor_Center
|
|
|
|
}
|
|
|
|
style.pos = pos
|
|
|
|
style.alignment = { 1.0, 0.5 }
|
|
|
|
style.bg_color = Color_BG_Panel_Translucent
|
|
|
|
style.size = range2( size, {})
|
2024-05-10 01:16:04 -07:00
|
|
|
text = to_str_runes_pair(str_fmt_tmp("Hot Delta: %v", hot_delta))
|
|
|
|
style.font = default_font
|
|
|
|
style.font_size = 12
|
|
|
|
style.text_color = Color_White
|
2024-03-14 21:02:28 -07:00
|
|
|
}
|
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
ui_parent(settings_menu)
|
2024-05-09 01:02:33 -07:00
|
|
|
ui_theme_via_style({
|
2024-05-09 23:08:36 -07:00
|
|
|
bg_color = Color_Transparent,
|
|
|
|
font = default_font,
|
2024-05-09 01:02:33 -07:00
|
|
|
text_color = Color_White,
|
2024-05-09 23:08:36 -07:00
|
|
|
size = range2({0, 40}, {0, 40}), // TODO(Ed): Implment ratio scaling for height
|
|
|
|
layout = { font_size = 16 },
|
2024-05-09 01:02:33 -07:00
|
|
|
})
|
2024-05-09 23:08:36 -07:00
|
|
|
ui_style_theme_ref().hot.bg_color = Color_Blue
|
2024-05-09 01:02:33 -07:00
|
|
|
frame_bar := ui_widget("Settings Menu: Frame Bar", { .Mouse_Clickable, .Focusable, .Click_To_Focus })
|
2024-03-10 07:31:21 -07:00
|
|
|
{
|
2024-05-07 23:26:39 -07:00
|
|
|
using frame_bar
|
2024-05-09 23:08:36 -07:00
|
|
|
style.bg_color = Color_BG_Panel
|
|
|
|
style.flags = {}
|
2024-05-07 23:26:39 -07:00
|
|
|
style.alignment = { 0, 1 }
|
2024-05-09 23:08:36 -07:00
|
|
|
}
|
|
|
|
ui_parent(frame_bar)
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
if frame_bar.active {
|
|
|
|
pos += input.mouse.delta
|
|
|
|
}
|
2024-05-07 23:26:39 -07:00
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
title := ui_text("Settings Menu: Title", str_intern("Settings Menu"), {.Disabled})
|
|
|
|
{
|
|
|
|
using title
|
|
|
|
style.alignment = {0, 1}
|
|
|
|
style.margins = { 0, 0, 15, 0}
|
|
|
|
style.text_alignment = {0 , 0.5}
|
|
|
|
}
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
ui_style_theme(ui_style_theme_peek())
|
|
|
|
ui_style_theme_ref().default.bg_color = Color_GreyRed
|
|
|
|
ui_style_theme_ref().hot. bg_color = Color_Red
|
|
|
|
close_btn := ui_button("Settings Menu: Close Btn")
|
|
|
|
{
|
|
|
|
using close_btn
|
|
|
|
text = str_intern("close")
|
|
|
|
// style.bg_color = Color_GreyRed
|
|
|
|
style.size.min = {50, 0}
|
|
|
|
style.anchor = range2( {1.0, 0}, {})
|
|
|
|
style.alignment = {1, 1}
|
|
|
|
style.text_alignment = {0.5, 0.5}
|
|
|
|
if close_btn.pressed {
|
|
|
|
settings_open = false
|
2024-03-14 21:02:28 -07:00
|
|
|
}
|
2024-03-10 07:31:21 -07:00
|
|
|
}
|
2024-05-09 23:08:36 -07:00
|
|
|
|
|
|
|
ui_resizable_handles( & settings_menu, & pos, & size )
|
2024-05-07 23:26:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-05-09 01:02:33 -07:00
|
|
|
//endregion App UI Tick
|
2024-03-10 17:09:04 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
//region WorkspaceImgui Tick
|
2024-05-07 23:26:39 -07:00
|
|
|
{
|
2024-05-09 01:02:33 -07:00
|
|
|
profile("Workspace Imgui")
|
2024-03-14 21:02:28 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
// Creates the root box node, set its as the first parent.
|
|
|
|
ui_graph_build( & state.project.workspace.ui )
|
2024-05-07 23:26:39 -07:00
|
|
|
ui := ui_context
|
2024-03-10 07:31:21 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
frame_style_flags : UI_StyleFlags = {
|
|
|
|
.Fixed_Position_X, .Fixed_Position_Y,
|
|
|
|
.Fixed_Width, .Fixed_Height,
|
|
|
|
}
|
|
|
|
default_layout := UI_Layout {
|
|
|
|
anchor = {},
|
|
|
|
alignment = { 0., 0.0 },
|
2024-05-09 23:08:36 -07:00
|
|
|
font_size = 30,
|
2024-05-09 01:02:33 -07:00
|
|
|
text_alignment = { 0.0, 0.0 },
|
|
|
|
// corner_radii = { 0.2, 0.2, 0.2, 0.2 },
|
|
|
|
pos = { 0, 0 },
|
|
|
|
size = range2( { 1000, 1000 }, {}),
|
|
|
|
// padding = { 20, 20, 20, 20 }
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_style_default := UI_Style {
|
2024-05-09 23:08:36 -07:00
|
|
|
flags = frame_style_flags,
|
|
|
|
bg_color = Color_BG_TextBox,
|
2024-05-09 01:02:33 -07:00
|
|
|
font = default_font,
|
|
|
|
text_color = Color_White,
|
|
|
|
|
|
|
|
layout = default_layout,
|
|
|
|
}
|
|
|
|
|
2024-05-09 23:08:36 -07:00
|
|
|
frame_theme := to_ui_styletheme(frame_style_default)
|
2024-05-09 01:02:33 -07:00
|
|
|
frame_theme.disabled.bg_color = Color_Frame_Disabled
|
2024-05-09 23:08:36 -07:00
|
|
|
frame_theme.hot. bg_color = Color_Frame_Hover
|
|
|
|
frame_theme.active. bg_color = Color_Frame_Select
|
2024-05-09 01:02:33 -07:00
|
|
|
ui_style_theme( frame_theme )
|
|
|
|
|
|
|
|
config.ui_resize_border_width = 2.5
|
|
|
|
// test_draggable()
|
|
|
|
// test_text_box()
|
|
|
|
// test_parenting( & default_layout, & frame_style_default )
|
|
|
|
// test_whitespace_ast( & default_layout, & frame_style_default )
|
2024-02-11 21:35:22 -08:00
|
|
|
}
|
2024-05-09 01:02:33 -07:00
|
|
|
//endregion Workspace Imgui Tick
|
2024-02-11 21:35:22 -08:00
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
debug.last_mouse_pos = input.mouse.pos
|
|
|
|
|
2024-02-10 00:40:53 -08:00
|
|
|
should_shutdown : b32 = ! cast(b32) rl.WindowShouldClose()
|
|
|
|
return should_shutdown
|
|
|
|
}
|