Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/shell/window_type_launcher.h" | 5 #include "ash/shell/window_type_launcher.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/screensaver/screensaver_view.h" | 8 #include "ash/screensaver/screensaver_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell/example_factory.h" | 10 #include "ash/shell/example_factory.h" |
| 11 #include "ash/shell/panel_window.h" | 11 #include "ash/shell/panel_window.h" |
| 12 #include "ash/shell/toplevel_window.h" | 12 #include "ash/shell/toplevel_window.h" |
| 13 #include "ash/shell_delegate.h" | 13 #include "ash/shell_delegate.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/system/web_notification/web_notification_tray.h" | 16 #include "ash/system/web_notification/web_notification_tray.h" |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "ui/aura/root_window.h" | 21 #include "ui/aura/root_window.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
| 24 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 25 #include "ui/message_center/notification_types.h" | 25 #include "ui/message_center/notification_types.h" |
| 26 #include "ui/views/controls/button/text_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
| 27 #include "ui/views/controls/menu/menu_item_view.h" | 27 #include "ui/views/controls/menu/menu_item_view.h" |
| 28 #include "ui/views/controls/menu/menu_runner.h" | 28 #include "ui/views/controls/menu/menu_runner.h" |
| 29 #include "ui/views/corewm/shadow_types.h" | 29 #include "ui/views/corewm/shadow_types.h" |
| 30 #include "ui/views/examples/examples_window_with_content.h" | 30 #include "ui/views/examples/examples_window_with_content.h" |
| 31 #include "ui/views/layout/grid_layout.h" | 31 #include "ui/views/layout/grid_layout.h" |
| 32 #include "ui/views/test/child_modal_window.h" | 32 #include "ui/views/test/child_modal_window.h" |
| 33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 34 | 34 |
| 35 using views::MenuItemView; | 35 using views::MenuItemView; |
| 36 using views::MenuRunner; | 36 using views::MenuRunner; |
| 37 | 37 |
| 38 namespace ash { | 38 namespace ash { |
| 39 namespace shell { | 39 namespace shell { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 SkColor g_colors[] = { SK_ColorRED, | 43 SkColor g_colors[] = { SK_ColorRED, |
| 44 SK_ColorYELLOW, | 44 SK_ColorYELLOW, |
| 45 SK_ColorBLUE, | 45 SK_ColorBLUE, |
| 46 SK_ColorGREEN }; | 46 SK_ColorGREEN }; |
| 47 int g_color_index = 0; | 47 int g_color_index = 0; |
| 48 | 48 |
| 49 class ModalWindow : public views::WidgetDelegateView, | 49 class ModalWindow : public views::WidgetDelegateView, |
| 50 public views::ButtonListener { | 50 public views::ButtonListener { |
| 51 public: | 51 public: |
| 52 explicit ModalWindow(ui::ModalType modal_type) | 52 explicit ModalWindow(ui::ModalType modal_type) |
| 53 : modal_type_(modal_type), | 53 : modal_type_(modal_type), |
| 54 color_(g_colors[g_color_index]), | 54 color_(g_colors[g_color_index]), |
| 55 ALLOW_THIS_IN_INITIALIZER_LIST(open_button_( | 55 ALLOW_THIS_IN_INITIALIZER_LIST(open_button_( |
| 56 new views::NativeTextButton(this, ASCIIToUTF16("Moar!")))) { | 56 new views::LabelButton(this, ASCIIToUTF16("Moar!")))) { |
|
msw
2013/03/03 04:38:36
You need to set the native style on this button.
tfarina
2013/03/03 21:38:26
Done.
| |
| 57 ++g_color_index %= arraysize(g_colors); | 57 ++g_color_index %= arraysize(g_colors); |
| 58 AddChildView(open_button_); | 58 AddChildView(open_button_); |
| 59 } | 59 } |
| 60 virtual ~ModalWindow() { | 60 virtual ~ModalWindow() { |
| 61 } | 61 } |
| 62 | 62 |
| 63 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { | 63 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { |
| 64 views::Widget* widget = | 64 views::Widget* widget = |
| 65 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type), | 65 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type), |
| 66 parent); | 66 parent); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 // Overridden from views::ButtonListener: | 100 // Overridden from views::ButtonListener: |
| 101 virtual void ButtonPressed(views::Button* sender, | 101 virtual void ButtonPressed(views::Button* sender, |
| 102 const ui::Event& event) OVERRIDE { | 102 const ui::Event& event) OVERRIDE { |
| 103 DCHECK(sender == open_button_); | 103 DCHECK(sender == open_button_); |
| 104 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_); | 104 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 ui::ModalType modal_type_; | 108 ui::ModalType modal_type_; |
| 109 SkColor color_; | 109 SkColor color_; |
| 110 views::NativeTextButton* open_button_; | 110 views::LabelButton* open_button_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(ModalWindow); | 112 DISALLOW_COPY_AND_ASSIGN(ModalWindow); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class NonModalTransient : public views::WidgetDelegateView { | 115 class NonModalTransient : public views::WidgetDelegateView { |
| 116 public: | 116 public: |
| 117 NonModalTransient() | 117 NonModalTransient() |
| 118 : color_(g_colors[g_color_index]) { | 118 : color_(g_colors[g_color_index]) { |
| 119 ++g_color_index %= arraysize(g_colors); | 119 ++g_color_index %= arraysize(g_colors); |
| 120 } | 120 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 Shell::GetPrimaryRootWindow(), | 191 Shell::GetPrimaryRootWindow(), |
| 192 gfx::Rect(120, 150, 300, 410)); | 192 gfx::Rect(120, 150, 300, 410)); |
| 193 widget->GetNativeView()->SetName("WindowTypeLauncher"); | 193 widget->GetNativeView()->SetName("WindowTypeLauncher"); |
| 194 views::corewm::SetShadowType(widget->GetNativeView(), | 194 views::corewm::SetShadowType(widget->GetNativeView(), |
| 195 views::corewm::SHADOW_TYPE_RECTANGULAR); | 195 views::corewm::SHADOW_TYPE_RECTANGULAR); |
| 196 widget->Show(); | 196 widget->Show(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 WindowTypeLauncher::WindowTypeLauncher() | 199 WindowTypeLauncher::WindowTypeLauncher() |
| 200 : ALLOW_THIS_IN_INITIALIZER_LIST(create_button_( | 200 : ALLOW_THIS_IN_INITIALIZER_LIST(create_button_( |
| 201 new views::NativeTextButton(this, ASCIIToUTF16("Create Window")))), | 201 new views::LabelButton(this, ASCIIToUTF16("Create Window")))), |
| 202 ALLOW_THIS_IN_INITIALIZER_LIST(create_persistant_button_( | 202 ALLOW_THIS_IN_INITIALIZER_LIST(create_persistant_button_( |
| 203 new views::NativeTextButton( | 203 new views::LabelButton( |
| 204 this, ASCIIToUTF16("Create Persistant Window")))), | 204 this, ASCIIToUTF16("Create Persistant Window")))), |
| 205 ALLOW_THIS_IN_INITIALIZER_LIST(panel_button_( | 205 ALLOW_THIS_IN_INITIALIZER_LIST(panel_button_( |
| 206 new views::NativeTextButton(this, ASCIIToUTF16("Create Panel")))), | 206 new views::LabelButton(this, ASCIIToUTF16("Create Panel")))), |
| 207 ALLOW_THIS_IN_INITIALIZER_LIST(create_nonresizable_button_( | 207 ALLOW_THIS_IN_INITIALIZER_LIST(create_nonresizable_button_( |
| 208 new views::NativeTextButton( | 208 new views::LabelButton( |
| 209 this, ASCIIToUTF16("Create Non-Resizable Window")))), | 209 this, ASCIIToUTF16("Create Non-Resizable Window")))), |
| 210 ALLOW_THIS_IN_INITIALIZER_LIST(bubble_button_( | 210 ALLOW_THIS_IN_INITIALIZER_LIST(bubble_button_( |
| 211 new views::NativeTextButton( | 211 new views::LabelButton( |
| 212 this, ASCIIToUTF16("Create Pointy Bubble")))), | 212 this, ASCIIToUTF16("Create Pointy Bubble")))), |
| 213 ALLOW_THIS_IN_INITIALIZER_LIST(lock_button_( | 213 ALLOW_THIS_IN_INITIALIZER_LIST(lock_button_( |
| 214 new views::NativeTextButton(this, ASCIIToUTF16("Lock Screen")))), | 214 new views::LabelButton(this, ASCIIToUTF16("Lock Screen")))), |
| 215 ALLOW_THIS_IN_INITIALIZER_LIST(widgets_button_( | 215 ALLOW_THIS_IN_INITIALIZER_LIST(widgets_button_( |
| 216 new views::NativeTextButton( | 216 new views::LabelButton( |
| 217 this, ASCIIToUTF16("Show Example Widgets")))), | 217 this, ASCIIToUTF16("Show Example Widgets")))), |
| 218 ALLOW_THIS_IN_INITIALIZER_LIST(system_modal_button_( | 218 ALLOW_THIS_IN_INITIALIZER_LIST(system_modal_button_( |
| 219 new views::NativeTextButton( | 219 new views::LabelButton( |
| 220 this, ASCIIToUTF16("Open System Modal Window")))), | 220 this, ASCIIToUTF16("Open System Modal Window")))), |
| 221 ALLOW_THIS_IN_INITIALIZER_LIST(window_modal_button_( | 221 ALLOW_THIS_IN_INITIALIZER_LIST(window_modal_button_( |
| 222 new views::NativeTextButton( | 222 new views::LabelButton( |
| 223 this, ASCIIToUTF16("Open Window Modal Window")))), | 223 this, ASCIIToUTF16("Open Window Modal Window")))), |
| 224 ALLOW_THIS_IN_INITIALIZER_LIST(child_modal_button_( | 224 ALLOW_THIS_IN_INITIALIZER_LIST(child_modal_button_( |
| 225 new views::NativeTextButton( | 225 new views::LabelButton( |
| 226 this, ASCIIToUTF16("Open Child Modal Window")))), | 226 this, ASCIIToUTF16("Open Child Modal Window")))), |
| 227 ALLOW_THIS_IN_INITIALIZER_LIST(transient_button_( | 227 ALLOW_THIS_IN_INITIALIZER_LIST(transient_button_( |
| 228 new views::NativeTextButton( | 228 new views::LabelButton( |
| 229 this, ASCIIToUTF16("Open Non-Modal Transient Window")))), | 229 this, ASCIIToUTF16("Open Non-Modal Transient Window")))), |
| 230 ALLOW_THIS_IN_INITIALIZER_LIST(examples_button_( | 230 ALLOW_THIS_IN_INITIALIZER_LIST(examples_button_( |
| 231 new views::NativeTextButton( | 231 new views::LabelButton( |
| 232 this, ASCIIToUTF16("Open Views Examples Window")))), | 232 this, ASCIIToUTF16("Open Views Examples Window")))), |
| 233 ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( | 233 ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( |
| 234 new views::NativeTextButton( | 234 new views::LabelButton( |
| 235 this, ASCIIToUTF16("Show/Hide a Window")))), | 235 this, ASCIIToUTF16("Show/Hide a Window")))), |
| 236 ALLOW_THIS_IN_INITIALIZER_LIST(show_screensaver_( | 236 ALLOW_THIS_IN_INITIALIZER_LIST(show_screensaver_( |
| 237 new views::NativeTextButton( | 237 new views::LabelButton( |
| 238 this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]")))), | 238 this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]")))), |
| 239 ALLOW_THIS_IN_INITIALIZER_LIST(show_web_notification_( | 239 ALLOW_THIS_IN_INITIALIZER_LIST(show_web_notification_( |
| 240 new views::NativeTextButton( | 240 new views::LabelButton( |
| 241 this, ASCIIToUTF16("Show a web/app notification")))) { | 241 this, ASCIIToUTF16("Show a web/app notification")))) { |
| 242 create_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 243 create_persistant_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 244 panel_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 245 create_nonresizable_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 246 bubble_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 247 lock_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 248 widgets_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 249 system_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 250 window_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 251 child_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 252 transient_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 253 examples_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 254 show_hide_window_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 255 show_screensaver_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 256 show_web_notification_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | |
| 257 | |
| 242 views::GridLayout* layout = new views::GridLayout(this); | 258 views::GridLayout* layout = new views::GridLayout(this); |
| 243 layout->SetInsets(5, 5, 5, 5); | 259 layout->SetInsets(5, 5, 5, 5); |
| 244 SetLayoutManager(layout); | 260 SetLayoutManager(layout); |
| 245 views::ColumnSet* column_set = layout->AddColumnSet(0); | 261 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 246 column_set->AddColumn(views::GridLayout::LEADING, | 262 column_set->AddColumn(views::GridLayout::LEADING, |
| 247 views::GridLayout::CENTER, | 263 views::GridLayout::CENTER, |
| 248 0, | 264 0, |
| 249 views::GridLayout::USE_PREF, | 265 views::GridLayout::USE_PREF, |
| 250 0, | 266 0, |
| 251 0); | 267 0); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 406 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
| 391 MenuItemView::TOPLEFT, | 407 MenuItemView::TOPLEFT, |
| 392 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 408 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
| 393 MenuRunner::MENU_DELETED) | 409 MenuRunner::MENU_DELETED) |
| 394 return; | 410 return; |
| 395 } | 411 } |
| 396 #endif // !defined(OS_MACOSX) | 412 #endif // !defined(OS_MACOSX) |
| 397 | 413 |
| 398 } // namespace shell | 414 } // namespace shell |
| 399 } // namespace ash | 415 } // namespace ash |
| OLD | NEW |