diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-01-22 21:14:16 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2013-01-22 21:14:16 +0100 |
| commit | ea4cc0d3ca538c523b5c1d7e24f9ac375c413ee7 (patch) | |
| tree | caf578db44b1a3edd867f2418c2a03ca37685a37 /shortcuts | |
| parent | d017a2d1b3ac40cf6098ea0adc7e75c2a241e7f1 (diff) | |
ShortcutController: use an abstract modeller to build the UI
(bzr r2919.3.52)
Diffstat (limited to 'shortcuts')
| -rw-r--r-- | shortcuts/ShortcutController.cpp | 35 | ||||
| -rw-r--r-- | shortcuts/ShortcutController.h | 7 |
2 files changed, 21 insertions, 21 deletions
diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp index 2cd09d0b8..cb2c4d8ff 100644 --- a/shortcuts/ShortcutController.cpp +++ b/shortcuts/ShortcutController.cpp @@ -18,6 +18,7 @@ */ #include "ShortcutController.h" +#include "ShortcutModel.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UScreen.h" @@ -34,8 +35,9 @@ const unsigned int SUPER_TAP_DURATION = 650; const unsigned int FADE_DURATION = 100; } -Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser, Model::Ptr const& model) - : model_(model) +Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser, + AbstractModeller::Ptr const& modeller) + : modeller_(modeller) , base_window_raiser_(base_window_raiser) , visible_(false) , enabled_(true) @@ -62,22 +64,21 @@ Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser, Model::P fade_animator_.updated.connect([this] (double opacity) { SetOpacity(opacity); }); + + modeller->model_changed.connect([this] (Model::Ptr const& model) { + if (view_) + { + if (visible_) + model->Fill(); + + view_->SetModel(model); + } + }); } Controller::~Controller() {} -void Controller::SetModel(Model::Ptr const& model) -{ - if (model == model_) - return; - - model_ = model; - - if (view_) - view_->SetModel(model_); -} - void Controller::OnBackgroundUpdate(GVariant* data) { gdouble red, green, blue, alpha; @@ -90,7 +91,7 @@ void Controller::OnBackgroundUpdate(GVariant* data) bool Controller::Show() { - if (enabled_ && model_) + if (enabled_ && modeller_->GetCurrentModel()) { show_timer_.reset(new glib::Timeout(SUPER_TAP_DURATION, sigc::mem_fun(this, &Controller::OnShowTimer))); visible_ = true; @@ -103,10 +104,10 @@ bool Controller::Show() bool Controller::OnShowTimer() { - if (!enabled_ || !model_) + if (!enabled_ || !modeller_->GetCurrentModel()) return false; - model_->Fill(); + modeller_->GetCurrentModel()->Fill(); EnsureView(); int monitor = UScreen::GetDefault()->GetMonitorWithMouse(); @@ -160,7 +161,7 @@ void Controller::ConstructView() { view_ = View::Ptr(new View()); AddChild(view_.GetPointer()); - view_->SetModel(model_); + view_->SetModel(modeller_->GetCurrentModel()); view_->background_color = bg_color_; if (!view_window_) diff --git a/shortcuts/ShortcutController.h b/shortcuts/ShortcutController.h index 07004997f..0205d94d3 100644 --- a/shortcuts/ShortcutController.h +++ b/shortcuts/ShortcutController.h @@ -30,7 +30,7 @@ #include <UnityCore/GLibSource.h> #include "BaseWindowRaiser.h" -#include "ShortcutModel.h" +#include "AbstractShortcutModeller.h" #include "ShortcutView.h" #include "unity-shared/Introspectable.h" #include "unity-shared/UBusWrapper.h" @@ -45,7 +45,7 @@ class Controller : public debug::Introspectable public: typedef std::shared_ptr<Controller> Ptr; - Controller(BaseWindowRaiser::Ptr const& raiser, Model::Ptr const& model = nullptr); + Controller(BaseWindowRaiser::Ptr const& raiser, AbstractModeller::Ptr const& modeller); virtual ~Controller(); bool Show(); @@ -54,7 +54,6 @@ public: bool Visible() const; bool IsEnabled() const; - void SetModel(Model::Ptr const& model); void SetAdjustment(int x, int y); void SetEnabled(bool enabled); virtual void SetOpacity(double value); @@ -72,7 +71,7 @@ private: bool OnShowTimer(); View::Ptr view_; - Model::Ptr model_; + AbstractModeller::Ptr modeller_; BaseWindowRaiser::Ptr base_window_raiser_; nux::Geometry workarea_; |
