titles for the zoom mode setting menu btns aren't behaving correctly...
This commit is contained in:
		| @@ -25,6 +25,7 @@ UI_ScreenState :: struct | ||||
| 		min_zoom_inputbox       : UI_TextInputBox, | ||||
| 		max_zoom_inputbox       : UI_TextInputBox, | ||||
| 		cfg_drop_down           : UI_DropDown, | ||||
| 		zoom_mode_drop_down     : UI_DropDown, | ||||
| 		pos, size, min_size     : Vec2, | ||||
| 		is_open                 : b32, | ||||
| 		is_maximized            : b32, | ||||
| @@ -377,6 +378,68 @@ ui_screen_settings_menu :: proc( captures : rawptr = nil ) -> ( should_raise : b | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			Zoom_Mode: | ||||
| 			{ | ||||
| 				scope( theme_table_row(is_even = true)) | ||||
| 				hb := ui_hbox(.Left_To_Right, "settings_menu.cam_zoom_mode.hb"); { | ||||
| 					using hb | ||||
|  | ||||
| 					layout.size.min = {0, 35} | ||||
| 					layout.flags    = {.Fixed_Height} | ||||
| 					layout.padding  = to_ui_layout_side(4) | ||||
| 				} | ||||
|  | ||||
| 				scope(theme_text) | ||||
| 				title := ui_text("settings_menu.cam_zoom_mode.title", str_intern("Camera: Zoom Mode")); { | ||||
| 					using title | ||||
| 					layout.anchor.ratio.x = 1.0 | ||||
| 					layout.margins.left   = 10 | ||||
| 					layout.font_size      = 12 | ||||
| 				} | ||||
|  | ||||
| 				mode_selector := ui_drop_down( & zoom_mode_drop_down, "settings_menu.cam_zoom_mode.drop_down", str_intern_fmt("%v selected", config.cam_zoom_mode), | ||||
| 					vb_compute_layout = true, | ||||
| 					// vb_parent = app_config.vbox | ||||
| 				) | ||||
| 				mode_selector.btn.layout.anchor.ratio.x = 0.5 | ||||
| 				if mode_selector.is_open | ||||
| 				{ | ||||
| 					idx := 1 | ||||
| 					for entry in CameraZoomMode | ||||
| 					{ | ||||
| 						ui_parent(app_config.vbox) | ||||
| 						// scope( theme_table_row(is_even = idx % 2 == 0)) | ||||
| 						idx += 1 | ||||
|  | ||||
| 						scope( theme_button) | ||||
| 						btn := ui_button( str_intern_fmt("settings_menu.cam_zoom_mode.%v : option btn", entry).str ) | ||||
| 						btn.layout.size.min  = {0, 25} | ||||
| 						// btn.layout.alignment = {0, 0} | ||||
| 						// btn.layout.anchor    = {} | ||||
| 						btn.layout.flags     = {.Fixed_Height} | ||||
| 						btn.layout.padding  = to_ui_layout_side(4) | ||||
|  | ||||
| 						// ui_parent_push(btn) | ||||
| 						ui_parent(btn) | ||||
| 						push(theme_text) | ||||
| 						// title := ui_text( str_intern_fmt("settings_menu.cam_zoom_mode.%v : option btn title").str, str_intern_fmt("%v", entry) ) | ||||
| 						{ | ||||
| 							using title | ||||
| 							layout.anchor.ratio.x = 1.0 | ||||
| 							layout.margins.left   = 10 | ||||
| 							layout.font_size      = 12 | ||||
| 						} | ||||
| 						// ui_parent_pop() | ||||
|  | ||||
| 						if btn.pressed { | ||||
| 							mode_selector.should_close = true | ||||
| 							config.cam_zoom_mode = entry | ||||
| 							screen_ui.active = 0 | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	ui_vbox_end(vbox, compute_layout = false ) | ||||
|   | ||||
| @@ -243,7 +243,6 @@ update :: proc( delta_time : f64 ) -> b32 | ||||
| 			return clamp(binary_search_closest(levels, zoom), 0, len(levels) - 1) | ||||
| 		} | ||||
|  | ||||
| 		config.cam_zoom_mode = .Digital | ||||
| 		switch config.cam_zoom_mode | ||||
| 		{ | ||||
| 			case .Smooth: | ||||
|   | ||||
| @@ -28,10 +28,11 @@ ui_button :: proc( label : string, flags : UI_BoxFlags = {} ) -> (btn : UI_Widge | ||||
|  | ||||
| #region("Drop Down") | ||||
| UI_DropDown :: struct { | ||||
| 	btn     : UI_Widget, | ||||
| 	title   : UI_Widget, | ||||
| 	vbox    : UI_VBox, | ||||
| 	is_open : bool, | ||||
| 	btn          : UI_Widget, | ||||
| 	title        : UI_Widget, | ||||
| 	vbox         : UI_VBox, | ||||
| 	is_open      : b32, | ||||
| 	should_close : b32, | ||||
| } | ||||
|  | ||||
| @(deferred_out = ui_drop_down_end_auto) | ||||
| @@ -41,11 +42,12 @@ ui_drop_down :: proc( drop_down : ^UI_DropDown, label : string, title_text : Str | ||||
| 	vb_flags          := UI_BoxFlags{}, | ||||
| 	vb_compute_layout := true, | ||||
| 	btn_theme   : ^UI_Theme = nil, | ||||
| 	title_theme : ^UI_Theme = nil | ||||
| 	title_theme : ^UI_Theme = nil, | ||||
| 	vb_parent   : ^UI_Box   = nil, | ||||
| ) -> (deferred : ^UI_DropDown) | ||||
| { | ||||
| 	deferred = drop_down | ||||
| 	ui_drop_down_begin(drop_down, label, title_text, direction, btn_flags, vb_flags, btn_theme, title_theme) | ||||
| 	ui_drop_down_begin(drop_down, label, title_text, direction, btn_flags, vb_flags, btn_theme, title_theme, vb_parent, vb_compute_layout) | ||||
| 	if ! drop_down.is_open do return | ||||
| 	ui_parent_push(drop_down.vbox) | ||||
| 	return | ||||
| @@ -58,6 +60,7 @@ ui_drop_down_begin :: proc( drop_down : ^UI_DropDown, label : string, title_text | ||||
| 	vb_flags  := UI_BoxFlags{}, | ||||
| 	btn_theme   : ^UI_Theme = nil, | ||||
| 	title_theme : ^UI_Theme = nil, | ||||
| 	vb_parent   : ^UI_Box   = nil, | ||||
| 	vb_compute_layout := true ) | ||||
| { | ||||
| 	using drop_down | ||||
| @@ -76,14 +79,22 @@ ui_drop_down_begin :: proc( drop_down : ^UI_DropDown, label : string, title_text | ||||
| 		title = ui_text( str_intern_fmt("%s.btn.title", label).str, title_text) | ||||
| 	} | ||||
|  | ||||
| 	if btn.pressed { | ||||
| 		is_open = !is_open | ||||
| 	} | ||||
| 	is_open     |= b32(btn.pressed) | ||||
| 	is_open     &= ! should_close | ||||
| 	should_close = false | ||||
|  | ||||
| 	if is_open == false do return | ||||
|  | ||||
| 	scope(theme_transparent) | ||||
| 	if vb_parent != nil { | ||||
| 		ui_parent_push(vb_parent) | ||||
| 	} | ||||
| 	vbox = ui_vbox_begin( direction, str_intern_fmt("%v : vbox", label).str, compute_layout = vb_compute_layout ) | ||||
| 	vbox.layout.anchor.ratio.y = 1.0 | ||||
|  | ||||
| 	if vb_parent != nil { | ||||
| 		ui_parent_pop() | ||||
| 	} | ||||
| } | ||||
|  | ||||
| ui_drop_down_end :: proc( drop_down : ^UI_DropDown ) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user