Improve highlighting structure
- switched to a sparse delta based map - true lazy-loading to avoid any unneccessary allocations - fixed windows management api
This commit is contained in:
@@ -22,6 +22,12 @@ struct Window : Tile {
|
||||
virtual std::array<std::string, 5> bar_info() { return {}; };
|
||||
};
|
||||
|
||||
struct Popup : Window {
|
||||
Coord pos;
|
||||
Coord size;
|
||||
virtual ~Popup() = default;
|
||||
};
|
||||
|
||||
struct TileBlock : Tile {
|
||||
bool vertical;
|
||||
std::vector<std::unique_ptr<Tile>> tiles;
|
||||
@@ -82,11 +88,12 @@ struct TileBlock : Tile {
|
||||
}
|
||||
};
|
||||
|
||||
struct TileRoot {
|
||||
struct TileBase {
|
||||
std::unique_ptr<Tile> tile;
|
||||
Coord pos;
|
||||
Coord size;
|
||||
|
||||
inline bool hidden() { return this->tile->hidden; }
|
||||
void render(std::vector<ScreenCell> &buffer) {
|
||||
if (this->tile->hidden)
|
||||
return;
|
||||
@@ -97,21 +104,23 @@ struct TileRoot {
|
||||
event.mouse_y -= this->pos.row;
|
||||
this->tile->handle_click(event, size);
|
||||
}
|
||||
bool inside(uint32_t x, uint32_t y) {
|
||||
return x >= pos.col && x < pos.col + size.col && y >= pos.row &&
|
||||
y < pos.row + size.row;
|
||||
}
|
||||
};
|
||||
|
||||
extern TileRoot root_tile;
|
||||
extern std::vector<std::unique_ptr<TileRoot>> popups;
|
||||
namespace layout {
|
||||
extern TileBase root_tile;
|
||||
extern Window *focused_window;
|
||||
extern std::vector<std::unique_ptr<Popup>> popups;
|
||||
extern std::vector<std::unique_ptr<TileBase>> floating_tiles;
|
||||
} // namespace layout
|
||||
|
||||
inline void close_popup(TileRoot *handle) {
|
||||
auto it = std::find_if(popups.begin(), popups.end(),
|
||||
[handle](const auto &p) { return p.get() == handle; });
|
||||
if (it != popups.end())
|
||||
popups.erase(it);
|
||||
inline void close(Popup *handle) {
|
||||
std::erase_if(layout::popups,
|
||||
[handle](const auto &p) { return p.get() == handle; });
|
||||
}
|
||||
|
||||
inline void close(TileBase *handle) {
|
||||
std::erase_if(layout::floating_tiles,
|
||||
[handle](const auto &p) { return p.get() == handle; });
|
||||
}
|
||||
|
||||
void render();
|
||||
|
||||
Reference in New Issue
Block a user