hy3/src/TabGroup.hpp

115 lines
2.5 KiB
C++
Raw Normal View History

2023-05-16 03:02:26 -07:00
#pragma once
2023-06-07 03:22:17 -07:00
#include <hyprland/src/Compositor.hpp>
#include <list>
#include <memory>
2023-05-26 01:17:01 -07:00
#include <vector>
2023-05-16 03:02:26 -07:00
class Hy3TabGroup;
class Hy3TabBar;
2023-05-16 03:02:26 -07:00
#include "Hy3Layout.hpp"
struct Hy3TabBarEntry {
std::string window_title;
2023-06-09 00:18:37 -07:00
bool destroying = false;
CTexture texture;
CAnimatedVariable focused;
CAnimatedVariable urgent;
2023-06-09 00:18:37 -07:00
CAnimatedVariable offset; // 0.0-1.0 of total bar
CAnimatedVariable width; // 0.0-1.0 of total bar
CAnimatedVariable vertical_pos; // 0.0-1.0, user specified direction
CAnimatedVariable fade_opacity; // 0.0-1.0
Hy3TabBar& tab_bar;
Hy3Node& node; // only used for comparioson. do not deref.
2023-06-04 17:28:26 -07:00
struct {
int x, y;
float rounding = 0.0;
float scale = 0.0;
float focused = 0.0;
float urgent = 0.0;
2023-06-04 17:28:26 -07:00
std::string window_title;
std::string text_font;
int text_height = 0;
int text_padding = 0;
int col_active = 0;
int col_urgent = 0;
int col_inactive = 0;
int col_text_active = 0;
int col_text_urgent = 0;
int col_text_inactive = 0;
} last_render;
Hy3TabBarEntry(Hy3TabBar&, Hy3Node&);
bool operator==(const Hy3Node&) const;
bool operator==(const Hy3TabBarEntry&) const;
void setFocused(bool);
void setUrgent(bool);
2023-06-04 17:28:26 -07:00
void setWindowTitle(std::string);
2023-06-09 00:18:37 -07:00
void beginDestroy();
void unDestroy();
bool shouldRemove();
void prepareTexture(float, wlr_box&);
2023-05-16 03:02:26 -07:00
};
class Hy3TabBar {
public:
bool destroy = false;
2023-05-30 23:23:46 -07:00
bool dirty = true;
bool damaged = true;
CAnimatedVariable fade_opacity;
Hy3TabBar();
void beginDestroy();
2023-05-16 03:02:26 -07:00
2023-06-09 00:18:37 -07:00
void tick();
void updateNodeList(std::list<Hy3Node*>& nodes);
void updateAnimations(bool warp = false);
2023-05-16 03:02:26 -07:00
void setSize(Vector2D);
std::list<Hy3TabBarEntry> entries;
2023-06-07 03:22:17 -07:00
2023-05-16 03:02:26 -07:00
private:
Hy3Node* focused_node = nullptr;
2023-05-16 03:02:26 -07:00
Vector2D size;
// 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:
CWindow* target_window = nullptr;
int workspace_id = -1;
bool hidden = false;
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.
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&);
void tick();
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;
Vector2D last_pos;
Vector2D last_size;
2023-05-26 01:17:01 -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
};