Enable picking color alpha for triangles

This commit is contained in:
Stephen Seo 2024-01-23 15:04:09 +09:00
parent c6dd68ae14
commit 20859dbcd8

View file

@ -97,13 +97,20 @@ namespace Tri {
inline void draw_color_picker(Tri::State *state) { inline void draw_color_picker(Tri::State *state) {
if(state->get_flags().test(Tri::State::F_DISPLAY_COLOR_P)) { if(state->get_flags().test(Tri::State::F_DISPLAY_COLOR_P)) {
GuiSetAlpha(1.0f); GuiSetAlpha(1.0f);
if(!GuiWindowBox({4.0f, 4.0f, 242.0f, 292.0f}, "Tri Color Picker")) { if(!GuiWindowBox({4.0f, 4.0f, 242.0f, 328.0f}, "Tri Color Picker")) {
auto &colorArray = state->get_color(); auto &color = state->get_color();
GuiColorPicker( GuiColorPicker(
{8.0f, 32.0f, 206.0f, 240.0f}, {8.0f, 32.0f, 206.0f, 240.0f},
nullptr, nullptr,
&colorArray); &color);
if(GuiButton({8.0f, 274.0f, 234.0f, 16.0f}, "Close")) { float alpha = ((float)color.a) / 255.0F;
GuiColorBarAlpha(
{8.0F, 280.0F, 206.0F, 20.0F},
nullptr,
&alpha
);
color.a = alpha * 255.0F;
if(GuiButton({8.0f, 308.0f, 234.0f, 16.0f}, "Close")) {
state->close_color_picker(); state->close_color_picker();
} }
} else { } else {
@ -248,13 +255,20 @@ namespace Tri {
inline void draw_edit_tri(Tri::State *state) { inline void draw_edit_tri(Tri::State *state) {
if(state->get_flags().test(Tri::State::F_TRI_EDIT_MODE)) { if(state->get_flags().test(Tri::State::F_TRI_EDIT_MODE)) {
GuiSetAlpha(1.0f); GuiSetAlpha(1.0f);
if(!GuiWindowBox({500.0f, 4.0f, 242.0f, 292.0f}, "Edit Tri Color Picker")) { if(!GuiWindowBox({500.0f, 4.0f, 242.0f, 328.0f}, "Edit Tri Color Picker")) {
auto &colorArray = state->get_selected_tri_color(); auto &color = state->get_selected_tri_color();
GuiColorPicker( GuiColorPicker(
{504.0f, 32.0f, 206.0f, 240.0f}, {504.0f, 32.0f, 206.0f, 240.0f},
nullptr, nullptr,
&colorArray); &color);
if(GuiButton({504.0f, 272.0f, 234.0f, 16.0f}, "Close")) { float alpha = ((float)color.a) / 255.0F;
GuiColorBarAlpha(
{504.0F, 280.0F, 206.0F, 20.0F},
nullptr,
&alpha
);
color.a = alpha * 255.0F;
if(GuiButton({504.0f, 308.0f, 234.0f, 16.0f}, "Close")) {
state->close_selected_tri_mode(); state->close_selected_tri_mode();
} }
} else { } else {