actually using the work that I did with fonts
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 8 Feb 2022 04:48:20 +0000 (22:48 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 8 Feb 2022 04:48:20 +0000 (22:48 -0600)
src/entity/editor.onyx
src/gfx/ui.onyx

index 9d91d281d64a5096c4869ce0709243273cd648e0..e59bab665d4525dbf8d976b43f5c717fd0a33f78 100644 (file)
@@ -138,11 +138,11 @@ editor_draw :: () {
         h -= 4;
         w = 100;
 
+        theme := Button_Theme.{};
         for^ type_info.enum_values(Tabs) {
             // Don't draw the "None" item;
             if it.value == 0 do continue;
 
-            theme := Button_Theme.{};
             theme.active = active_tab == ~~it.value;
             if draw_button(.{x, y, w, h}, it.name, ^theme, increment=~~it.value) {
                 clicked_tab = ~~it.value;
@@ -185,8 +185,7 @@ editor_draw :: () {
         info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(type);
 
         y += 40.0f;
-        theme := Button_Theme.{};
-        theme.active = active_index == i;
+        theme := Button_Theme.{active = active_index == i};
         if draw_button(.{x, y - 18, w, 36.0f}, info.name, ^theme, increment=i) {
             active_index = i;
         }
@@ -200,8 +199,7 @@ editor_draw :: () {
         test << #char "t";
     }
 
-    theme := Textbox_Theme.{};
-    draw_textbox(.{x, y + 72.0f, w, 36.0f}, ^test, theme=^theme);
+    draw_textbox(.{x, y + 72.0f, w, 36.0f}, ^test);
 }
 
 #local render_entity_fields :: (entity: ^Entity, x, y, w, h: f32) {
index bab6555414a67ad1c5034773897176da60307dc9..0e987cecc4cb8edd4c9e1d7facd8b0cabfcc950a 100644 (file)
@@ -42,14 +42,9 @@ Button_Theme :: struct {
     active := false;
 }
 
-default_button_theme := Button_Theme.{};
+#local default_button_theme := Button_Theme.{};
 
-draw_button  :: (use r: Rect, text: str, theme: ^Button_Theme, site := #callsite, increment := 0) -> bool {
-    // HMMM.... this should be gotten rid of as quick as possible.
-    __ASDF := Button_Theme.{};
-    if theme == null {
-        theme = ^__ASDF; 
-    }
+draw_button  :: (use r: Rect, text: str, theme := ^default_button_theme, site := #callsite, increment := 0) -> bool {
     result := false;
 
     hash := get_site_hash(site, increment);
@@ -128,9 +123,9 @@ Textbox_Theme :: struct {
     placeholder_text_color := Color.{ 0.5, 0.5, 0.5 };
 }
 
-default_textbox_theme := Textbox_Theme.{};
-
 #local {
+    default_textbox_theme := Textbox_Theme.{};
+
     Textbox_Editing_State :: struct {
         hash: UI_Id = 0;
 
@@ -142,7 +137,7 @@ default_textbox_theme := Textbox_Theme.{};
     textbox_editing_state := Textbox_Editing_State.{};
 }
 
-draw_textbox :: (use r: Rect, text_buffer: ^[..] u8, placeholder := null_str, theme: ^Textbox_Theme = null, site := #callsite, increment := 0) -> bool {
+draw_textbox :: (use r: Rect, text_buffer: ^[..] u8, placeholder := null_str, theme := ^default_textbox_theme, site := #callsite, increment := 0) -> bool {
     result := false;
 
     hash := get_site_hash(site, increment);
@@ -224,6 +219,8 @@ draw_textbox :: (use r: Rect, text_buffer: ^[..] u8, placeholder := null_str, th
 
             textbox_editing_state.cursor_position = math.clamp(textbox_editing_state.cursor_position, 0, text_buffer.count);
             textbox_editing_state.cursor_animation = 1.0f;
+
+            text = str.{text_buffer.data, text_buffer.count};
         }
     }