some refactore
This commit is contained in:
@@ -1,32 +1,40 @@
|
||||
#include "widgets/controlCenter/controlCenter.hpp"
|
||||
#include "components/button/iconButton.hpp"
|
||||
#include "components/button/tabButton.hpp"
|
||||
|
||||
|
||||
ControlCenter::ControlCenter(std::string icon, std::string name)
|
||||
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->popover->set_hexpand(false);
|
||||
this->popover->set_size_request(240, -1);
|
||||
|
||||
this->scrollview.set_child(this->container);
|
||||
this->scrollview.set_min_content_width(220);
|
||||
this->scrollview.set_max_content_width(220);
|
||||
this->scrollview.set_size_request(220, -1);
|
||||
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->container);
|
||||
set_popover_child(this->scrollview);
|
||||
|
||||
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
|
||||
this->tabRow.set_spacing(4);
|
||||
this->tabRow.set_margin_bottom(4);
|
||||
this->tabRow.add_css_class("control-center-tab-row");
|
||||
|
||||
this->mediaControl.set_label("\uf5d3"); // control icon
|
||||
this->mediaControl.add_css_class("tab-icon");
|
||||
this->testTabButton.set_label("\uE5CA"); // test icon
|
||||
this->testTabButton.add_css_class("tab-icon");
|
||||
this->mediaControl = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
|
||||
this->testTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
|
||||
|
||||
this->tabRow.append(this->mediaControl);
|
||||
this->tabRow.append(this->testTabButton);
|
||||
this->tabRow.append(*this->mediaControl);
|
||||
this->tabRow.append(*this->testTabButton);
|
||||
|
||||
this->container.append(this->tabRow);
|
||||
|
||||
this->contentStack.set_hhomogeneous(false);
|
||||
this->contentStack.set_hhomogeneous(true);
|
||||
this->contentStack.set_vhomogeneous(false);
|
||||
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
|
||||
this->contentStack.set_transition_duration(150);
|
||||
@@ -41,11 +49,11 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
|
||||
|
||||
this->container.append(this->contentStack);
|
||||
|
||||
this->mediaControl.signal_clicked().connect([this]() {
|
||||
this->mediaControl->signal_clicked().connect([this]() {
|
||||
this->setActiveTab("controls");
|
||||
});
|
||||
|
||||
this->testTabButton.signal_clicked().connect([this]() {
|
||||
this->testTabButton->signal_clicked().connect([this]() {
|
||||
this->setActiveTab("test");
|
||||
});
|
||||
|
||||
@@ -68,13 +76,13 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
|
||||
void ControlCenter::setActiveTab(const std::string &tab_name) {
|
||||
this->contentStack.set_visible_child(tab_name);
|
||||
|
||||
this->mediaControl.remove_css_class("active-button");
|
||||
this->testTabButton.remove_css_class("active-button");
|
||||
this->mediaControl->setActive(false);
|
||||
this->testTabButton->setActive(false);
|
||||
|
||||
if (tab_name == "controls") {
|
||||
this->mediaControl.add_css_class("active-button");
|
||||
this->mediaControl->setActive(true);
|
||||
} else if (tab_name == "test") {
|
||||
this->testTabButton.add_css_class("active-button");
|
||||
this->testTabButton->setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user