#include #include #include #include #include #include #include #include #include "strings.hpp" #include "config.hpp" #include "core_window.hpp" #include "lights_list.hpp" #include "light_adder.hpp" #include "welcome.hpp" #include "control.hpp" #include "editor.hpp" namespace cx_light { core_window::core_window() { this->current_visible = NULL; this->set_title(__(WINDOW_TITLE)); this->set_default_size(600, 200); this->init_default(); } core_window::~core_window() { delete this->center; delete this->current; delete this->lights; delete this->current_frame; if (this->current_visible != NULL) { delete this->current_visible; } } void core_window::init_default() { this->center = new Gtk::Box(); this->center->set_orientation(Gtk::Orientation::HORIZONTAL); this->set_child(*this->center); this->current = new Gtk::Box(); this->current->set_margin(DEFAULT_MARGIN); this->current_frame = new Gtk::Frame(); this->current_frame->set_margin(DEFAULT_MARGIN); this->current_frame->set_child(*this->current); this->create_lights_list(); this->center->append(*this->current_frame); this->set_view(new welcome()); } void core_window::create_lights_list() { this->lights = new lights_list(); this->center->append(*this->lights); this->lights->set_add_light_callback([&] () { this->set_view(new light_adder()); }); this->lights->set_edit_light_callback([&] (light *target) { this->set_view(new editor(target)); }); this->lights->set_show_light_callback([&] (light *target) { this->set_view(new control(target)); }); } void core_window::set_view(Gtk::Widget *target) { if (this->current_visible != NULL) { this->current->remove(*this->current_visible); delete this->current_visible; } this->current_visible = target; this->current->append(*target); } }