From f1f6df829f1bfc98875663794f55a2577e14e094 Mon Sep 17 00:00:00 2001 From: Justin Scofield <47263509+scawful@users.noreply.github.com> Date: Sun, 5 Jan 2025 06:17:09 -0500 Subject: [PATCH] controller and canvas houskeeping --- src/app/core/controller.h | 4 ++-- src/app/gui/canvas.h | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 9d7f3f0b..99654d15 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -53,13 +53,13 @@ class Controller : public ExperimentFlags { auto window() -> SDL_Window * { return window_.get(); } void init_test_editor(editor::Editor *editor) { test_editor_ = editor; } void set_active(bool active) { active_ = active; } - auto active() { return active_; } + auto active() const { return active_; } private: friend int ::main(int argc, char **argv); bool active_ = false; - Platform platform_; + Platform platform_ = Platform::kUnknown; editor::Editor *test_editor_ = nullptr; editor::EditorManager editor_manager_; diff --git a/src/app/gui/canvas.h b/src/app/gui/canvas.h index bc94352d..f2f2ef93 100644 --- a/src/app/gui/canvas.h +++ b/src/app/gui/canvas.h @@ -1,6 +1,7 @@ #ifndef YAZE_GUI_CANVAS_H #define YAZE_GUI_CANVAS_H +#include #include #include "app/gfx/bitmap.h" @@ -130,8 +131,8 @@ public: void DrawLayeredElements(); int GetTileIdFromMousePos() { - int x = mouse_pos_in_canvas_.x; - int y = mouse_pos_in_canvas_.y; + float x = mouse_pos_in_canvas_.x; + float y = mouse_pos_in_canvas_.y; int num_columns = (canvas_sz_.x / global_scale_) / custom_step_; int num_rows = (canvas_sz_.y / global_scale_) / custom_step_; int tile_id = (x / custom_step_) + (y / custom_step_) * num_columns; @@ -206,6 +207,7 @@ private: bool enable_context_menu_ = true; bool custom_canvas_size_ = false; bool select_rect_active_ = false; + bool refresh_graphics_ = false; float custom_step_ = 0.0f; float global_scale_ = 1.0f; @@ -216,14 +218,11 @@ private: uint16_t edit_palette_index_ = 0; uint64_t edit_palette_group_name_index_ = 0; uint64_t edit_palette_sub_index_ = 0; - bool refresh_graphics_ = false; - std::string canvas_id_ = "Canvas"; - std::string context_id_ = "CanvasContext"; - ImDrawList *draw_list_; - ImVector points_; - ImVector> labels_; + + ImDrawList* draw_list_ = nullptr; + ImVec2 scrolling_; ImVec2 canvas_sz_; ImVec2 canvas_p0_; @@ -231,7 +230,13 @@ private: ImVec2 drawn_tile_pos_; ImVec2 mouse_pos_in_canvas_; ImVec2 selected_tile_pos_ = ImVec2(-1, -1); + + ImVector points_; ImVector selected_points_; + ImVector> labels_; + + std::string canvas_id_ = "Canvas"; + std::string context_id_ = "CanvasContext"; std::vector selected_tiles_; };