mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-12-24 10:50:03 +01:00
* widget: add click handling and point containment methods to IWidget interface * core: add onClick method to handle mouse click events - renderer: move getOrCreateWidgetsFor method declaration to public section * core: update mouse event handling to track mouse location and button clicks * widget: add onclick command handling and point containment to CLabel - config: add onclick special config value to label * assets: add label configuration for keyboard layout switching * config: add onclick configuration for label widgets - add CLICKABLE macro for onclick configuration - replace direct onclick assignment with CLICKABLE macro * core: fix cursor shape initialization and pointer handling - ensure pointer is available before setting cursor shape - initialize cursor shape device if not already done * core: add hover handling and cursor shape updates - implement onHover method to manage widget hover states - update cursor shape based on hover status - ensure all outputs are redrawn after state changes * widgets: add hover state management and bounding box calculations - add setHover and isHovered methods to manage hover state - implement containsPoint method for hit testing - override getBoundingBox in CLabel for accurate positioning - add onHover method in CLabel to change cursor shape * core: add hover handling in pointer motion - invoke onHover method with current mouse location * widgets: add hover handling and bounding box for password input field - add getBoundingBox method to calculate the widget's bounding box - implement onHover method to update cursor shape on hover * widgets: update hover behavior for label widget - modify cursor shape setting to only apply when onclickCommand is not empty * core: optimize hover handling and rendering for lock surfaces - Improve hover state tracking for widgets - reduce unnecessary redraw calls by tracking hover changes - remove redundant renderAllOutputs() call * widgets: add onclick and hover to shape and image * core: trigger hover and onclick only for the currently focused surface * core: handle fractionalScale in onclick and hover * core: don't trigger onclick or hover when hide_cursor is set * misc: remove braces * core: run onclick commands asnychronously --------- Co-authored-by: Memoraike <memoraike@gmail.com>
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "../../defines.hpp"
|
|
#include "../../helpers/Math.hpp"
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <any>
|
|
|
|
class COutput;
|
|
|
|
class IWidget {
|
|
public:
|
|
struct SRenderData {
|
|
float opacity = 1;
|
|
};
|
|
|
|
virtual ~IWidget() = default;
|
|
|
|
virtual void configure(const std::unordered_map<std::string, std::any>& prop, const SP<COutput>& pOutput) = 0;
|
|
virtual bool draw(const SRenderData& data) = 0;
|
|
|
|
static Vector2D posFromHVAlign(const Vector2D& viewport, const Vector2D& size, const Vector2D& offset, const std::string& halign, const std::string& valign,
|
|
const double& ang = 0);
|
|
static int roundingForBox(const CBox& box, int roundingConfig);
|
|
static int roundingForBorderBox(const CBox& borderBox, int roundingConfig, int thickness);
|
|
|
|
virtual CBox getBoundingBoxWl() const {
|
|
return CBox();
|
|
};
|
|
virtual void onClick(uint32_t button, bool down, const Vector2D& pos) {}
|
|
virtual void onHover(const Vector2D& pos) {}
|
|
bool containsPoint(const Vector2D& pos) const;
|
|
|
|
struct SFormatResult {
|
|
std::string formatted;
|
|
float updateEveryMs = 0; // 0 means don't (static)
|
|
bool alwaysUpdate = false;
|
|
bool cmd = false;
|
|
bool allowForceUpdate = false;
|
|
};
|
|
|
|
static SFormatResult formatString(std::string in);
|
|
|
|
void setHover(bool hover);
|
|
bool isHovered() const;
|
|
|
|
private:
|
|
bool hovered = false;
|
|
};
|