2023-05-16 03:02:26 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hyprland/src/helpers/AnimatedVariable.hpp>
|
|
|
|
#include <hyprland/src/helpers/Vector2D.hpp>
|
2023-05-25 02:27:02 -07:00
|
|
|
#include <list>
|
2023-05-28 17:50:22 -07:00
|
|
|
#include <memory>
|
2023-05-26 01:17:01 -07:00
|
|
|
#include <vector>
|
2023-05-16 03:02:26 -07:00
|
|
|
|
|
|
|
class Hy3TabGroup;
|
2023-05-25 02:27:02 -07:00
|
|
|
class Hy3TabBar;
|
2023-05-16 03:02:26 -07:00
|
|
|
|
|
|
|
#include "Hy3Layout.hpp"
|
|
|
|
#include <hyprland/src/render/Texture.hpp>
|
|
|
|
|
|
|
|
struct Hy3TabBarEntry {
|
|
|
|
std::string window_title;
|
2023-05-28 02:55:21 -07:00
|
|
|
bool focused = false;
|
2023-05-16 03:02:26 -07:00
|
|
|
bool urgent = false;
|
2023-05-28 02:55:21 -07:00
|
|
|
CTexture texture;
|
2023-05-25 02:27:02 -07:00
|
|
|
CAnimatedVariable offset; // offset 0, 0.0-1.0 of total bar
|
|
|
|
CAnimatedVariable width; // 0.0-1.0 of total bar
|
2023-05-28 23:19:35 -07:00
|
|
|
Hy3TabBar& tab_bar;
|
2023-05-25 02:27:02 -07:00
|
|
|
Hy3Node& node; // only used for comparioson. do not deref.
|
2023-05-28 23:19:35 -07:00
|
|
|
wlr_box last_render_box;
|
2023-05-28 02:55:21 -07:00
|
|
|
float last_render_rounding = 0.0;
|
2023-05-28 23:19:35 -07:00
|
|
|
bool last_render_focused = false;
|
|
|
|
bool last_render_urgent = false;
|
2023-05-25 02:27:02 -07:00
|
|
|
|
2023-05-28 23:19:35 -07:00
|
|
|
Hy3TabBarEntry(Hy3TabBar&, Hy3Node&);
|
2023-05-28 17:50:22 -07:00
|
|
|
bool operator==(const Hy3Node&) const;
|
|
|
|
bool operator==(const Hy3TabBarEntry&) const;
|
2023-05-28 02:55:21 -07:00
|
|
|
|
2023-05-30 01:10:46 -07:00
|
|
|
void setFocused(bool);
|
|
|
|
void setUrgent(bool);
|
2023-05-28 23:19:35 -07:00
|
|
|
void prepareTexture(float, wlr_box&);
|
2023-05-16 03:02:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class Hy3TabBar {
|
|
|
|
public:
|
2023-05-28 23:19:35 -07:00
|
|
|
bool destroy = false;
|
2023-05-30 23:23:46 -07:00
|
|
|
bool dirty = true;
|
|
|
|
bool damaged = true;
|
2023-05-25 02:27:02 -07:00
|
|
|
CAnimatedVariable vertical_pos;
|
|
|
|
CAnimatedVariable fade_opacity;
|
|
|
|
|
|
|
|
Hy3TabBar();
|
2023-05-28 23:19:35 -07:00
|
|
|
void beginDestroy();
|
2023-05-16 03:02:26 -07:00
|
|
|
|
2023-05-25 02:27:02 -07:00
|
|
|
void updateNodeList(std::list<Hy3Node*>& nodes);
|
|
|
|
void updateAnimations(bool warp = false);
|
2023-05-16 03:02:26 -07:00
|
|
|
void setSize(Vector2D);
|
|
|
|
|
2023-05-28 02:55:21 -07:00
|
|
|
std::list<Hy3TabBarEntry> entries;
|
2023-05-16 03:02:26 -07:00
|
|
|
private:
|
2023-05-25 02:27:02 -07:00
|
|
|
Hy3Node* focused_node = nullptr;
|
2023-05-16 03:02:26 -07:00
|
|
|
Vector2D size;
|
2023-05-28 23:19:35 -07:00
|
|
|
|
|
|
|
// Tab bar entries take a reference to `this`.
|
|
|
|
Hy3TabBar(Hy3TabBar&&) = delete;
|
|
|
|
Hy3TabBar(const Hy3TabBar&) = delete;
|
2023-05-16 03:02:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class Hy3TabGroup {
|
|
|
|
public:
|
2023-05-29 02:36:13 -07:00
|
|
|
CWindow* target_window = nullptr;
|
2023-05-31 22:11:59 -07:00
|
|
|
int workspace_id = -1;
|
2023-05-16 03:02:26 -07:00
|
|
|
Hy3TabBar bar;
|
|
|
|
CAnimatedVariable pos;
|
|
|
|
CAnimatedVariable size;
|
|
|
|
|
|
|
|
// initialize a group with the given node. UB if node is not a group.
|
2023-05-28 23:19:35 -07:00
|
|
|
Hy3TabGroup(Hy3Node&);
|
2023-05-16 03:02:26 -07:00
|
|
|
|
|
|
|
// update tab bar with node position and data. UB if node is not a group.
|
|
|
|
void updateWithGroup(Hy3Node&);
|
2023-05-30 23:23:46 -07:00
|
|
|
void damageIfRequired();
|
2023-05-16 03:02:26 -07:00
|
|
|
// render the scaled tab bar on the current monitor.
|
|
|
|
void renderTabBar();
|
|
|
|
|
|
|
|
private:
|
2023-05-26 01:17:01 -07:00
|
|
|
std::vector<CWindow*> stencil_windows;
|
2023-05-30 01:10:46 -07:00
|
|
|
Vector2D last_pos;
|
|
|
|
Vector2D last_size;
|
2023-05-26 01:17:01 -07:00
|
|
|
|
2023-05-28 17:50:22 -07:00
|
|
|
Hy3TabGroup();
|
|
|
|
|
2023-05-16 03:02:26 -07:00
|
|
|
// moving a Hy3TabGroup will unregister any active animations
|
|
|
|
Hy3TabGroup(Hy3TabGroup&&) = delete;
|
2023-05-26 01:17:01 -07:00
|
|
|
|
|
|
|
// UB if node is not a group.
|
|
|
|
void updateStencilWindows(Hy3Node&);
|
2023-05-16 03:02:26 -07:00
|
|
|
};
|