Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: examples/wm_flow/wm/frame_controller.cc

Issue 805123003: Adds capture to the mojo window_manager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sky comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: examples/wm_flow/wm/frame_controller.cc
diff --git a/examples/wm_flow/wm/frame_controller.cc b/examples/wm_flow/wm/frame_controller.cc
index e391f421efed1f25b90b9425733f8d9eedafb7be..acf608c92a7e8111d0f7cad7abcccd10aa771896 100644
--- a/examples/wm_flow/wm/frame_controller.cc
+++ b/examples/wm_flow/wm/frame_controller.cc
@@ -9,8 +9,10 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/services/view_manager/public/cpp/view.h"
#include "mojo/views/native_widget_mojo.h"
+#include "services/window_manager/capture_controller.h"
#include "services/window_manager/window_manager_app.h"
#include "ui/views/background.h"
+#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/widget/widget.h"
@@ -21,10 +23,14 @@ class FrameController::LayoutManager : public views::LayoutManager,
public:
explicit LayoutManager(FrameController* controller)
: controller_(controller),
+ capture_checkbox_(
+ new views::Checkbox(base::ASCIIToUTF16("Capture"))),
close_button_(
new views::LabelButton(this, base::ASCIIToUTF16("Begone"))),
maximize_button_(
- new views::LabelButton(this, base::ASCIIToUTF16("Embiggen"))) {}
+ new views::LabelButton(this, base::ASCIIToUTF16("Embiggen"))) {
+ capture_checkbox_->set_listener(this);
+ }
virtual ~LayoutManager() {}
private:
@@ -34,11 +40,16 @@ class FrameController::LayoutManager : public views::LayoutManager,
// Overridden from views::LayoutManager:
virtual void Installed(views::View* host) override {
+ host->AddChildView(capture_checkbox_);
host->AddChildView(close_button_);
host->AddChildView(maximize_button_);
}
virtual void Layout(views::View* host) override {
- gfx::Size ps = close_button_->GetPreferredSize();
+ gfx::Size ps = capture_checkbox_->GetPreferredSize();
+ capture_checkbox_->SetBounds(kButtonFrameMargin, kButtonFrameMargin,
+ ps.width(), ps.height());
+
+ ps = close_button_->GetPreferredSize();
gfx::Rect bounds = host->GetLocalBounds();
close_button_->SetBounds(bounds.right() - kButtonFrameMargin - ps.width(),
kButtonFrameMargin, ps.width(), ps.height());
@@ -64,9 +75,12 @@ class FrameController::LayoutManager : public views::LayoutManager,
controller_->CloseWindow();
else if (sender == maximize_button_)
controller_->ToggleMaximize();
+ else if (sender == capture_checkbox_)
+ controller_->SetCapture(capture_checkbox_->checked());
}
FrameController* controller_;
+ views::Checkbox* capture_checkbox_;
views::Button* close_button_;
views::Button* maximize_button_;
@@ -146,6 +160,13 @@ void FrameController::ActivateWindow() {
window_manager_app_->focus_controller()->ActivateView(view_);
}
+void FrameController::SetCapture(bool frame_has_capture) {
+ if (frame_has_capture)
+ window_manager_app_->capture_controller()->SetCapture(view_);
+ else
+ window_manager_app_->capture_controller()->ReleaseCapture(view_);
+}
+
////////////////////////////////////////////////////////////////////////////////
// FrameController, mojo::ViewObserver implementation:
« no previous file with comments | « examples/wm_flow/wm/frame_controller.h ('k') | mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698