hyprland-plugins/hyprbars/barDeco.hpp

78 lines
2.7 KiB
C++
Raw Permalink Normal View History

2023-02-28 21:30:51 +01:00
#pragma once
#define WLR_USE_UNSTABLE
2023-05-01 03:57:48 +02:00
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
#include <hyprland/src/render/OpenGL.hpp>
2024-05-14 23:40:06 +02:00
#include <hyprland/src/devices/IPointer.hpp>
2023-02-28 22:59:58 +01:00
#include "globals.hpp"
2023-02-28 21:30:51 +01:00
class CHyprBar : public IHyprWindowDecoration {
public:
2024-04-27 14:03:46 +02:00
CHyprBar(PHLWINDOW);
2023-02-28 21:30:51 +01:00
virtual ~CHyprBar();
2023-11-11 15:39:46 +01:00
virtual SDecorationPositioningInfo getPositioningInfo();
2023-02-28 21:30:51 +01:00
2023-11-11 15:39:46 +01:00
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
2023-02-28 21:30:51 +01:00
2024-10-31 12:18:29 +01:00
virtual void draw(PHLMONITOR, float const& a);
2023-02-28 21:30:51 +01:00
2023-11-11 15:39:46 +01:00
virtual eDecorationType getDecorationType();
2023-02-28 21:30:51 +01:00
2024-04-27 14:03:46 +02:00
virtual void updateWindow(PHLWINDOW);
2023-02-28 21:30:51 +01:00
2023-11-11 15:39:46 +01:00
virtual void damageEntire();
2023-02-28 21:30:51 +01:00
2023-11-11 15:39:46 +01:00
virtual eDecorationLayer getDecorationLayer();
2023-11-04 14:15:30 +01:00
2023-11-11 15:39:46 +01:00
virtual uint64_t getDecorationFlags();
2023-02-28 23:53:49 +01:00
2023-11-11 15:39:46 +01:00
bool m_bButtonsDirty = true;
virtual std::string getDisplayName();
2024-04-27 14:03:46 +02:00
PHLWINDOW getOwner();
void updateRules();
2024-12-17 01:27:36 +01:00
void applyRule(const SP<CWindowRule>&);
2023-02-28 21:30:51 +01:00
private:
2024-12-04 15:58:09 +01:00
SBoxExtents m_seExtents;
2023-02-28 21:30:51 +01:00
2024-12-04 15:58:09 +01:00
PHLWINDOWREF m_pWindow;
2023-02-28 21:30:51 +01:00
2024-12-04 15:58:09 +01:00
CBox m_bAssignedBox;
2023-02-28 21:30:51 +01:00
2024-12-04 15:58:09 +01:00
SP<CTexture> m_pTextTex;
SP<CTexture> m_pButtonsTex;
2023-02-28 21:30:51 +01:00
2024-12-04 15:58:09 +01:00
bool m_bWindowSizeChanged = false;
bool m_bHidden = false;
bool m_bTitleColorChanged = false;
std::optional<CHyprColor> m_bForcedBarColor;
std::optional<CHyprColor> m_bForcedTitleColor;
2023-02-28 22:17:46 +01:00
2024-12-04 15:58:09 +01:00
Vector2D cursorRelativeToBar();
2023-02-28 22:59:58 +01:00
2024-12-04 15:58:09 +01:00
void renderBarTitle(const Vector2D& bufferSize, const float scale);
void renderText(SP<CTexture> out, const std::string& text, const CHyprColor& color, const Vector2D& bufferSize, const float scale, const int fontSize);
void renderBarButtons(const Vector2D& bufferSize, const float scale);
void renderBarButtonsText(CBox* barBox, const float scale, const float a);
void onMouseDown(SCallbackInfo& info, IPointer::SButtonEvent e);
void onMouseMove(Vector2D coords);
CBox assignedBoxGlobal();
2023-02-28 22:59:58 +01:00
2024-12-04 15:58:09 +01:00
SP<HOOK_CALLBACK_FN> m_pMouseButtonCallback;
SP<HOOK_CALLBACK_FN> m_pMouseMoveCallback;
2023-02-28 22:59:58 +01:00
2024-12-04 15:58:09 +01:00
std::string m_szLastTitle;
2023-02-28 23:53:49 +01:00
2024-12-04 15:58:09 +01:00
bool m_bDraggingThis = false;
bool m_bDragPending = false;
bool m_bCancelledDown = false;
// for dynamic updates
int m_iLastHeight = 0;
};