mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
RichButton removed, use Container instead
This commit is contained in:
parent
b836ec514a
commit
9611252d84
10 changed files with 58 additions and 90 deletions
|
|
@ -229,6 +229,7 @@ Button::Button(std::shared_ptr<UINode> content, glm::vec4 padding)
|
|||
add(content);
|
||||
setScrollable(false);
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||
setPressedColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.95f));
|
||||
content->setInteractive(false);
|
||||
}
|
||||
|
||||
|
|
@ -258,6 +259,7 @@ Button::Button(
|
|||
label->setInteractive(false);
|
||||
add(label);
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||
setPressedColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.95f));
|
||||
}
|
||||
|
||||
void Button::setText(std::wstring text) {
|
||||
|
|
@ -273,14 +275,6 @@ std::wstring Button::getText() const {
|
|||
return L"";
|
||||
}
|
||||
|
||||
glm::vec4 Button::getPressedColor() const {
|
||||
return pressedColor;
|
||||
}
|
||||
|
||||
void Button::setPressedColor(glm::vec4 color) {
|
||||
pressedColor = color;
|
||||
}
|
||||
|
||||
Button* Button::textSupplier(wstringsupplier supplier) {
|
||||
if (label) {
|
||||
label->textSupplier(supplier);
|
||||
|
|
@ -303,20 +297,6 @@ void Button::drawBackground(const GfxContext* pctx, Assets* assets) {
|
|||
batch->rect(pos.x, pos.y, size.x, size.y);
|
||||
}
|
||||
|
||||
void Button::mouseRelease(GUI* gui, int x, int y) {
|
||||
UINode::mouseRelease(gui, x, y);
|
||||
if (isInside(glm::vec2(x, y))) {
|
||||
for (auto callback : actions) {
|
||||
callback(gui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button* Button::listenAction(onaction action) {
|
||||
actions.push_back(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
void Button::setTextAlign(Align align) {
|
||||
if (label) {
|
||||
label->setAlign(align);
|
||||
|
|
@ -331,33 +311,6 @@ Align Button::getTextAlign() const {
|
|||
return Align::left;
|
||||
}
|
||||
|
||||
// ============================== RichButton ==================================
|
||||
RichButton::RichButton(glm::vec2 size) : Container(size) {
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||
}
|
||||
|
||||
void RichButton::mouseRelease(GUI* gui, int x, int y) {
|
||||
UINode::mouseRelease(gui, x, y);
|
||||
if (isInside(glm::vec2(x, y))) {
|
||||
for (auto callback : actions) {
|
||||
callback(gui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RichButton* RichButton::listenAction(onaction action) {
|
||||
actions.push_back(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
void RichButton::drawBackground(const GfxContext* pctx, Assets* assets) {
|
||||
glm::vec2 pos = calcPos();
|
||||
auto batch = pctx->getBatch2D();
|
||||
batch->texture(nullptr);
|
||||
batch->setColor(isPressed() ? pressedColor : (hover ? hoverColor : color));
|
||||
batch->rect(pos.x, pos.y, size.x, size.y);
|
||||
}
|
||||
|
||||
// ================================ TextBox ===================================
|
||||
TextBox::TextBox(std::wstring placeholder, glm::vec4 padding)
|
||||
: Panel(glm::vec2(200,32), padding, 0),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue