mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-08 22:08:02 +02:00
add onPointerMove function
This commit is contained in:
parent
b3956789e7
commit
b9060fdb74
5 changed files with 24 additions and 3 deletions
|
|
@ -738,7 +738,10 @@ void CHyprlock::onHover(const Vector2D& pos) {
|
|||
if (!HOVERED) {
|
||||
widget->setHover(true);
|
||||
widget->onHover(pos);
|
||||
widget->onPointerMove(pos);
|
||||
outputNeedsRedraw = true;
|
||||
} else {
|
||||
outputNeedsRedraw |= widget->onPointerMove(pos);
|
||||
}
|
||||
|
||||
if (!cursorChanged)
|
||||
|
|
|
|||
|
|
@ -275,6 +275,10 @@ bool IWidget::isHovered() const {
|
|||
return hovered;
|
||||
}
|
||||
|
||||
bool IWidget::onPointerMove(const Vector2D& pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IWidget::containsPoint(const Vector2D& pos) const {
|
||||
return getBoundingBoxWl().containsPoint(pos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class IWidget {
|
|||
};
|
||||
virtual void onClick(uint32_t button, bool down, const Vector2D& pos) {}
|
||||
virtual void onHover(const Vector2D& pos) {}
|
||||
virtual bool onPointerMove(const Vector2D& pos);
|
||||
bool containsPoint(const Vector2D& pos) const;
|
||||
|
||||
struct SFormatResult {
|
||||
|
|
|
|||
|
|
@ -645,14 +645,26 @@ CBox CPasswordInputField::getEyeBox() {
|
|||
|
||||
CBox inputFieldBox = getBoundingBoxWl();
|
||||
auto padding = (inputFieldBox.h - eyeSize.y) / 2.0;
|
||||
auto eyePosition =
|
||||
inputFieldBox.pos() + (password.eye.placement == "right" ? Vector2D{inputFieldBox.w - eyeSize.x - password.eye.margin - padding, padding} : Vector2D{padding, padding});
|
||||
auto eyePosition = inputFieldBox.pos() + (password.eye.placement == "right" ? Vector2D{inputFieldBox.w - eyeSize.x - padding, padding} : Vector2D{padding, padding});
|
||||
|
||||
return {eyePosition, eyeSize};
|
||||
}
|
||||
|
||||
void CPasswordInputField::onHover(const Vector2D& pos) {
|
||||
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER);
|
||||
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT);
|
||||
}
|
||||
|
||||
bool CPasswordInputField::onPointerMove(const Vector2D& pos) {
|
||||
CBox eyeBox = getEyeBox();
|
||||
|
||||
if (eyeBox.containsPoint(pos)) {
|
||||
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER);
|
||||
return true;
|
||||
} else {
|
||||
g_pSeatManager->m_pCursorShape->setShape(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPasswordInputField::onClick(uint32_t button, bool down, const Vector2D& pos) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class CPasswordInputField : public IWidget {
|
|||
virtual void configure(const std::unordered_map<std::string, std::any>& prop, const SP<COutput>& pOutput);
|
||||
virtual bool draw(const SRenderData& data);
|
||||
virtual void onHover(const Vector2D& pos);
|
||||
virtual bool onPointerMove(const Vector2D& pos);
|
||||
virtual void onClick(uint32_t button, bool down, const Vector2D& pos);
|
||||
virtual CBox getBoundingBoxWl() const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue