mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 06:51:51 +00:00
minor refactor
This commit is contained in:
parent
cc27e4b224
commit
d437b67580
2 changed files with 11 additions and 4 deletions
|
|
@ -59,10 +59,17 @@ void GUI::onAssetsLoad(Assets* assets) {
|
||||||
), "core:root");
|
), "core:root");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::resetTooltip() {
|
||||||
|
tooltipTimer = 0.0f;
|
||||||
|
tooltip->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::updateTooltip(float delta) {
|
void GUI::updateTooltip(float delta) {
|
||||||
|
if (hover == nullptr || !hover->isInside(Events::cursor)) {
|
||||||
|
return resetTooltip();
|
||||||
|
}
|
||||||
float mouseDelta = glm::length(Events::delta);
|
float mouseDelta = glm::length(Events::delta);
|
||||||
if ((hover && mouseDelta < 1.0f) ||
|
if (mouseDelta < 1.0f || tooltipTimer >= hover->getTooltipDelay()) {
|
||||||
(hover && hover->isInside(Events::cursor) && tooltipTimer >= hover->getTooltipDelay())) {
|
|
||||||
if (tooltipTimer + delta >= hover->getTooltipDelay()) {
|
if (tooltipTimer + delta >= hover->getTooltipDelay()) {
|
||||||
auto label = std::dynamic_pointer_cast<gui::Label>(get("tooltip.label"));
|
auto label = std::dynamic_pointer_cast<gui::Label>(get("tooltip.label"));
|
||||||
const auto& text = hover->getTooltip();
|
const auto& text = hover->getTooltip();
|
||||||
|
|
@ -80,8 +87,7 @@ void GUI::updateTooltip(float delta) {
|
||||||
}
|
}
|
||||||
tooltipTimer += delta;
|
tooltipTimer += delta;
|
||||||
} else {
|
} else {
|
||||||
tooltipTimer = 0.0f;
|
resetTooltip();
|
||||||
tooltip->setVisible(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ namespace gui {
|
||||||
void actMouse(float delta);
|
void actMouse(float delta);
|
||||||
void actFocused();
|
void actFocused();
|
||||||
void updateTooltip(float delta);
|
void updateTooltip(float delta);
|
||||||
|
void resetTooltip();
|
||||||
public:
|
public:
|
||||||
GUI();
|
GUI();
|
||||||
~GUI();
|
~GUI();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue