hypr-chrome v0.1
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#define WLR_USE_UNSTABLE
|
||||
|
||||
#include "Globals.hpp"
|
||||
#include <hyprland/src/desktop/DesktopTypes.hpp>
|
||||
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
|
||||
#include <hyprutils/math/Box.hpp>
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Render {
|
||||
class ITexture;
|
||||
}
|
||||
|
||||
// A decoration that draws a chamfered HUD-style border frame behind each
|
||||
// window, expanding past the window's edges by `plugin:hyprchrome:extent`
|
||||
// pixels on every side. The frame's corners are chamfered by an amount
|
||||
// inferred from the window's own border rounding, so the border peeking out
|
||||
// around a rounded window's corners reads as a matching diagonal cut rather
|
||||
// than a hard rectangular corner.
|
||||
class ChromeDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
ChromeDecoration(PHLWINDOW window);
|
||||
virtual ~ChromeDecoration();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
|
||||
virtual void draw(PHLMONITOR monitor, float const& alpha);
|
||||
virtual eDecorationType getDecorationType();
|
||||
virtual void updateWindow(PHLWINDOW window);
|
||||
virtual void damageEntire();
|
||||
virtual eDecorationLayer getDecorationLayer();
|
||||
virtual uint64_t getDecorationFlags();
|
||||
virtual std::string getDisplayName();
|
||||
|
||||
PHLWINDOW GetOwner();
|
||||
|
||||
// Returns a cairo-rendered texture of the chamfered border frame sized to
|
||||
// `sizePx` (device pixels): a hollow ring `extentPx` thick inset from the
|
||||
// outer edge, with both the outer and inner boundaries corner-chamfered
|
||||
// by `chamferPx`, plus a title bar of height `titleBarHeightPx` and width
|
||||
// `titleBarWidthPx` (already measured/clamped by the caller - see
|
||||
// ChromeDecorationGeometry) hanging off the floating top-border
|
||||
// cutout. Cached and only regenerated when any of these change from the
|
||||
// last call.
|
||||
SP<Render::ITexture> GetBorderTexture(const Vector2D& sizePx, float extentPx, float chamferPx, uint64_t colorValue, float titleBarHeightPx, float titleBarWidthPx);
|
||||
|
||||
// Returns a texture of `title` rendered via Hyprland's own text renderer
|
||||
// (Pango, through IHyprRenderer::renderText) at `textSizePx` using
|
||||
// `fontFamily`, truncated with a trailing "…" if it doesn't fit within
|
||||
// `maxWidthPx` - black while `isActive`, 0xEEEEEEFF otherwise, both at the
|
||||
// border color's own alpha. Cached and only regenerated when any of these
|
||||
// change from the last call. Returns nullptr if `title` is empty.
|
||||
SP<Render::ITexture> GetTitleTexture(const std::string& title, float textSizePx, uint64_t colorValue, const std::string& fontFamily, int maxWidthPx, bool isActive);
|
||||
|
||||
WP<ChromeDecoration> self;
|
||||
|
||||
private:
|
||||
PHLWINDOWREF windowRef;
|
||||
CBox assignedBox;
|
||||
|
||||
SP<Render::ITexture> cachedTexture;
|
||||
Vector2D cachedTexSize = {-1, -1};
|
||||
float cachedExtent = -1.F;
|
||||
float cachedChamfer = -1.F;
|
||||
uint64_t cachedColorValue = 0;
|
||||
float cachedTitleBarHeight = -1.F;
|
||||
float cachedTitleBarWidth = -1.F;
|
||||
|
||||
SP<Render::ITexture> cachedTitleTex;
|
||||
std::string cachedTitleTexTitle;
|
||||
float cachedTitleTexSize = -1.F;
|
||||
uint64_t cachedTitleTexColor = 0;
|
||||
std::string cachedTitleTexFont;
|
||||
int cachedTitleTexMaxWidth = -1;
|
||||
bool cachedTitleTexActive = false;
|
||||
|
||||
// The border frame's box in global (monitor-independent) logical
|
||||
// coordinates: the window's own box, expanded by `extent` and offset by
|
||||
// the window's workspace/floating animation offsets.
|
||||
CBox FullDecorationExtentGlobal();
|
||||
|
||||
friend class ChromePassElement;
|
||||
};
|
||||
Reference in New Issue
Block a user