Misc + made a more controlled digital zoom
Trying to get digital zoom to closer target levels that would match specific even font sizes Various other changes from iterating on VEFontCache
This commit is contained in:
@ -504,15 +504,16 @@ ui_top_ancestor :: #force_inline proc "contextless" ( box : ^UI_Box ) -> (^UI_Bo
|
||||
return ancestor
|
||||
}
|
||||
|
||||
ui_view_bounds :: #force_inline proc "contextless" () -> (range : Range2) {
|
||||
using state := get_state();
|
||||
// if ui_context == & screen_ui {
|
||||
// return screen_get_bounds()
|
||||
// }
|
||||
// else {
|
||||
|
||||
ui_view_bounds :: #force_inline proc "contextless" ( ui : ^UI_State = nil ) -> (range : Range2) {
|
||||
state := get_state(); using state
|
||||
ui := ui; if ui == nil do ui = ui_context
|
||||
|
||||
if ui == & screen_ui {
|
||||
return screen_get_bounds()
|
||||
}
|
||||
else {
|
||||
return view_get_bounds()
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
ui_context :: #force_inline proc "contextless" () -> ^UI_State { return get_state().ui_context }
|
||||
|
@ -118,36 +118,33 @@ ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return hm
|
||||
|
||||
// TODO(Ed): Rename to ui_box_tranverse_view_next
|
||||
// Traveral pritorizes immeidate children
|
||||
ui_box_tranverse_next_depth_first :: #force_inline proc "contextless" ( box : ^ UI_Box, bypass_intersection_test := false ) -> (^ UI_Box)
|
||||
{
|
||||
using state := get_state()
|
||||
// If current has children, do them first
|
||||
if box.first != nil
|
||||
{
|
||||
// Check to make sure parent is present on the screen, if its not don't bother.
|
||||
if bypass_intersection_test {
|
||||
return box.first
|
||||
}
|
||||
if intersects_range2( ui_view_bounds(), box.computed.bounds) {
|
||||
return box.first
|
||||
ui_box_tranverse_next_depth_first :: #force_inline proc "contextless" (box: ^UI_Box, bypass_intersection_test := false, ctx: ^UI_State = nil) -> ^UI_Box {
|
||||
state := get_state(); using state
|
||||
ctx := ctx if ctx != nil else ui_context
|
||||
|
||||
// If current has children, check if we should traverse them
|
||||
if box.first != nil {
|
||||
if bypass_intersection_test || intersects_range2(ui_view_bounds(ctx), box.computed.bounds) {
|
||||
return box.first
|
||||
}
|
||||
}
|
||||
|
||||
if box.next != nil do return box.next
|
||||
// There are no more adjacent nodes
|
||||
// If no children or children are culled, try next sibling
|
||||
if box.next != nil {
|
||||
return box.next
|
||||
}
|
||||
|
||||
// No more siblings, traverse up the tree
|
||||
parent := box.parent
|
||||
// Attempt to find a parent with a next, otherwise we just return a parent with nil
|
||||
for ; parent.parent != nil;
|
||||
{
|
||||
if parent.next != nil {
|
||||
break
|
||||
}
|
||||
parent = parent.parent
|
||||
for parent != nil {
|
||||
if parent.next != nil {
|
||||
return parent.next
|
||||
}
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
// Lift back up to parent, and set it to its next.
|
||||
return parent.next
|
||||
// We've reached the end of the tree
|
||||
return nil
|
||||
}
|
||||
|
||||
// Traveral pritorizes traversing a "anestry layer"
|
||||
|
@ -166,9 +166,11 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
// 8. Text position & size
|
||||
if len(box.text.str) > 0
|
||||
{
|
||||
ascent, descent, line_gap := get_font_vertical_metrics(style.font, layout.font_size)
|
||||
content_size := content_bounds.max - content_bounds.min
|
||||
text_pos : Vec2
|
||||
text_pos = content_bounds.min + { 0, text_size.y * 0.5 }
|
||||
text_pos = content_bounds.min
|
||||
text_pos += { 0, -descent }
|
||||
text_pos += (content_size - text_size) * layout.text_alignment
|
||||
|
||||
computed.text_size = text_size
|
||||
|
@ -163,17 +163,17 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
|
||||
text_layout.flags = {
|
||||
// .Origin_At_Anchor_Center,
|
||||
.Fixed_Position_X, .Fixed_Position_Y,
|
||||
.Fixed_Width, .Fixed_Height,
|
||||
.Fixed_Width, .Fixed_Height,
|
||||
}
|
||||
text_layout.text_alignment = { 0.0, 0.5 }
|
||||
text_layout.alignment = { 0.0, 0.0 }
|
||||
text_layout.size.min = { 1600, 20 }
|
||||
text_layout.alignment = { 0.0, 1.0 }
|
||||
text_layout.size.min = { 1600, 14 }
|
||||
text_style := frame_style_default ^
|
||||
text_style_combo := to_ui_style_combo(text_style)
|
||||
text_style_combo.default.bg_color = Color_Transparent
|
||||
text_style_combo.disabled.bg_color = Color_Frame_Disabled
|
||||
text_style_combo.hot.bg_color = Color_Frame_Hover
|
||||
text_style_combo.active.bg_color = Color_Frame_Select
|
||||
text_style_combo.disabled.bg_color = Color_Transparent
|
||||
text_style_combo.hot.bg_color = Color_Transparent
|
||||
text_style_combo.active.bg_color = Color_Transparent
|
||||
scope( text_layout, text_style )
|
||||
|
||||
alloc_error : AllocatorError; success : bool
|
||||
@ -204,14 +204,14 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
|
||||
ui_layout( text_layout )
|
||||
line_hbox := ui_widget(str_fmt( "line %v", line_id ), {.Mouse_Clickable})
|
||||
|
||||
if line_hbox.key == ui.hot
|
||||
if line_hbox.key == ui.hot && false
|
||||
{
|
||||
line_hbox.text = StrRunesPair {}
|
||||
ui_parent(line_hbox)
|
||||
|
||||
chunk_layout := text_layout
|
||||
chunk_layout.alignment = { 0.0, 0.5 }
|
||||
chunk_layout.anchor = range2({ 0.0, 0 }, { 0.0, 0 })
|
||||
chunk_layout.alignment = { 0.0, 0.0 }
|
||||
chunk_layout.anchor = range2({ 0.0, 0.0 }, { 0.0, 0.0 })
|
||||
chunk_layout.pos = {}
|
||||
chunk_layout.flags = { .Fixed_Position_X, .Size_To_Text }
|
||||
|
||||
@ -286,12 +286,12 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
|
||||
if len(line_hbox.text.str) > 0 {
|
||||
array_append( widgets_ptr, line_hbox )
|
||||
text_layout.pos.x = text_layout.pos.x
|
||||
text_layout.pos.y += size_range2(line_hbox.computed.bounds).y - 8
|
||||
text_layout.pos.y += size_range2(line_hbox.computed.bounds).y
|
||||
}
|
||||
else {
|
||||
widget := & widgets.data[ widgets.num - 1 ]
|
||||
if widget.box != nil {
|
||||
text_layout.pos.y += size_range2( widget.computed.bounds ).y - 8
|
||||
text_layout.pos.y += size_range2( widget.computed.bounds ).y
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user