Readded grid menu and fixed grid modify tool
This commit is contained in:
parent
19db2a57ea
commit
b7bd2efc71
10 changed files with 180 additions and 161 deletions
|
|
@ -32,7 +32,7 @@ void ColorRectangleDisplay::clay_draw(SkCanvas* canvas, UpdateInputData& io, Cla
|
|||
SkPaint alphaPaint;
|
||||
alphaPaint.setShader(get_alpha_background_shader());
|
||||
canvas->drawPaint(alphaPaint);
|
||||
canvas->drawPaint(SkPaint{color});
|
||||
canvas->drawPaint(SkPaint{SkColor4f(color.fR, color.fG, color.fB, std::sqrt(color.fA))}); // Square root for alpha to keep color visible
|
||||
canvas->restore();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ template <typename T> class DropDown : public Element {
|
|||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
}
|
||||
}) {
|
||||
ElementHelpers::text_label(gui, selections[*data]);
|
||||
ElementHelpers::text_label(gui, selections[static_cast<size_t>(*data)]);
|
||||
CLAY_AUTO_ID({.layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}}}) {}
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
|
|
@ -121,7 +121,7 @@ template <typename T> class DropDown : public Element {
|
|||
update_hovering_over(i, l->mouseHovering);
|
||||
if(l->mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down) {
|
||||
gui.set_post_callback_func([&, i] {
|
||||
*d = i;
|
||||
*d = static_cast<T>(i);
|
||||
isOpen = false;
|
||||
if(opts.onClick) opts.onClick();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@ void SelectableButton::layout(const Clay_ElementId& id, const Data& d) {
|
|||
SkColor4f backgroundColorHighlight;
|
||||
SkColor4f backgroundColor;
|
||||
|
||||
onClick = d.onClick;
|
||||
onClick = [&, this, d] {
|
||||
if(d.onClickButton)
|
||||
d.onClickButton(this);
|
||||
else if(d.onClick) d.onClick();
|
||||
};
|
||||
|
||||
if(isHeld || ((d.isSelected || mouseHovering) && d.drawType == DrawType::TRANSPARENT_BORDER))
|
||||
borderColor = io.theme->fillColor1;
|
||||
|
|
@ -66,8 +70,10 @@ void SelectableButton::layout(const Clay_ElementId& id, const Data& d) {
|
|||
void SelectableButton::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
bool oldIsHeld = isHeld;
|
||||
isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
if(isHeld) {
|
||||
gui.set_post_callback_func([&]{ if(onClick) onClick(); });
|
||||
if(isHeld)
|
||||
gui.set_to_layout();
|
||||
else if(mouseHovering && oldIsHeld && button.button == InputManager::MouseButton::LEFT && !button.down) {
|
||||
gui.set_post_callback_func(onClick);
|
||||
gui.set_to_layout();
|
||||
}
|
||||
else if(mouseHovering != oldIsHovering || isHeld != oldIsHeld)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class SelectableButton : public Element {
|
|||
DrawType drawType = DrawType::TRANSPARENT_ALL;
|
||||
bool isSelected = false;
|
||||
std::function<void()> onClick;
|
||||
std::function<void(SelectableButton*)> onClickButton;
|
||||
std::function<void(const InnerContentCallbackParameters&)> innerContent;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue