fix: tooltip visibility when cursor is hidden
This commit is contained in:
@@ -87,8 +87,6 @@ void GUI::updateTooltip(float delta) {
|
|||||||
|
|
||||||
/// @brief Mouse related input and logic handling
|
/// @brief Mouse related input and logic handling
|
||||||
void GUI::actMouse(float delta) {
|
void GUI::actMouse(float delta) {
|
||||||
updateTooltip(delta);
|
|
||||||
|
|
||||||
float mouseDelta = glm::length(Events::delta);
|
float mouseDelta = glm::length(Events::delta);
|
||||||
doubleClicked = false;
|
doubleClicked = false;
|
||||||
doubleClickTimer += delta + mouseDelta * 0.1f;
|
doubleClickTimer += delta + mouseDelta * 0.1f;
|
||||||
@@ -177,8 +175,14 @@ void GUI::act(float delta, const Viewport& vp) {
|
|||||||
container->act(delta);
|
container->act(delta);
|
||||||
auto prevfocus = focus;
|
auto prevfocus = focus;
|
||||||
|
|
||||||
|
updateTooltip(delta);
|
||||||
if (!Events::_cursor_locked) {
|
if (!Events::_cursor_locked) {
|
||||||
actMouse(delta);
|
actMouse(delta);
|
||||||
|
} else {
|
||||||
|
if (hover) {
|
||||||
|
hover->setHover(false);
|
||||||
|
hover = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focus) {
|
if (focus) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Container::Container(glm::vec2 size) : UINode(size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<UINode> Container::getAt(glm::vec2 pos, std::shared_ptr<UINode> self) {
|
std::shared_ptr<UINode> Container::getAt(glm::vec2 pos, std::shared_ptr<UINode> self) {
|
||||||
if (!interactive || !isEnabled()) {
|
if (!isInteractive() || !isEnabled()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!isInside(pos)) return nullptr;
|
if (!isInside(pos)) return nullptr;
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ UINode::~UINode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool UINode::isVisible() const {
|
bool UINode::isVisible() const {
|
||||||
|
if (visible && parent) {
|
||||||
|
return parent->isVisible();
|
||||||
|
}
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +110,7 @@ bool UINode::isInside(glm::vec2 point) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<UINode> UINode::getAt(glm::vec2 point, std::shared_ptr<UINode> self) {
|
std::shared_ptr<UINode> UINode::getAt(glm::vec2 point, std::shared_ptr<UINode> self) {
|
||||||
if (!interactive || !enabled) {
|
if (!isInteractive() || !enabled) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return isInside(point) ? self : nullptr;
|
return isInside(point) ? self : nullptr;
|
||||||
@@ -145,7 +148,6 @@ float UINode::getTooltipDelay() const {
|
|||||||
return tooltipDelay;
|
return tooltipDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::vec2 UINode::calcPos() const {
|
glm::vec2 UINode::calcPos() const {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
return pos + parent->calcPos() + parent->contentOffset();
|
return pos + parent->calcPos() + parent->contentOffset();
|
||||||
@@ -332,6 +334,16 @@ void UINode::setGravity(Gravity gravity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UINode::isSubnodeOf(const UINode* node) {
|
||||||
|
if (parent == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (parent == node) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return parent->isSubnodeOf(node);
|
||||||
|
}
|
||||||
|
|
||||||
void UINode::getIndices(
|
void UINode::getIndices(
|
||||||
const std::shared_ptr<UINode> node,
|
const std::shared_ptr<UINode> node,
|
||||||
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ namespace gui {
|
|||||||
|
|
||||||
virtual void setGravity(Gravity gravity);
|
virtual void setGravity(Gravity gravity);
|
||||||
|
|
||||||
|
bool isSubnodeOf(const UINode* node);
|
||||||
|
|
||||||
/// @brief collect all nodes having id
|
/// @brief collect all nodes having id
|
||||||
static void getIndices(
|
static void getIndices(
|
||||||
const std::shared_ptr<UINode> node,
|
const std::shared_ptr<UINode> node,
|
||||||
|
|||||||
Reference in New Issue
Block a user