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

Unified Diff: mojo/examples/window_manager/debug_panel.cc

Issue 684543003: Move //mojo/examples to //examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « mojo/examples/window_manager/debug_panel.h ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/window_manager/debug_panel.cc
diff --git a/mojo/examples/window_manager/debug_panel.cc b/mojo/examples/window_manager/debug_panel.cc
deleted file mode 100644
index 643155b66f41e0bf23afacdc10f74a53d3d824e4..0000000000000000000000000000000000000000
--- a/mojo/examples/window_manager/debug_panel.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/examples/window_manager/debug_panel.h"
-
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "mojo/services/public/cpp/view_manager/view.h"
-#include "mojo/views/native_widget_view_manager.h"
-#include "ui/gfx/text_constants.h"
-#include "ui/views/background.h"
-#include "ui/views/controls/button/blue_button.h"
-#include "ui/views/controls/button/radio_button.h"
-#include "ui/views/widget/widget.h"
-
-namespace mojo {
-namespace examples {
-
-namespace {
-
-const int kControlBorderInset = 5;
-const int kNavigationTargetGroupId = 1;
-
-} // namespace
-
-DebugPanel::DebugPanel(Delegate* delegate, Shell* shell, View* view)
- : delegate_(delegate),
- view_(view),
- navigation_target_label_(
- new views::Label(base::ASCIIToUTF16("Navigation target:"))),
- navigation_target_new_(
- new views::RadioButton(base::ASCIIToUTF16("New window"),
- kNavigationTargetGroupId)),
- navigation_target_source_(
- new views::RadioButton(base::ASCIIToUTF16("Source window"),
- kNavigationTargetGroupId)),
- navigation_target_default_(
- new views::RadioButton(base::ASCIIToUTF16("Default"),
- kNavigationTargetGroupId)),
- colored_square_(
- new views::BlueButton(this, base::ASCIIToUTF16("Local nav test"))),
- close_last_(
- new views::BlueButton(this, base::ASCIIToUTF16("Close last window"))),
- cross_app_(
- new views::BlueButton(this,
- base::ASCIIToUTF16("Cross-app nav test"))) {
- navigation_target_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- navigation_target_default_->SetChecked(true);
-
- views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView();
- widget_delegate->GetContentsView()->set_background(
- views::Background::CreateSolidBackground(0xFFDDDDDD));
- widget_delegate->GetContentsView()->AddChildView(navigation_target_label_);
- widget_delegate->GetContentsView()->AddChildView(navigation_target_default_);
- widget_delegate->GetContentsView()->AddChildView(navigation_target_new_);
- widget_delegate->GetContentsView()->AddChildView(navigation_target_source_);
- widget_delegate->GetContentsView()->AddChildView(colored_square_);
- widget_delegate->GetContentsView()->AddChildView(close_last_);
- widget_delegate->GetContentsView()->AddChildView(cross_app_);
- widget_delegate->GetContentsView()->SetLayoutManager(this);
-
- views::Widget* widget = new views::Widget();
- views::Widget::InitParams params(
- views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- params.native_widget = new NativeWidgetViewManager(widget, shell, view);
- params.delegate = widget_delegate;
- params.bounds = gfx::Rect(0, 0, view->bounds().width, view->bounds().height);
- widget->Init(params);
- widget->Show();
-}
-
-DebugPanel::~DebugPanel() {
-}
-
-gfx::Size DebugPanel::GetPreferredSize(const views::View* view) const {
- return gfx::Size();
-}
-
-Target DebugPanel::navigation_target() const {
- if (navigation_target_new_->checked())
- return TARGET_NEW_NODE;
- if (navigation_target_source_->checked())
- return TARGET_SOURCE_NODE;
- return TARGET_DEFAULT;
-}
-
-void DebugPanel::Layout(views::View* view) {
- int y = kControlBorderInset;
- int w = view->width() - kControlBorderInset * 2;
-
- navigation_target_label_->SetBounds(
- kControlBorderInset, y, w,
- navigation_target_label_->GetPreferredSize().height());
- y += navigation_target_label_->height();
-
- views::RadioButton* radios[] = {
- navigation_target_default_,
- navigation_target_new_,
- navigation_target_source_,
- };
- for (size_t i = 0; i < arraysize(radios); ++i) {
- radios[i]->SetBounds(kControlBorderInset, y, w,
- radios[i]->GetPreferredSize().height());
- y += radios[i]->height();
- }
-
- y += kControlBorderInset;
- views::Button* buttons[] = {
- colored_square_,
- close_last_,
- cross_app_,
- };
- for (size_t i = 0; i < arraysize(buttons); ++i) {
- buttons[i]->SetBounds(kControlBorderInset, y, w,
- buttons[i]->GetPreferredSize().height());
- y += buttons[i]->height();
- }
-}
-
-void DebugPanel::ButtonPressed(views::Button* sender, const ui::Event& event) {
- if (sender == colored_square_) {
- Navigate("mojo://embedded_app/");
- } else if (sender == close_last_) {
- delegate_->CloseTopWindow();
- } else if (sender == cross_app_) {
- Navigate("http://www.aaronboodman.com/z_dropbox/test.html");
- }
-}
-
-void DebugPanel::Navigate(const std::string& url) {
- URLRequestPtr request(URLRequest::New());
- request->url = url;
- delegate_->RequestNavigate(view_->id(), TARGET_NEW_NODE, request.Pass());
-}
-
-} // namespace examples
-} // namespace mojo
« no previous file with comments | « mojo/examples/window_manager/debug_panel.h ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698