From 62b3fb758ca6845e08a341cb74ae28274da11a9f Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Wed, 7 Jul 2021 15:05:07 -0500 Subject: [PATCH] testing scissoring --- res/{colors.json => colors_dark.json} | 0 res/colors_light.json | 19 +++++++++++++++++++ src/main.onyx | 13 +++++++++---- src/mouse_handler.onyx | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) rename res/{colors.json => colors_dark.json} (100%) create mode 100644 res/colors_light.json create mode 100644 src/mouse_handler.onyx diff --git a/res/colors.json b/res/colors_dark.json similarity index 100% rename from res/colors.json rename to res/colors_dark.json diff --git a/res/colors_light.json b/res/colors_light.json new file mode 100644 index 0000000..e02a70b --- /dev/null +++ b/res/colors_light.json @@ -0,0 +1,19 @@ +{ + "dark_background": [ 0.8, 0.8, 0.8 ], + "background": [ 0.9, 0.9, 0.9 ], + "foreground": [ 0, 0, 0, ], + + "keyword": [ 0.7, 0.7, 1.0 ], + "value": [ 0.8, 1.0, 0.8 ], + "jumppoint": [ 1, 0.5, 0.5 ], + + "primary": [ 0.051, 0.278, 0.631 ], + "primary_light": [ 0.329, 0.451, 0.827 ], + "primary_dark": [ 0, 0.129, 0.443 ], + "primary_text": [ 0, 0, 0 ], + + "secondary": [ 0, 0.376, 0.392 ], + "secondary_light": [ 0.259, 0.557, 0.573 ], + "secondary_dark": [ 0, 0.212, 0.227 ], + "secondary_text": [ 0, 0, 0 ] +} diff --git a/src/main.onyx b/src/main.onyx index cc2494d..68202a1 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -9,6 +9,8 @@ use package core keys : Key_Handler; +search_buffer: string.String_Buffer; + background_tile_texture : gfx.Texture; main :: (args: [] cstr) { @@ -48,7 +50,7 @@ init :: () { @DynamicLoading // Currently, this file is just baked into the binary. When a mechanism // is added to easily ask JS to make a fetch request for a file, that can be used here. - colors_json := #file_contents "res/colors.json"; + colors_json := #file_contents "res/colors_dark.json"; arena := alloc.arena.make(context.allocator, 4096); defer alloc.arena.free(^arena); @@ -164,7 +166,7 @@ poll_events :: () -> bool { } update :: (dt: f32) { - speed :: 200.0f; + speed :: 400.0f; scale_speed :: 0.02f; transform := gfx.global_renderer->get_transform(); @@ -201,6 +203,8 @@ draw :: () { window_rectangle := ui.Rectangle.{ 0, 0, ~~window_width, ~~window_height }; + gfx.push_scissor(ui.mouse_state.x, ui.mouse_state.y, 400, 400); + draw_background_lines(~~window_width, ~~window_height, line_color=config.Colors.background); random.set_seed(32185); @@ -209,9 +213,12 @@ draw :: () { y := cast(f32) random.between(0, 4000); w := cast(f32) random.between(100, 400); h := cast(f32) random.between(100, 400); + gfx.rect(.{ x+2, y+2 }, .{ w, h }, color=config.Colors.primary_dark); gfx.rect(.{ x, y }, .{ w, h }, color=config.Colors.primary); } + gfx.pop_scissor(); + gfx.push_matrix(); gfx.identity(); draw_menu_bar(window_rectangle); @@ -221,8 +228,6 @@ draw :: () { ui.clear_buttons(); } -search_buffer: string.String_Buffer; - #private_file draw_menu_bar :: (window_rectangle: ui.Rectangle) { menu_bar, _ := ui.Flow.split_horizontal(window_rectangle, top_height=32); diff --git a/src/mouse_handler.onyx b/src/mouse_handler.onyx new file mode 100644 index 0000000..81b1af4 --- /dev/null +++ b/src/mouse_handler.onyx @@ -0,0 +1,2 @@ + +// #private_file events :: package js_events -- 2.25.1