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(),
800,
1920,
true);
state->get_flags().test(State::F_TAB_TOGGLE));
GuiValueBox(
{384.0f, 348.0f, 80.0f, 16.0f},
"Height",
state->get_input_height(),
600,
1080,
true);
!state->get_flags().test(State::F_TAB_TOGGLE));
const std::string &failMessage = state->failed_message();
if(!failMessage.empty()) {
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
#include <raygui.h>
#pragma warning(pop)

View file

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

View file

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