Fixes with change window size

WIP window size still doesn't change properly
This commit is contained in:
Stephen Seo 2021-03-30 12:51:46 +09:00
parent 0e6a9f6de4
commit 1bc5e62502
4 changed files with 20 additions and 10 deletions

View file

@ -173,14 +173,14 @@ namespace Tri {
state->get_input_width(), state->get_input_width(),
800, 800,
1920, 1920,
true); state->get_flags().test(State::F_TAB_TOGGLE));
GuiValueBox( GuiValueBox(
{384.0f, 348.0f, 80.0f, 16.0f}, {384.0f, 348.0f, 80.0f, 16.0f},
"Height", "Height",
state->get_input_height(), state->get_input_height(),
600, 600,
1080, 1080,
true); !state->get_flags().test(State::F_TAB_TOGGLE));
const std::string &failMessage = state->failed_message(); const std::string &failMessage = state->failed_message();
if(!failMessage.empty()) { if(!failMessage.empty()) {
GuiLabel({304.0f, 368.0f, 284.0f, 16.0f}, failMessage.c_str()); GuiLabel({304.0f, 368.0f, 284.0f, 16.0f}, failMessage.c_str());

View file

@ -1,2 +1,6 @@
#pragma warning(push, 0)
#define RAYGUI_IMPLEMENTATION #define RAYGUI_IMPLEMENTATION
#include <raygui.h> #include <raygui.h>
#pragma warning(pop)

View file

@ -150,8 +150,9 @@ void Tri::State::handle_events() {
case KEY_I: case KEY_I:
flags.flip(F_DISPLAY_CHANGE_SIZE); flags.flip(F_DISPLAY_CHANGE_SIZE);
if(!flags.test(F_DISPLAY_CHANGE_SIZE)) { if(!flags.test(F_DISPLAY_CHANGE_SIZE)) {
inputWidth = width; close_input_width_height_window();
inputHeight = height; } else {
failedMessage = "Press TAB to switch between width/height";
} }
break; break;
case KEY_E: case KEY_E:
@ -164,6 +165,9 @@ void Tri::State::handle_events() {
} }
} }
break; break;
case KEY_TAB:
flags.flip(F_TAB_TOGGLE);
break;
} }
} }
keyPressed = GetKeyPressed(); keyPressed = GetKeyPressed();
@ -394,7 +398,7 @@ std::array<float, 3>& Tri::State::get_bg_color() {
return bgColorPickerColor; return bgColorPickerColor;
} }
Tri::State::FilenameBufferType* Tri::State::get_save_filename_buffer() { std::array<char, 256>* Tri::State::get_save_filename_buffer() {
return &saveFilenameBuffer; return &saveFilenameBuffer;
} }
@ -505,6 +509,9 @@ bool Tri::State::change_width_height() {
} }
void Tri::State::close_input_width_height_window() { void Tri::State::close_input_width_height_window() {
failedMessage.clear();
inputWidth = width;
inputHeight = height;
flags.reset(F_DISPLAY_CHANGE_SIZE); flags.reset(F_DISPLAY_CHANGE_SIZE);
} }

View file

@ -34,6 +34,7 @@ namespace Tri {
F_SELECT_TRI_MODE = 11, F_SELECT_TRI_MODE = 11,
F_TRI_EDIT_MODE = 12, F_TRI_EDIT_MODE = 12,
F_TRI_EDIT_DRAW_TRI = 13, F_TRI_EDIT_DRAW_TRI = 13,
F_TAB_TOGGLE = 14,
}; };
private: private:
@ -44,8 +45,7 @@ namespace Tri {
unsigned int height; unsigned int height;
float dt; float dt;
float notification_alpha; float notification_alpha;
typedef std::array<char, 256> NBufferType; std::array<char, 256> notification_text;
NBufferType notification_text;
std::vector<Triangle> tris; std::vector<Triangle> tris;
unsigned int trisIndex; unsigned int trisIndex;
@ -58,8 +58,7 @@ namespace Tri {
std::array<float, 3> bgColorPickerColor; std::array<float, 3> bgColorPickerColor;
Color bgColor; Color bgColor;
typedef std::array<char, 256> FilenameBufferType; std::array<char, 256> saveFilenameBuffer;
FilenameBufferType saveFilenameBuffer;
std::string failedMessage; std::string failedMessage;
RenderTexture2D drawCache; RenderTexture2D drawCache;
@ -97,7 +96,7 @@ namespace Tri {
std::array<float, 4>& get_color(); std::array<float, 4>& get_color();
std::array<float, 3>& get_bg_color(); std::array<float, 3>& get_bg_color();
FilenameBufferType* get_save_filename_buffer(); std::array<char, 256>* get_save_filename_buffer();
bool do_save(); bool do_save();
const std::string& failed_message() const; const std::string& failed_message() const;
void close_save(); void close_save();