92 lines
3.3 KiB
C++
92 lines
3.3 KiB
C++
#include "widgets/controlCenter/controlCenter.hpp"
|
|
|
|
#include "components/button/iconButton.hpp"
|
|
#include "components/button/tabButton.hpp"
|
|
#include "components/mediaPlayer.hpp"
|
|
|
|
ControlCenter::ControlCenter(Icon::Type icon, std::string name)
|
|
: Popover(icon, name) {
|
|
this->popover->add_css_class("control-center-popover");
|
|
this->container.set_orientation(Gtk::Orientation::VERTICAL);
|
|
this->container.set_spacing(10);
|
|
|
|
this->scrollview.set_child(this->container);
|
|
this->scrollview.set_policy(
|
|
Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
|
|
this->scrollview.set_hexpand(false);
|
|
this->scrollview.set_vexpand(true);
|
|
this->scrollview.set_propagate_natural_height(true);
|
|
|
|
set_popover_child(this->scrollview);
|
|
|
|
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
|
|
this->tabRow.set_spacing(4);
|
|
this->tabRow.add_css_class("control-center-tab-row");
|
|
|
|
this->mediaTabButton = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
|
|
this->infoTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
|
|
this->timerButton = std::make_unique<TabButton>(Icon::TOKEN);
|
|
this->settingsTabButton = std::make_unique<TabButton>(Icon::SETTINGS);
|
|
|
|
this->tabRow.append(*this->mediaTabButton);
|
|
this->tabRow.append(*this->infoTabButton);
|
|
this->tabRow.append(*this->timerButton);
|
|
this->tabRow.append(*this->settingsTabButton);
|
|
|
|
this->container.append(this->tabRow);
|
|
|
|
this->contentStack.set_hhomogeneous(true);
|
|
this->contentStack.set_vhomogeneous(false);
|
|
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
|
|
|
|
this->mediaControlWidget = std::make_unique<MediaWidget>();
|
|
this->weatherWidget = std::make_unique<WeatherWidget>();
|
|
this->timerWidget = std::make_unique<TimerWidget>();
|
|
this->settingsWidget = std::make_unique<SettingsWidget>();
|
|
|
|
this->contentStack.add(*this->mediaControlWidget, "controls", "Controls");
|
|
this->contentStack.add(*this->weatherWidget, "info", "Info");
|
|
this->contentStack.add(*this->timerWidget, "timer", "Timer");
|
|
this->contentStack.add(*this->settingsWidget, "settings", "Settings");
|
|
|
|
this->contentStack.set_visible_child("controls");
|
|
this->setActiveTab("controls");
|
|
|
|
this->container.append(this->contentStack);
|
|
|
|
this->mediaTabButton->signal_clicked().connect([this]() {
|
|
this->setActiveTab("controls");
|
|
});
|
|
|
|
this->infoTabButton->signal_clicked().connect([this]() {
|
|
this->setActiveTab("info");
|
|
});
|
|
|
|
this->timerButton->signal_clicked().connect([this]() {
|
|
this->setActiveTab("timer");
|
|
});
|
|
|
|
this->settingsTabButton->signal_clicked().connect([this]() {
|
|
this->setActiveTab("settings");
|
|
});
|
|
}
|
|
|
|
void ControlCenter::setActiveTab(const std::string &tab_name) {
|
|
this->contentStack.set_visible_child(tab_name);
|
|
|
|
this->mediaTabButton->setActive(false);
|
|
this->infoTabButton->setActive(false);
|
|
this->timerButton->setActive(false);
|
|
this->settingsTabButton->setActive(false);
|
|
|
|
if (tab_name == "controls") {
|
|
this->mediaTabButton->setActive(true);
|
|
} else if (tab_name == "info") {
|
|
this->infoTabButton->setActive(true);
|
|
} else if (tab_name == "timer") {
|
|
this->timerButton->setActive(true);
|
|
} else if (tab_name == "settings") {
|
|
this->settingsTabButton->setActive(true);
|
|
}
|
|
}
|