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