GUI style changed to make it take less space
This commit is contained in:
parent
ab2d2ca415
commit
49d72e384c
18 changed files with 210 additions and 164 deletions
|
|
@ -67,7 +67,7 @@ void DrawImage::draw_download_progress_bar(SkCanvas* canvas, const DrawData& dra
|
|||
p.setStroke(true);
|
||||
p.setStrokeWidth(10.0f);
|
||||
p.setStrokeCap(SkPaint::kRound_Cap);
|
||||
p.setColor4f(drawData.main->toolbar.io->theme->fillColor5);
|
||||
p.setColor4f(drawData.main->toolbar.io->theme->fillColor1);
|
||||
Vector2f center = convert_vec2<Vector2f>(imRect.center());
|
||||
|
||||
const float DOWNLOAD_ARC_RADIUS = 50.0f;
|
||||
|
|
|
|||
|
|
@ -201,32 +201,27 @@ void DrawingProgram::toolbar_gui() {
|
|||
.border = {.color = convert_vec4<Clay_Color>(t.io->theme->backColor2), .width = CLAY_BORDER_OUTSIDE(t.io->theme->windowBorders1)}
|
||||
}) {
|
||||
t.gui.obstructing_window();
|
||||
if(t.gui.svg_icon_button("Brush Toolbar Button", "data/icons/brush.svg", drawTool->get_type() == DrawingProgramToolType::BRUSH)) { switch_to_tool(DrawingProgramToolType::BRUSH); }
|
||||
if(t.gui.svg_icon_button("Eraser Toolbar Button", "data/icons/eraser.svg", drawTool->get_type() == DrawingProgramToolType::ERASER)) { switch_to_tool(DrawingProgramToolType::ERASER); }
|
||||
if(t.gui.svg_icon_button("Text Toolbar Button", "data/icons/text.svg", drawTool->get_type() == DrawingProgramToolType::TEXTBOX)) { switch_to_tool(DrawingProgramToolType::TEXTBOX); }
|
||||
if(t.gui.svg_icon_button("Ellipse Toolbar Button", "data/icons/circle.svg", drawTool->get_type() == DrawingProgramToolType::ELLIPSE)) { switch_to_tool(DrawingProgramToolType::ELLIPSE); }
|
||||
if(t.gui.svg_icon_button("Rect Toolbar Button", "data/icons/rectangle.svg", drawTool->get_type() == DrawingProgramToolType::RECTANGLE)) { switch_to_tool(DrawingProgramToolType::RECTANGLE); }
|
||||
if(t.gui.svg_icon_button("RectSelect Toolbar Button", "data/icons/rectselect.svg", drawTool->get_type() == DrawingProgramToolType::RECTSELECT)) { switch_to_tool(DrawingProgramToolType::RECTSELECT); }
|
||||
if(t.gui.svg_icon_button("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", drawTool->get_type() == DrawingProgramToolType::LASSOSELECT)) { switch_to_tool(DrawingProgramToolType::LASSOSELECT); }
|
||||
if(t.gui.svg_icon_button("Edit Toolbar Button", "data/icons/cursor.svg", drawTool->get_type() == DrawingProgramToolType::EDIT)) { switch_to_tool(DrawingProgramToolType::EDIT); }
|
||||
if(t.gui.svg_icon_button("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", drawTool->get_type() == DrawingProgramToolType::EYEDROPPER)) { switch_to_tool(DrawingProgramToolType::EYEDROPPER); }
|
||||
if(t.gui.svg_icon_button("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", drawTool->get_type() == DrawingProgramToolType::ZOOM)) { switch_to_tool(DrawingProgramToolType::ZOOM); }
|
||||
if(t.gui.svg_icon_button("Pan Canvas Toolbar Button", "data/icons/hand.svg", drawTool->get_type() == DrawingProgramToolType::PAN)) { switch_to_tool(DrawingProgramToolType::PAN); }
|
||||
if(t.gui.svg_icon_button_transparent("Brush Toolbar Button", "data/icons/brush.svg", drawTool->get_type() == DrawingProgramToolType::BRUSH)) { switch_to_tool(DrawingProgramToolType::BRUSH); }
|
||||
if(t.gui.svg_icon_button_transparent("Eraser Toolbar Button", "data/icons/eraser.svg", drawTool->get_type() == DrawingProgramToolType::ERASER)) { switch_to_tool(DrawingProgramToolType::ERASER); }
|
||||
if(t.gui.svg_icon_button_transparent("Text Toolbar Button", "data/icons/text.svg", drawTool->get_type() == DrawingProgramToolType::TEXTBOX)) { switch_to_tool(DrawingProgramToolType::TEXTBOX); }
|
||||
if(t.gui.svg_icon_button_transparent("Ellipse Toolbar Button", "data/icons/circle.svg", drawTool->get_type() == DrawingProgramToolType::ELLIPSE)) { switch_to_tool(DrawingProgramToolType::ELLIPSE); }
|
||||
if(t.gui.svg_icon_button_transparent("Rect Toolbar Button", "data/icons/rectangle.svg", drawTool->get_type() == DrawingProgramToolType::RECTANGLE)) { switch_to_tool(DrawingProgramToolType::RECTANGLE); }
|
||||
if(t.gui.svg_icon_button_transparent("RectSelect Toolbar Button", "data/icons/rectselect.svg", drawTool->get_type() == DrawingProgramToolType::RECTSELECT)) { switch_to_tool(DrawingProgramToolType::RECTSELECT); }
|
||||
if(t.gui.svg_icon_button_transparent("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", drawTool->get_type() == DrawingProgramToolType::LASSOSELECT)) { switch_to_tool(DrawingProgramToolType::LASSOSELECT); }
|
||||
if(t.gui.svg_icon_button_transparent("Edit Toolbar Button", "data/icons/cursor.svg", drawTool->get_type() == DrawingProgramToolType::EDIT)) { switch_to_tool(DrawingProgramToolType::EDIT); }
|
||||
if(t.gui.svg_icon_button_transparent("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", drawTool->get_type() == DrawingProgramToolType::EYEDROPPER)) { switch_to_tool(DrawingProgramToolType::EYEDROPPER); }
|
||||
if(t.gui.svg_icon_button_transparent("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", drawTool->get_type() == DrawingProgramToolType::ZOOM)) { switch_to_tool(DrawingProgramToolType::ZOOM); }
|
||||
if(t.gui.svg_icon_button_transparent("Pan Canvas Toolbar Button", "data/icons/hand.svg", drawTool->get_type() == DrawingProgramToolType::PAN)) { switch_to_tool(DrawingProgramToolType::PAN); }
|
||||
|
||||
double newRotationAngle = world.drawData.cam.c.rotation, oldRotationAngle = world.drawData.cam.c.rotation;
|
||||
t.gui.rotate_wheel("Canvas Rotate Wheel", &newRotationAngle);
|
||||
if(newRotationAngle != oldRotationAngle)
|
||||
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), newRotationAngle - oldRotationAngle);
|
||||
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Foreground Color", &controls.foregroundColor, &controls.foregroundColor == t.colorLeft)) {
|
||||
t.color_selector_left(&controls.foregroundColor == t.colorLeft ? nullptr : &controls.foregroundColor);
|
||||
}
|
||||
}
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Background Color", &controls.backgroundColor, &controls.backgroundColor == t.colorLeft))
|
||||
t.color_selector_left(&controls.backgroundColor == t.colorLeft ? nullptr : &controls.backgroundColor);
|
||||
}
|
||||
if(t.gui.big_color_button("Foreground Color", &controls.foregroundColor, &controls.foregroundColor == t.colorLeft))
|
||||
t.color_selector_left(&controls.foregroundColor == t.colorLeft ? nullptr : &controls.foregroundColor);
|
||||
if(t.gui.big_color_button("Background Color", &controls.backgroundColor, &controls.backgroundColor == t.colorLeft))
|
||||
t.color_selector_left(&controls.backgroundColor == t.colorLeft ? nullptr : &controls.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace GUIStuff {
|
|||
void CheckBox::update(UpdateInputData& io, bool newIsTicked, const std::function<void()>& elemUpdate) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIXED(20), .height = CLAY_SIZING_FIXED(20)}
|
||||
.sizing = {.width = CLAY_SIZING_FIXED(15), .height = CLAY_SIZING_FIXED(15)}
|
||||
},
|
||||
.custom = { .customData = this }
|
||||
}) {
|
||||
|
|
@ -38,7 +38,7 @@ void CheckBox::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderComma
|
|||
}
|
||||
else {
|
||||
SkRect checkBox = SkRect::MakeLTRB(-0.45f, -0.45f, 0.45f, 0.45f);
|
||||
p.setColor4f(convert_vec4<SkColor4f>(selection.hovered ? io.theme->fillColor1 : io.theme->backColor3));
|
||||
p.setColor4f(convert_vec4<SkColor4f>(selection.hovered ? io.theme->fillColor1 : io.theme->fillColor2));
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(0.15f);
|
||||
canvas->drawRoundRect(checkBox, 0.25f, 0.25f, p);
|
||||
|
|
@ -47,7 +47,7 @@ void CheckBox::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderComma
|
|||
|
||||
if(isTicked) {
|
||||
SkPaint checkP;
|
||||
checkP.setColor4f(io.theme->backColor2);
|
||||
checkP.setColor4f(io.theme->backColor1);
|
||||
checkP.setStyle(SkPaint::kFill_Style);
|
||||
checkP.setStrokeWidth(0.12);
|
||||
checkP.setStrokeCap(SkPaint::kRound_Cap);
|
||||
|
|
|
|||
|
|
@ -22,15 +22,11 @@ namespace GUIStuff {
|
|||
|
||||
std::shared_ptr<Theme> get_default_dark_mode() {
|
||||
std::shared_ptr<Theme> theme(std::make_shared<Theme>());
|
||||
theme->fillColor1 = {0.25f, 0.5f, 0.85f, 1.0f};
|
||||
theme->fillColor2 = {0.5f, 0.58f, 0.93f, 1.0f};
|
||||
theme->fillColor3 = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
theme->fillColor4 = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
theme->fillColor5 = {0.76f, 0.76f, 1.0f, 1.0f};
|
||||
theme->backColor1 = {0.0f, 0.0f, 0.0f, 0.9f};
|
||||
theme->backColor2 = {0.15f, 0.15f, 0.15f, 1.0f};
|
||||
theme->backColor3 = {0.22f, 0.22f, 0.22f, 1.0f};
|
||||
theme->frontColor1 = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
theme->fillColor1 = {0.65f, 0.64f, 1.0f, 1.0f};
|
||||
theme->fillColor2 = {0.31f, 0.31f, 0.48f, 1.0f};
|
||||
theme->backColor1 = {0.156f, 0.156f, 0.18f, 1.0f};
|
||||
theme->backColor2 = {0.24f, 0.24f, 0.29f, 1.0f};
|
||||
theme->frontColor1 = {0.9f, 0.9f, 0.9f, 1.0f};
|
||||
theme->frontColor2 = {0.8f, 0.8f, 0.8f, 1.0f};
|
||||
return theme;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,24 +48,23 @@ typedef StringArena<4000000> DefaultStringArena;
|
|||
SkFont get_setup_skfont();
|
||||
|
||||
struct Theme {
|
||||
SkColor4f fillColor1 = {0.5f, 0.6f, 1.0f, 1.0f};
|
||||
SkColor4f fillColor2 = {0.4f, 0.5f, 0.9f, 1.0f};
|
||||
SkColor4f fillColor3 = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
SkColor4f fillColor4 = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
SkColor4f fillColor5 = {0.7f, 0.7f, 1.0f, 1.0f};
|
||||
SkColor4f backColor1 = {1.0f, 1.0f, 1.0f, 0.9f};
|
||||
SkColor4f backColor2 = {0.95f, 0.95f, 0.95f, 1.0f};
|
||||
SkColor4f backColor3 = {0.9f, 0.9f, 0.9f, 1.0f};
|
||||
SkColor4f frontColor1 = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
SkColor4f frontColor2 = {0.1f, 0.1f, 0.1f, 1.0f};
|
||||
SkColor4f fillColor1 = {0.8f, 0.785f, 1.0f, 1.0f};
|
||||
SkColor4f fillColor2 = {0.3f, 0.3f, 0.477f, 1.0f};
|
||||
SkColor4f backColor1 = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
SkColor4f backColor2 = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
SkColor4f frontColor1 = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
SkColor4f frontColor2 = {0.9f, 0.9f, 0.9f, 1.0f};
|
||||
|
||||
SkColor4f errorColor = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
SkColor4f warningColor = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
|
||||
float hoverExpandTime = 0.1f;
|
||||
uint16_t childGap1 = 10;
|
||||
uint16_t padding1 = 10;
|
||||
float windowCorners1 = 10;
|
||||
uint16_t windowBorders1 = 2;
|
||||
uint16_t childGap1 = 8;
|
||||
uint16_t padding1 = 8;
|
||||
float windowCorners1 = 8;
|
||||
uint16_t windowBorders1 = 0;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Theme, fillColor1, fillColor2, fillColor3, fillColor4, fillColor5, backColor1, backColor2, backColor3, frontColor1, frontColor2, hoverExpandTime, childGap1, padding1, windowCorners1, windowBorders1)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Theme, fillColor1, fillColor2, backColor1, backColor2, frontColor1, frontColor2, hoverExpandTime, childGap1, padding1, windowCorners1, windowBorders1)
|
||||
};
|
||||
|
||||
std::shared_ptr<Theme> get_default_dark_mode();
|
||||
|
|
@ -109,7 +108,7 @@ struct UpdateInputData {
|
|||
|
||||
SkFont get_font(float fSize) const;
|
||||
|
||||
uint16_t fontSize = 20;
|
||||
uint16_t fontSize = 14;
|
||||
sk_sp<SkTypeface> textTypeface;
|
||||
|
||||
sk_sp<skia::textlayout::FontCollection> fontCollection;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ void MovableTabList::update(UpdateInputData& io, const std::vector<std::pair<std
|
|||
}
|
||||
|
||||
CLAY({.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(45)},
|
||||
.padding = CLAY_PADDING_ALL(2),
|
||||
.childGap = 8,
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(35)},
|
||||
.padding = CLAY_PADDING_ALL(0),
|
||||
.childGap = 4,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
},
|
||||
|
|
@ -31,11 +31,11 @@ void MovableTabList::update(UpdateInputData& io, const std::vector<std::pair<std
|
|||
.sizing = {.width = CLAY_SIZING_FIT(250), .height = CLAY_SIZING_GROW(0)},
|
||||
}
|
||||
}) {
|
||||
buttons[i].update(io, true, true, [&](SelectionHelper& s, bool iS) {
|
||||
buttons[i].update(io, SelectableButton::DrawType::FILLED, [&](SelectionHelper& s, bool iS) {
|
||||
CLAY({.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||
.padding = CLAY_PADDING_ALL(4),
|
||||
.childGap = 4,
|
||||
.padding = CLAY_PADDING_ALL(0),
|
||||
.childGap = 0,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ void MovableTabList::update(UpdateInputData& io, const std::vector<std::pair<std
|
|||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
}
|
||||
}) {
|
||||
closeButtons[i].update(io, false, false, [&](SelectionHelper& s, bool iS) {
|
||||
closeButtons[i].update(io, SelectableButton::DrawType::TRANSPARENT, [&](SelectionHelper& s, bool iS) {
|
||||
if(s.clicked)
|
||||
closedTab = i;
|
||||
closeIcons[i].update(io, "data/icons/close.svg", s.held || s.hovered, nullptr);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ template <typename T> class NumberSlider : public Element {
|
|||
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(100), .height = CLAY_SIZING_FIXED(15)}
|
||||
.sizing = {.width = CLAY_SIZING_GROW(100), .height = CLAY_SIZING_FIXED(10)}
|
||||
},
|
||||
.custom = { .customData = this }
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ void PaintCircleMenu::draw_rotate_bar(SkCanvas* canvas, UpdateInputData& io) {
|
|||
if(rotateBarSelect.held)
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor1);
|
||||
else if(rotateBarSelect.hovered)
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor2);
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor1);
|
||||
else
|
||||
rotateBarHolderFill.setColor4f(io.theme->frontColor2);
|
||||
float rotateBarHolderRadius = (CIRCLE_END - ROTATE_START) / 2.0f;
|
||||
|
|
@ -155,7 +155,7 @@ void PaintCircleMenu::draw_palette_bar(SkCanvas* canvas, UpdateInputData& io) {
|
|||
double angleEnd = (colorSelectionIndex + 1) * colorDistribution;
|
||||
Vector2f lineDir1{std::cos(angleStart), std::sin(angleStart)};
|
||||
Vector2f lineDir2{std::cos(angleEnd), std::sin(angleEnd)};
|
||||
SkPaint lineP(io.theme->fillColor2);
|
||||
SkPaint lineP(io.theme->fillColor1);
|
||||
lineP.setStrokeWidth(5.0f);
|
||||
lineP.setStroke(true);
|
||||
lineP.setStrokeJoin(SkPaint::kRound_Join);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ void RadioButton::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCo
|
|||
}
|
||||
else {
|
||||
SkPaint p;
|
||||
p.setColor4f(convert_vec4<SkColor4f>(selection.hovered ? io.theme->fillColor1 : io.theme->backColor3));
|
||||
p.setColor4f(convert_vec4<SkColor4f>(selection.hovered ? io.theme->fillColor1 : io.theme->backColor2));
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(0.15f);
|
||||
canvas->drawCircle(0.0f, 0.0f, 0.5f, p);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void RotateWheel::draw_rotate_wheel(SkCanvas* canvas, UpdateInputData& io) {
|
|||
if(selection.held)
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor1);
|
||||
else if(selection.hovered)
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor2);
|
||||
rotateBarHolderFill.setColor4f(io.theme->fillColor1);
|
||||
else
|
||||
rotateBarHolderFill.setColor4f(io.theme->frontColor2);
|
||||
float rotateBarHolderRadius = (wheelEnd - wheelStart) / 2.0f;
|
||||
|
|
|
|||
|
|
@ -3,50 +3,51 @@
|
|||
|
||||
namespace GUIStuff {
|
||||
|
||||
void SelectableButton::update(UpdateInputData& io, bool hasBorders, bool hasBorderPadding, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool isSelected) {
|
||||
if(hasBorders) {
|
||||
SkColor4f borderColor;
|
||||
if(selection.held)
|
||||
borderColor = io.theme->fillColor1;
|
||||
else if(isSelected)
|
||||
borderColor = io.theme->fillColor2;
|
||||
else if(selection.hovered)
|
||||
borderColor = io.theme->fillColor2;
|
||||
else
|
||||
borderColor = io.theme->backColor3;
|
||||
void SelectableButton::update(UpdateInputData& io, DrawType drawType, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool isSelected) {
|
||||
bool hasBorders = selection.held || ((isSelected || selection.hovered) && drawType == DrawType::TRANSPARENT_BORDER);
|
||||
|
||||
SkColor4f backgroundColor;
|
||||
if(selection.held)
|
||||
backgroundColor = io.theme->backColor3;
|
||||
else if(isSelected)
|
||||
backgroundColor = io.theme->backColor2;
|
||||
else if(selection.hovered)
|
||||
backgroundColor = io.theme->backColor2;
|
||||
else
|
||||
backgroundColor = io.theme->backColor1;
|
||||
SkColor4f borderColor = hasBorders ? io.theme->fillColor1 : SkColor4f{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
SkColor4f backgroundColorHighlight;
|
||||
SkColor4f backgroundColor;
|
||||
|
||||
if(isSelected)
|
||||
backgroundColorHighlight = color_mul_alpha(io.theme->fillColor1, 0.4f);
|
||||
else if(selection.hovered || selection.held)
|
||||
backgroundColorHighlight = color_mul_alpha(io.theme->fillColor1, 0.2f);
|
||||
else
|
||||
backgroundColorHighlight = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
if(drawType == DrawType::TRANSPARENT || drawType == DrawType::TRANSPARENT_BORDER)
|
||||
backgroundColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
else if(drawType == DrawType::FILLED)
|
||||
backgroundColor = io.theme->backColor2;
|
||||
else
|
||||
backgroundColor = io.theme->fillColor2;
|
||||
|
||||
CLAY({.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||
.childGap = 0,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(backgroundColor),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||
.border = {
|
||||
.color = convert_vec4<Clay_Color>(borderColor),
|
||||
.width = CLAY_BORDER_OUTSIDE(1)
|
||||
}
|
||||
}) {
|
||||
CLAY({.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||
.padding = hasBorderPadding ? CLAY_PADDING_ALL(4) : CLAY_PADDING_ALL(0),
|
||||
.childGap = 4,
|
||||
.padding = (drawType == DrawType::TRANSPARENT_BORDER) ? CLAY_PADDING_ALL(0) : CLAY_PADDING_ALL(4),
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(backgroundColor),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||
.border = {
|
||||
.color = convert_vec4<Clay_Color>(borderColor),
|
||||
.width = CLAY_BORDER_OUTSIDE(4)
|
||||
}
|
||||
.backgroundColor = convert_vec4<Clay_Color>(backgroundColorHighlight),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
||||
}) {
|
||||
selection.update(Clay_Hovered(), io.mouse.leftClick, io.mouse.leftHeld);
|
||||
elemUpdate(selection, isSelected);
|
||||
}
|
||||
}
|
||||
else {
|
||||
selection.update(Clay_Hovered(), io.mouse.leftClick, io.mouse.leftHeld);
|
||||
elemUpdate(selection, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectableButton::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,14 @@ namespace GUIStuff {
|
|||
|
||||
class SelectableButton : public Element {
|
||||
public:
|
||||
void update(UpdateInputData& io, bool hasBorders, bool hasBorderPadding, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool isSelected);
|
||||
enum class DrawType {
|
||||
TRANSPARENT,
|
||||
FILLED,
|
||||
FILLED_INVERSE,
|
||||
TRANSPARENT_BORDER
|
||||
};
|
||||
|
||||
void update(UpdateInputData& io, DrawType drawType, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool isSelected);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command) override;
|
||||
SelectionHelper selection;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ template <typename T> class TextBox : public Element {
|
|||
SkRect r = SkRect::MakeXYWH(bb.min.x(), bb.min.y(), bb.width(), bb.height());
|
||||
|
||||
canvas->drawRect(r, SkPaint(io.theme->backColor2));
|
||||
SkPaint outline(selection.selected ? io.theme->fillColor1 : io.theme->backColor3);
|
||||
SkPaint outline(selection.selected ? io.theme->fillColor1 : io.theme->backColor2);
|
||||
outline.setStroke(true);
|
||||
outline.setStrokeWidth(2.0f);
|
||||
canvas->drawRoundRect(r, 2.0f, 2.0f, outline);
|
||||
|
|
|
|||
|
|
@ -365,10 +365,10 @@ void GUIManager::input_text(const std::string& id, std::string* val, const std::
|
|||
pop_id();
|
||||
}
|
||||
|
||||
bool GUIManager::selectable_button(const std::string& id, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool hasBorder, bool hasBorderPadding, bool isSelected) {
|
||||
bool GUIManager::selectable_button(const std::string& id, const std::function<void(SelectionHelper&, bool)>& elemUpdate, GUIStuff::SelectableButton::DrawType drawType, bool isSelected) {
|
||||
push_id(id);
|
||||
SelectableButton* e = insert_element<SelectableButton>();
|
||||
e->update(*io, hasBorder, hasBorderPadding, elemUpdate, isSelected);
|
||||
e->update(*io, drawType, elemUpdate, isSelected);
|
||||
bool toRet = e->selection.clicked;
|
||||
pop_id();
|
||||
return toRet;
|
||||
|
|
@ -388,7 +388,21 @@ bool GUIManager::svg_icon_button(const std::string& id, const std::string& svgPa
|
|||
svg_icon("1", svgPath, is || s.held || s.hovered);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, hasBorder, true, isSelected);
|
||||
}, SelectableButton::DrawType::FILLED, isSelected);
|
||||
}
|
||||
pop_id();
|
||||
return toRet;
|
||||
}
|
||||
|
||||
bool GUIManager::svg_icon_button_transparent(const std::string& id, const std::string& svgPath, bool isSelected, float size, bool hasBorder, const std::function<void()>& elemUpdate) {
|
||||
bool toRet = false;
|
||||
push_id(id);
|
||||
CLAY ({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(size), .height = CLAY_SIZING_FIXED(size) } } }) {
|
||||
toRet = selectable_button("0", [&](SelectionHelper& s, bool is) {
|
||||
svg_icon("1", svgPath, is || s.held || s.hovered);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, SelectableButton::DrawType::TRANSPARENT, isSelected);
|
||||
}
|
||||
pop_id();
|
||||
return toRet;
|
||||
|
|
@ -401,7 +415,7 @@ bool GUIManager::text_button_sized(const std::string& id, const std::string& tex
|
|||
text_label(text);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, true, true, isSelected);
|
||||
}, SelectableButton::DrawType::FILLED, isSelected);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
|
@ -413,19 +427,45 @@ bool GUIManager::text_button(const std::string& id, const std::string& text, boo
|
|||
text_label(text);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, true, true, isSelected);
|
||||
}, SelectableButton::DrawType::FILLED, isSelected);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
bool GUIManager::text_button_wide(const std::string& id, const std::string& text, bool isSelected, const std::function<void()>& elemUpdate) {
|
||||
bool toRet = false;
|
||||
CLAY ({.layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) } } }) {
|
||||
CLAY ({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
|
||||
.childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER},
|
||||
}}) {
|
||||
toRet = selectable_button(id, [&](SelectionHelper& s, bool iS) {
|
||||
text_label(text);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, true, true, isSelected);
|
||||
}, SelectableButton::DrawType::FILLED, isSelected);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
bool GUIManager::text_button_left_transparent(const std::string& id, const std::string& text, bool isSelected, const std::function<void()>& elemUpdate) {
|
||||
bool toRet = false;
|
||||
CLAY ({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
|
||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
||||
}}) {
|
||||
toRet = selectable_button(id, [&](SelectionHelper& s, bool iS) {
|
||||
CLAY ({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
|
||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}
|
||||
}}) {
|
||||
text_label(text);
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}
|
||||
}, SelectableButton::DrawType::TRANSPARENT, isSelected);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
|
@ -495,7 +535,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
|||
svg_icon("dropico", "data/icons/droparrow.svg", dropDownOpen);
|
||||
}
|
||||
}
|
||||
}, true, false, dropDownOpen);
|
||||
}, SelectableButton::DrawType::FILLED, dropDownOpen);
|
||||
if(dropDownOpen) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
|
|
@ -516,7 +556,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
|||
.attachTo = CLAY_ATTACH_TO_PARENT
|
||||
},
|
||||
.border = {
|
||||
.color = convert_vec4<Clay_Color>(io->theme->backColor3),
|
||||
.color = convert_vec4<Clay_Color>(io->theme->backColor2),
|
||||
.width = CLAY_BORDER_OUTSIDE(4)
|
||||
}
|
||||
}) {
|
||||
|
|
@ -532,7 +572,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
|||
if(selectedEntry)
|
||||
entryColor = io->theme->backColor2;
|
||||
else if(Clay_Hovered())
|
||||
entryColor = io->theme->backColor3;
|
||||
entryColor = io->theme->backColor2;
|
||||
else
|
||||
entryColor = io->theme->backColor1;
|
||||
CLAY({
|
||||
|
|
@ -621,9 +661,9 @@ void GUIManager::scroll_bar_area(const std::string& uniqueId, const std::functio
|
|||
if(sD.isMoving)
|
||||
scrollerColor = io->theme->fillColor1;
|
||||
else if(Clay_Hovered())
|
||||
scrollerColor = io->theme->fillColor2;
|
||||
scrollerColor = io->theme->fillColor1;
|
||||
else
|
||||
scrollerColor = io->theme->backColor3;
|
||||
scrollerColor = io->theme->backColor2;
|
||||
|
||||
CLAY({
|
||||
.layout = {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "Elements/PaintCircleMenu.hpp"
|
||||
#include "Elements/RadioButton.hpp"
|
||||
#include "Elements/ColorPicker.hpp"
|
||||
#include "Elements/SelectableButton.hpp"
|
||||
#include "Elements/TextBox.hpp"
|
||||
#include <any>
|
||||
#include "GUIManagerID.hpp"
|
||||
|
|
@ -18,10 +19,13 @@
|
|||
|
||||
using namespace Eigen;
|
||||
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
class GUIManager {
|
||||
public:
|
||||
constexpr static float BIG_BUTTON_SIZE = 30;
|
||||
|
||||
struct ElementContainer {
|
||||
std::unique_ptr<Element> elem;
|
||||
std::any extra;
|
||||
|
|
@ -50,20 +54,23 @@ class GUIManager {
|
|||
void text_label_size(const std::string& val, float modifier);
|
||||
void text_label(const std::string& val);
|
||||
void text_label_centered(const std::string& val);
|
||||
bool text_button_left_transparent(const std::string& id, const std::string& text, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool text_button(const std::string& id, const std::string& text, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool text_button_wide(const std::string& id, const std::string& text, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool text_button_sized(const std::string& id, const std::string& text, Clay_SizingAxis x, Clay_SizingAxis y, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);
|
||||
|
||||
void svg_icon(const std::string& id, const std::string& svgPath, bool isHighlighted = false, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool svg_icon_button(const std::string& id, const std::string& svgPath, bool isSelected = false, float size = 40.0f, bool hasBorder = true, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool svg_icon_button(const std::string& id, const std::string& svgPath, bool isSelected = false, float size = BIG_BUTTON_SIZE, bool hasBorder = true, const std::function<void()>& elemUpdate = nullptr);
|
||||
|
||||
bool rotate_wheel(const std::string& id, double* angle, float size = 40.0f, const std::function<void()>& elemUpdate = nullptr);
|
||||
bool svg_icon_button_transparent(const std::string& id, const std::string& svgPath, bool isSelected = false, float size = BIG_BUTTON_SIZE, bool hasBorder = true, const std::function<void()>& elemUpdate = nullptr);
|
||||
|
||||
bool rotate_wheel(const std::string& id, double* angle, float size = BIG_BUTTON_SIZE, const std::function<void()>& elemUpdate = nullptr);
|
||||
|
||||
void top_to_bottom_window_popup_layout(Clay_SizingAxis x, Clay_SizingAxis y, const std::function<void()>& elemUpdate);
|
||||
void left_to_right_layout(Clay_SizingAxis x, Clay_SizingAxis y, const std::function<void()>& elemUpdate);
|
||||
void left_to_right_line_layout(const std::function<void()>& elemUpdate);
|
||||
|
||||
bool selectable_button(const std::string& id, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool hasBorder, bool hasBorderPadding, bool isSelected);
|
||||
bool selectable_button(const std::string& id, const std::function<void(SelectionHelper&, bool)>& elemUpdate, GUIStuff::SelectableButton::DrawType drawType, bool isSelected);
|
||||
|
||||
void push_id(int64_t id);
|
||||
void push_id(const std::string& id);
|
||||
|
|
@ -226,6 +233,14 @@ class GUIManager {
|
|||
pop_id();
|
||||
}
|
||||
|
||||
template <typename T> bool big_color_button(const std::string& id, T* val, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr) {
|
||||
bool toRet = false;
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(GUIStuff::GUIManager::BIG_BUTTON_SIZE), .height = CLAY_SIZING_FIXED(GUIStuff::GUIManager::BIG_BUTTON_SIZE)}}}) {
|
||||
toRet = color_button<T>(id, val, isSelected, elemUpdate);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
template <typename T> bool color_button(const std::string& id, T* val, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr) {
|
||||
return selectable_button(id, [&](SelectionHelper& s, bool iS) {
|
||||
CLAY({.layout = {
|
||||
|
|
@ -236,14 +251,14 @@ class GUIManager {
|
|||
}) {}
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, true, false, isSelected);
|
||||
}, GUIStuff::SelectableButton::DrawType::TRANSPARENT_BORDER, isSelected);
|
||||
}
|
||||
|
||||
template <typename T> void color_picker_button(const std::string& id, T* val, bool selectAlpha, const std::function<void()>& elemUpdate = nullptr) {
|
||||
push_id(id);
|
||||
bool& isOpen = insert_any_with_id<bool>(0, false);
|
||||
bool clicked;
|
||||
CLAY ({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40) } } }) {
|
||||
CLAY ({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(BIG_BUTTON_SIZE), .height = CLAY_SIZING_FIXED(BIG_BUTTON_SIZE) } } }) {
|
||||
clicked = color_button("0", val, isOpen, elemUpdate);
|
||||
}
|
||||
if(clicked)
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ void RichTextBox::rebuild() {
|
|||
pData.pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
||||
pData.pStyle.setTextDirection(skia::textlayout::TextDirection::kLtr);
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
tStyle.setFontSize(20.0f);
|
||||
tStyle.setFontSize(14.0f);
|
||||
tStyle.setFontFamilies({SkString{"Roboto"}});
|
||||
pData.pStyle.setTextStyle(tStyle);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ Toolbar::Toolbar(MainProgram& initMain):
|
|||
io->textTypeface = main.fonts.map["Roboto"];
|
||||
io->textFontMgr = main.fonts.mgr;
|
||||
io->fontCollection = main.fonts.collection;
|
||||
io->fontSize = 20;
|
||||
|
||||
load_default_palette();
|
||||
load_default_theme();
|
||||
|
|
@ -226,7 +225,6 @@ nlohmann::json Toolbar::get_config_json() {
|
|||
toRet["jumpTransitionTime"] = jumpTransitionTime;
|
||||
toRet["dragZoomSpeed"] = dragZoomSpeed;
|
||||
toRet["scrollZoomSpeed"] = scrollZoomSpeed;
|
||||
toRet["guiFontSize"] = io->fontSize;
|
||||
toRet["showPerformance"] = showPerformance;
|
||||
toRet["displayName"] = main.displayName;
|
||||
toRet["useNativeFilePicker"] = useNativeFilePicker;
|
||||
|
|
@ -280,7 +278,6 @@ void Toolbar::set_config_json(const nlohmann::json& j) {
|
|||
j.at("dragZoomSpeed").get_to(dragZoomSpeed);
|
||||
j.at("scrollZoomSpeed").get_to(scrollZoomSpeed);
|
||||
j.at("guiScale").get_to(guiScale);
|
||||
j.at("guiFontSize").get_to(io->fontSize);
|
||||
j.at("showPerformance").get_to(showPerformance);
|
||||
j.at("useNativeFilePicker").get_to(useNativeFilePicker);
|
||||
j.at("themeInUse").get_to(themeData.themeCurrentlyLoaded);
|
||||
|
|
@ -422,7 +419,7 @@ void Toolbar::top_toolbar() {
|
|||
bool menuPopUpJustOpen = false;
|
||||
bool bookmarkMenuPopUpJustOpen = false;
|
||||
bool gridMenuPopUpJustOpen = false;
|
||||
if(gui.svg_icon_button("Main Menu Button", "data/icons/menu.svg", menuPopUpOpen)) {
|
||||
if(gui.svg_icon_button_transparent("Main Menu Button", "data/icons/menu.svg", menuPopUpOpen)) {
|
||||
menuPopUpOpen = true;
|
||||
menuPopUpJustOpen = true;
|
||||
}
|
||||
|
|
@ -433,11 +430,11 @@ void Toolbar::top_toolbar() {
|
|||
gui.tab_list("file tab list", tabNames, main.worldIndex, closedTab);
|
||||
if(main.world->network_being_used() && gui.svg_icon_button("Player List Toggle Button", "data/icons/list.svg", playerMenuOpen))
|
||||
playerMenuOpen = !playerMenuOpen;
|
||||
if(gui.svg_icon_button("Menu Undo Button", "data/icons/undo.svg"))
|
||||
if(gui.svg_icon_button_transparent("Menu Undo Button", "data/icons/undo.svg"))
|
||||
main.world->undo_with_checks();
|
||||
if(gui.svg_icon_button("Menu Redo Button", "data/icons/redo.svg"))
|
||||
if(gui.svg_icon_button_transparent("Menu Redo Button", "data/icons/redo.svg"))
|
||||
main.world->redo_with_checks();
|
||||
if(gui.svg_icon_button("Grids Button", "data/icons/grid.svg", gridMenu.popupOpen)) {
|
||||
if(gui.svg_icon_button_transparent("Grids Button", "data/icons/grid.svg", gridMenu.popupOpen)) {
|
||||
if(gridMenu.popupOpen)
|
||||
stop_displaying_grid_menu();
|
||||
else {
|
||||
|
|
@ -445,7 +442,7 @@ void Toolbar::top_toolbar() {
|
|||
gridMenuPopUpJustOpen = true;
|
||||
}
|
||||
}
|
||||
if(gui.svg_icon_button("Bookmark Menu Button", "data/icons/bookmark.svg", bookMenu.popupOpen)) {
|
||||
if(gui.svg_icon_button_transparent("Bookmark Menu Button", "data/icons/bookmark.svg", bookMenu.popupOpen)) {
|
||||
if(bookMenu.popupOpen)
|
||||
bookMenu.popupOpen = false;
|
||||
else {
|
||||
|
|
@ -464,9 +461,9 @@ void Toolbar::top_toolbar() {
|
|||
if(menuPopUpOpen) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0) },
|
||||
.sizing = {.width = CLAY_SIZING_FIT(100), .height = CLAY_SIZING_FIT(0) },
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childGap = 1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||
},
|
||||
|
|
@ -476,20 +473,20 @@ void Toolbar::top_toolbar() {
|
|||
.border = {.color = convert_vec4<Clay_Color>(io->theme->backColor2), .width = CLAY_BORDER_OUTSIDE(io->theme->windowBorders1)}
|
||||
}) {
|
||||
gui.obstructing_window();
|
||||
if(gui.text_button_wide("new file local", "New File")) {
|
||||
if(gui.text_button_left_transparent("new file local", "New File")) {
|
||||
main.new_tab({
|
||||
.conType = World::CONNECTIONTYPE_LOCAL
|
||||
}, true);
|
||||
}
|
||||
if(gui.text_button_wide("save file", "Save"))
|
||||
if(gui.text_button_left_transparent("save file", "Save"))
|
||||
save_func();
|
||||
if(gui.text_button_wide("save as file", "Save As"))
|
||||
if(gui.text_button_left_transparent("save as file", "Save As"))
|
||||
save_as_func();
|
||||
if(gui.text_button_wide("open file", "Open"))
|
||||
if(gui.text_button_left_transparent("open file", "Open"))
|
||||
open_world_file(World::CONNECTIONTYPE_LOCAL, "", "");
|
||||
if(gui.text_button_wide("screenshot", "Take Screenshot"))
|
||||
if(gui.text_button_left_transparent("screenshot", "Take Screenshot"))
|
||||
main.world->drawProg.switch_to_tool(DrawingProgramToolType::SCREENSHOT);
|
||||
if(gui.text_button_wide("add image or file to canvas", "Add Image/File to Canvas")) {
|
||||
if(gui.text_button_left_transparent("add image or file to canvas", "Add Image/File to Canvas")) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_browser_file::upload("*", [](std::string const& fileName, std::string const& mimeType, std::string_view buffer, void* callbackData) {
|
||||
if(!buffer.empty()) {
|
||||
|
|
@ -506,36 +503,36 @@ void Toolbar::top_toolbar() {
|
|||
#endif
|
||||
}
|
||||
if(main.world->network_being_used()) {
|
||||
if(gui.text_button_wide("lobby info", "Lobby Info")) {
|
||||
if(gui.text_button_left_transparent("lobby info", "Lobby Info")) {
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = LOBBY_INFO_MENU;
|
||||
}
|
||||
}
|
||||
else if(gui.text_button_wide("start hosting", "Host")) {
|
||||
else if(gui.text_button_left_transparent("start hosting", "Host")) {
|
||||
serverLocalID = NetLibrary::get_random_server_local_id();
|
||||
serverToConnectTo = NetLibrary::get_global_id() + serverLocalID;
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = HOST_MENU;
|
||||
}
|
||||
if(gui.text_button_wide("start connecting", "Connect")) {
|
||||
if(gui.text_button_left_transparent("start connecting", "Connect")) {
|
||||
serverToConnectTo.clear();
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = CONNECT_MENU;
|
||||
}
|
||||
if(gui.text_button_wide("canvas specific settings", "Canvas Settings")) {
|
||||
if(gui.text_button_left_transparent("canvas specific settings", "Canvas Settings")) {
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = CANVAS_SETTINGS_MENU;
|
||||
}
|
||||
if(gui.text_button_wide("open options", "Settings")) {
|
||||
if(gui.text_button_left_transparent("open options", "Settings")) {
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = GENERAL_SETTINGS_MENU;
|
||||
}
|
||||
if(gui.text_button_wide("about menu button", "About")) {
|
||||
if(gui.text_button_left_transparent("about menu button", "About")) {
|
||||
optionsMenuOpen = true;
|
||||
optionsMenuType = ABOUT_MENU;
|
||||
}
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if(gui.text_button_wide("quit button", "Quit"))
|
||||
if(gui.text_button_left_transparent("quit button", "Quit"))
|
||||
main.setToQuit = true;
|
||||
#endif
|
||||
if(io->mouse.leftClick && !menuPopUpJustOpen)
|
||||
|
|
@ -696,17 +693,17 @@ void Toolbar::grid_menu(bool justOpened) {
|
|||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
}
|
||||
}) {
|
||||
if(gui.svg_icon_button("visibility eye", grid.visible ? "data/icons/eyeopen.svg" : "data/icons/eyeclose.svg", false, entryHeight, false)) {
|
||||
if(gui.svg_icon_button_transparent("visibility eye", grid.visible ? "data/icons/eyeopen.svg" : "data/icons/eyeclose.svg", false, entryHeight, false)) {
|
||||
miniButtonClicked = true;
|
||||
grid.visible = !grid.visible;
|
||||
main.world->gridMan.send_grid_info(gridID);
|
||||
}
|
||||
if(gui.svg_icon_button("edit pencil", "data/icons/pencil.svg", false, entryHeight, false)) {
|
||||
if(gui.svg_icon_button_transparent("edit pencil", "data/icons/pencil.svg", false, entryHeight, false)) {
|
||||
miniButtonClicked = true;
|
||||
main.world->drawProg.modify_grid(gridID);
|
||||
stop_displaying_grid_menu();
|
||||
}
|
||||
if(gui.svg_icon_button("delete trash", "data/icons/trash.svg", false, entryHeight, false)) {
|
||||
if(gui.svg_icon_button_transparent("delete trash", "data/icons/trash.svg", false, entryHeight, false)) {
|
||||
miniButtonClicked = true;
|
||||
toDelete = gridID;
|
||||
}
|
||||
|
|
@ -789,11 +786,11 @@ void Toolbar::bookmark_menu(bool justOpened) {
|
|||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
}
|
||||
}) {
|
||||
if(gui.svg_icon_button("bookmark jump button", "data/icons/jump.svg", false, entryHeight, false)) {
|
||||
if(gui.svg_icon_button_transparent("bookmark jump button", "data/icons/jump.svg", false, entryHeight, false)) {
|
||||
miniButtonClicked = true;
|
||||
main.world->bMan.jump_to_bookmark(bookmark);
|
||||
}
|
||||
if(gui.svg_icon_button("delete trash", "data/icons/trash.svg", false, entryHeight, false)) {
|
||||
if(gui.svg_icon_button_transparent("delete trash", "data/icons/trash.svg", false, entryHeight, false)) {
|
||||
miniButtonClicked = true;
|
||||
toDelete = bookmark;
|
||||
}
|
||||
|
|
@ -833,7 +830,7 @@ std::unique_ptr<skia::textlayout::Paragraph> Toolbar::build_paragraph_from_chat_
|
|||
tStyle.setFontSize(io->fontSize);
|
||||
tStyle.setFontFamilies({SkString{"Roboto"}});
|
||||
tStyle.setFontStyle(SkFontStyle::Bold());
|
||||
tStyle.setForegroundColor(SkPaint{color_mul_alpha(message.type == ChatMessage::JOIN ? io->theme->fillColor4 : io->theme->frontColor1, alpha)});
|
||||
tStyle.setForegroundColor(SkPaint{color_mul_alpha(message.type == ChatMessage::JOIN ? io->theme->warningColor : io->theme->frontColor1, alpha)});
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
||||
skia::textlayout::ParagraphBuilderImpl a(pStyle, io->fontCollection, SkUnicodes::ICU::Make());
|
||||
|
|
@ -1000,7 +997,7 @@ void Toolbar::global_log() {
|
|||
c = io->theme->frontColor1;
|
||||
break;
|
||||
case LogMessage::COLOR_ERROR:
|
||||
c = io->theme->fillColor3;
|
||||
c = io->theme->errorColor;
|
||||
break;
|
||||
}
|
||||
gui.text_label_color(logM.text, color_mul_alpha(c, a));
|
||||
|
|
@ -1025,7 +1022,7 @@ void Toolbar::drawing_program_gui() {
|
|||
if(colorLeft) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0)},
|
||||
.sizing = {.width = CLAY_SIZING_FIT(250), .height = CLAY_SIZING_FIT(0)},
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
|
|
@ -1051,7 +1048,7 @@ void Toolbar::drawing_program_gui() {
|
|||
if(colorRight) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0)},
|
||||
.sizing = {.width = CLAY_SIZING_FIT(250), .height = CLAY_SIZING_FIT(0)},
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
|
|
@ -1077,7 +1074,7 @@ void Toolbar::color_palette(const std::string& id, Vector4f* color, bool& hoveri
|
|||
gui.push_id(id);
|
||||
auto& palette = paletteData.palettes[paletteData.selectedPalette].colors;
|
||||
size_t i = 0;
|
||||
constexpr float COLOR_BUTTON_SIZE = 35.0f;
|
||||
constexpr float COLOR_BUTTON_SIZE = GUIStuff::GUIManager::BIG_BUTTON_SIZE;
|
||||
while(i < palette.size()) {
|
||||
CLAY({
|
||||
.layout = {
|
||||
|
|
@ -1371,18 +1368,18 @@ void Toolbar::options_menu() {
|
|||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(150), .height = CLAY_SIZING_GROW(0) },
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childGap = 2,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||
}
|
||||
}) {
|
||||
auto oldOption = generalSettingsOptions;
|
||||
if(gui.text_button_wide("Generalbutton", "General", generalSettingsOptions == GSETTINGS_GENERAL)) generalSettingsOptions = GSETTINGS_GENERAL;
|
||||
if(gui.text_button_wide("Appearancebutton", "Appearance", generalSettingsOptions == GSETTINGS_APPEARANCE)) generalSettingsOptions = GSETTINGS_APPEARANCE;
|
||||
if(gui.text_button_wide("Tabletbutton", "Tablet", generalSettingsOptions == GSETTINGS_TABLET)) generalSettingsOptions = GSETTINGS_TABLET;
|
||||
if(gui.text_button_wide("Themebutton", "Theme", generalSettingsOptions == GSETTINGS_THEME)) generalSettingsOptions = GSETTINGS_THEME;
|
||||
if(gui.text_button_wide("Keybindsbutton", "Keybinds", generalSettingsOptions == GSETTINGS_KEYBINDS)) generalSettingsOptions = GSETTINGS_KEYBINDS;
|
||||
if(gui.text_button_wide("Debugbutton", "Debug", generalSettingsOptions == GSETTINGS_DEBUG)) generalSettingsOptions = GSETTINGS_DEBUG;
|
||||
if(gui.text_button_left_transparent("Generalbutton", "General", generalSettingsOptions == GSETTINGS_GENERAL)) generalSettingsOptions = GSETTINGS_GENERAL;
|
||||
if(gui.text_button_left_transparent("Appearancebutton", "Appearance", generalSettingsOptions == GSETTINGS_APPEARANCE)) generalSettingsOptions = GSETTINGS_APPEARANCE;
|
||||
if(gui.text_button_left_transparent("Tabletbutton", "Tablet", generalSettingsOptions == GSETTINGS_TABLET)) generalSettingsOptions = GSETTINGS_TABLET;
|
||||
if(gui.text_button_left_transparent("Themebutton", "Theme", generalSettingsOptions == GSETTINGS_THEME)) generalSettingsOptions = GSETTINGS_THEME;
|
||||
if(gui.text_button_left_transparent("Keybindsbutton", "Keybinds", generalSettingsOptions == GSETTINGS_KEYBINDS)) generalSettingsOptions = GSETTINGS_KEYBINDS;
|
||||
if(gui.text_button_left_transparent("Debugbutton", "Debug", generalSettingsOptions == GSETTINGS_DEBUG)) generalSettingsOptions = GSETTINGS_DEBUG;
|
||||
if(oldOption != generalSettingsOptions) {
|
||||
load_theme();
|
||||
themeData.selectedThemeIndex = std::nullopt;
|
||||
|
|
@ -1429,8 +1426,6 @@ void Toolbar::options_menu() {
|
|||
case GSETTINGS_APPEARANCE: {
|
||||
gui.push_id("appearance settings");
|
||||
gui.input_scalar_field("Max GUI Scale", "Max GUI Scale", &guiScale, 0.5f, 3.0f, 1);
|
||||
gui.input_scalar_field<uint16_t>("GUI Font Size", "GUI Font Size", &io->fontSize, 10, 30);
|
||||
gui.text_label("Note: Changing font size may break UI in some cases.");
|
||||
gui.pop_id();
|
||||
break;
|
||||
}
|
||||
|
|
@ -1500,14 +1495,12 @@ void Toolbar::options_menu() {
|
|||
gui.text_label("Note: Changes only remain if theme is saved");
|
||||
gui.color_picker_button_field("fillColor1", "Fill Color 1", &io->theme->fillColor1, true);
|
||||
gui.color_picker_button_field("fillColor2", "Fill Color 2", &io->theme->fillColor2, true);
|
||||
gui.color_picker_button_field("fillColor3", "Fill Color 3", &io->theme->fillColor3, true);
|
||||
gui.color_picker_button_field("fillColor4", "Fill Color 4", &io->theme->fillColor4, true);
|
||||
gui.color_picker_button_field("fillColor5", "Fill Color 5", &io->theme->fillColor5, true);
|
||||
gui.color_picker_button_field("backColor1", "Back Color 1", &io->theme->backColor1, true);
|
||||
gui.color_picker_button_field("backColor2", "Back Color 2", &io->theme->backColor2, true);
|
||||
gui.color_picker_button_field("backColor3", "Back Color 3", &io->theme->backColor3, true);
|
||||
gui.color_picker_button_field("frontColor1", "Front Color 1", &io->theme->frontColor1, true);
|
||||
gui.color_picker_button_field("frontColor2", "Front Color 2", &io->theme->frontColor2, true);
|
||||
gui.color_picker_button_field("warningColor", "Warning Color", &io->theme->warningColor, true);
|
||||
gui.color_picker_button_field("errorColor", "Error Color", &io->theme->errorColor, true);
|
||||
//gui.slider_scalar_field("hoverExpandTime", "Hover Expand Time", &io->theme->hoverExpandTime, 0.001f, 1.0f);
|
||||
gui.input_scalar_field<uint16_t>("childGap1", "Gap between child elements", &io->theme->childGap1, 0, 30);
|
||||
gui.input_scalar_field<uint16_t>("padding1", "Window padding", &io->theme->padding1, 0, 30);
|
||||
|
|
@ -1715,7 +1708,7 @@ void Toolbar::about_menu_gui() {
|
|||
.childGap = io->theme->childGap1,
|
||||
}
|
||||
}) {
|
||||
if(gui.text_button_wide("infinipaintnoticebutton", "InfiniPaint", selectedLicense == -1)) selectedLicense = -1;
|
||||
if(gui.text_button_left_transparent("infinipaintnoticebutton", "InfiniPaint", selectedLicense == -1)) selectedLicense = -1;
|
||||
}
|
||||
gui.text_label_centered("Third Party Libraries");
|
||||
for(int i = 0; i < static_cast<int>(thirdPartyLicenses.size()); i++) {
|
||||
|
|
@ -1727,7 +1720,7 @@ void Toolbar::about_menu_gui() {
|
|||
}
|
||||
}) {
|
||||
gui.push_id(i);
|
||||
if(gui.text_button_wide("noticebutton", thirdPartyLicenses[i].first, selectedLicense == i)) selectedLicense = i;
|
||||
if(gui.text_button_left_transparent("noticebutton", thirdPartyLicenses[i].first, selectedLicense == i)) selectedLicense = i;
|
||||
gui.pop_id();
|
||||
}
|
||||
}
|
||||
|
|
@ -1857,7 +1850,7 @@ void Toolbar::file_picker_gui() {
|
|||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(entryHeight)},
|
||||
.childGap = 2,
|
||||
.childGap = 1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
class MainProgram;
|
||||
|
||||
#define DEFAULT_CANVAS_BACKGROUND_COLOR Vector3f{0.12f, 0.12f, 0.12f}
|
||||
#define DEFAULT_CANVAS_BACKGROUND_COLOR Vector3f{0.07f, 0.07f, 0.07f}
|
||||
|
||||
class World {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue