no compile errors, fully functional workspace indicators

This commit is contained in:
2026-01-31 20:00:35 +01:00
parent 7ad6f46b3c
commit f3b250759e
17 changed files with 400 additions and 809 deletions

View File

@@ -1,42 +1,52 @@
#include "components/workspaceIndicator.hpp"
#include <iostream>
#include "gtkmm/button.h"
#include "gtkmm/gestureclick.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
WorkspaceIndicator::WorkspaceIndicator(std::string label, sigc::slot<void()> onClick)
WorkspaceIndicator::WorkspaceIndicator(int id, std::string label, sigc::slot<void(int)> onClick)
: Gtk::Box(Gtk::Orientation::HORIZONTAL) {
auto overlay = Gtk::make_managed<Gtk::Overlay>();
auto numLabel = Gtk::make_managed<Gtk::Label>(label);
auto pillContainer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
overlay = std::make_shared<Gtk::Overlay>();
auto numLabel = Gtk::make_managed<Gtk::Label>(label);
auto pillContainer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
// auto gesture = Gtk::GestureClick::create();
// gesture->set_button(GDK_BUTTON_PRIMARY);
// gesture->signal_released().connect([this, i](int, double, double) {
// this->service->switchToWorkspace(
// i + this->monitorId * HyprlandService::kWorkspaceSlotCount);
// });
auto gesture = Gtk::GestureClick::create();
gesture->set_button(GDK_BUTTON_PRIMARY);
gesture->signal_released().connect([this, id, onClick](int, double, double) {
onClick(
id);
});
overlay->add_controller(gesture);
overlay->add_css_class("workspace-pill");
// overlay->add_controller(gesture);
overlay->add_css_class("workspace-pill");
if (id == 6 || id == 7) {
auto indicator = Gtk::make_managed<Gtk::Label>(id == 6 ? "🫱🏻" : "🫲🏻");
indicator->add_css_class(id == 6 ? "workspace-pill-six" : "workspace-pill-seven");
indicator->set_valign(Gtk::Align::END);
overlay->set_child(*indicator);
overlay->add_overlay(*numLabel);
pillContainer->append(*overlay);
} else {
overlay->set_child(*numLabel);
pillContainer->append(*overlay);
}
// if (i == 6 || i == 7) {
// auto indicator = Gtk::make_managed<Gtk::Label>(i == 6 ? "🫱🏻" : "🫲🏻");
// indicator->add_css_class(i == 6 ? "workspace-pill-six" : "workspace-pill-seven");
// indicator->set_valign(Gtk::Align::END);
// overlay->set_child(*indicator);
// overlay->add_overlay(*numLabel);
// pillContainer->append(*overlay);
// } else {
overlay->set_child(*numLabel);
pillContainer->append(*overlay);
// }
append(*pillContainer);
append(*pillContainer);
}
void WorkspaceIndicator::setIndicatorState(InidicatorState state) {
this->clearCssClass();
this->currentState = state;
auto cssClass = this->stateToCssClass[state];
this->overlay->add_css_class(cssClass);
}
void WorkspaceIndicator::clearCssClass() {
for (const auto &[_, cssClass] : stateToCssClass) {
this->overlay->remove_css_class(cssClass);
}
}