| 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/session_state_delegate.h" | 9 #include "ash/session_state_delegate.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 SK_ColorBLUE, | 47 SK_ColorBLUE, |
| 48 SK_ColorGREEN }; | 48 SK_ColorGREEN }; |
| 49 int g_color_index = 0; | 49 int g_color_index = 0; |
| 50 | 50 |
| 51 class ModalWindow : public views::WidgetDelegateView, | 51 class ModalWindow : public views::WidgetDelegateView, |
| 52 public views::ButtonListener { | 52 public views::ButtonListener { |
| 53 public: | 53 public: |
| 54 explicit ModalWindow(ui::ModalType modal_type) | 54 explicit ModalWindow(ui::ModalType modal_type) |
| 55 : modal_type_(modal_type), | 55 : modal_type_(modal_type), |
| 56 color_(g_colors[g_color_index]), | 56 color_(g_colors[g_color_index]), |
| 57 ALLOW_THIS_IN_INITIALIZER_LIST(open_button_( | 57 open_button_(new views::LabelButton(this, ASCIIToUTF16("Moar!"))) { |
| 58 new views::LabelButton(this, ASCIIToUTF16("Moar!")))) { | |
| 59 ++g_color_index %= arraysize(g_colors); | 58 ++g_color_index %= arraysize(g_colors); |
| 60 open_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 59 open_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 61 AddChildView(open_button_); | 60 AddChildView(open_button_); |
| 62 } | 61 } |
| 63 virtual ~ModalWindow() { | 62 virtual ~ModalWindow() { |
| 64 } | 63 } |
| 65 | 64 |
| 66 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { | 65 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { |
| 67 views::Widget* widget = | 66 views::Widget* widget = |
| 68 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type), | 67 views::Widget::CreateWindowWithParent(new ModalWindow(modal_type), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 new WindowTypeLauncher, | 192 new WindowTypeLauncher, |
| 194 Shell::GetPrimaryRootWindow(), | 193 Shell::GetPrimaryRootWindow(), |
| 195 gfx::Rect(120, 150, 300, 410)); | 194 gfx::Rect(120, 150, 300, 410)); |
| 196 widget->GetNativeView()->SetName("WindowTypeLauncher"); | 195 widget->GetNativeView()->SetName("WindowTypeLauncher"); |
| 197 views::corewm::SetShadowType(widget->GetNativeView(), | 196 views::corewm::SetShadowType(widget->GetNativeView(), |
| 198 views::corewm::SHADOW_TYPE_RECTANGULAR); | 197 views::corewm::SHADOW_TYPE_RECTANGULAR); |
| 199 widget->Show(); | 198 widget->Show(); |
| 200 } | 199 } |
| 201 | 200 |
| 202 WindowTypeLauncher::WindowTypeLauncher() | 201 WindowTypeLauncher::WindowTypeLauncher() |
| 203 : ALLOW_THIS_IN_INITIALIZER_LIST(create_button_( | 202 : create_button_( |
| 204 new views::LabelButton(this, ASCIIToUTF16("Create Window")))), | 203 new views::LabelButton(this, ASCIIToUTF16("Create Window"))), |
| 205 ALLOW_THIS_IN_INITIALIZER_LIST(create_persistant_button_( | 204 create_persistant_button_( |
| 206 new views::LabelButton( | 205 new views::LabelButton( |
| 207 this, ASCIIToUTF16("Create Persistant Window")))), | 206 this, ASCIIToUTF16("Create Persistant Window"))), |
| 208 ALLOW_THIS_IN_INITIALIZER_LIST(panel_button_( | 207 panel_button_( |
| 209 new views::LabelButton(this, ASCIIToUTF16("Create Panel")))), | 208 new views::LabelButton(this, ASCIIToUTF16("Create Panel"))), |
| 210 ALLOW_THIS_IN_INITIALIZER_LIST(create_nonresizable_button_( | 209 create_nonresizable_button_( |
| 211 new views::LabelButton( | 210 new views::LabelButton( |
| 212 this, ASCIIToUTF16("Create Non-Resizable Window")))), | 211 this, ASCIIToUTF16("Create Non-Resizable Window"))), |
| 213 ALLOW_THIS_IN_INITIALIZER_LIST(bubble_button_( | 212 bubble_button_( |
| 214 new views::LabelButton( | 213 new views::LabelButton( |
| 215 this, ASCIIToUTF16("Create Pointy Bubble")))), | 214 this, ASCIIToUTF16("Create Pointy Bubble"))), |
| 216 ALLOW_THIS_IN_INITIALIZER_LIST(lock_button_( | 215 lock_button_( |
| 217 new views::LabelButton(this, ASCIIToUTF16("Lock Screen")))), | 216 new views::LabelButton(this, ASCIIToUTF16("Lock Screen"))), |
| 218 ALLOW_THIS_IN_INITIALIZER_LIST(widgets_button_( | 217 widgets_button_( |
| 219 new views::LabelButton( | 218 new views::LabelButton( |
| 220 this, ASCIIToUTF16("Show Example Widgets")))), | 219 this, ASCIIToUTF16("Show Example Widgets"))), |
| 221 ALLOW_THIS_IN_INITIALIZER_LIST(system_modal_button_( | 220 system_modal_button_( |
| 222 new views::LabelButton( | 221 new views::LabelButton( |
| 223 this, ASCIIToUTF16("Open System Modal Window")))), | 222 this, ASCIIToUTF16("Open System Modal Window"))), |
| 224 ALLOW_THIS_IN_INITIALIZER_LIST(window_modal_button_( | 223 window_modal_button_( |
| 225 new views::LabelButton( | 224 new views::LabelButton( |
| 226 this, ASCIIToUTF16("Open Window Modal Window")))), | 225 this, ASCIIToUTF16("Open Window Modal Window"))), |
| 227 ALLOW_THIS_IN_INITIALIZER_LIST(child_modal_button_( | 226 child_modal_button_( |
| 228 new views::LabelButton( | 227 new views::LabelButton( |
| 229 this, ASCIIToUTF16("Open Child Modal Window")))), | 228 this, ASCIIToUTF16("Open Child Modal Window"))), |
| 230 ALLOW_THIS_IN_INITIALIZER_LIST(transient_button_( | 229 transient_button_( |
| 231 new views::LabelButton( | 230 new views::LabelButton( |
| 232 this, ASCIIToUTF16("Open Non-Modal Transient Window")))), | 231 this, ASCIIToUTF16("Open Non-Modal Transient Window"))), |
| 233 ALLOW_THIS_IN_INITIALIZER_LIST(examples_button_( | 232 examples_button_( |
| 234 new views::LabelButton( | 233 new views::LabelButton( |
| 235 this, ASCIIToUTF16("Open Views Examples Window")))), | 234 this, ASCIIToUTF16("Open Views Examples Window"))), |
| 236 ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( | 235 show_hide_window_button_( |
| 237 new views::LabelButton( | 236 new views::LabelButton( |
| 238 this, ASCIIToUTF16("Show/Hide a Window")))), | 237 this, ASCIIToUTF16("Show/Hide a Window"))), |
| 239 ALLOW_THIS_IN_INITIALIZER_LIST(show_screensaver_( | 238 show_screensaver_( |
| 240 new views::LabelButton( | 239 new views::LabelButton( |
| 241 this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]")))), | 240 this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]"))), |
| 242 ALLOW_THIS_IN_INITIALIZER_LIST(show_web_notification_( | 241 show_web_notification_( |
| 243 new views::LabelButton( | 242 new views::LabelButton( |
| 244 this, ASCIIToUTF16("Show a web/app notification")))) { | 243 this, ASCIIToUTF16("Show a web/app notification"))) { |
| 245 create_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 244 create_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 246 create_persistant_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 245 create_persistant_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 247 panel_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 246 panel_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 248 create_nonresizable_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 247 create_nonresizable_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 249 bubble_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 248 bubble_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 250 lock_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 249 lock_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 251 widgets_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 250 widgets_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 252 system_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 251 system_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 253 window_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 252 window_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 254 child_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 253 child_modal_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 408 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
| 410 MenuItemView::TOPLEFT, | 409 MenuItemView::TOPLEFT, |
| 411 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 410 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
| 412 MenuRunner::MENU_DELETED) | 411 MenuRunner::MENU_DELETED) |
| 413 return; | 412 return; |
| 414 } | 413 } |
| 415 #endif // !defined(OS_MACOSX) | 414 #endif // !defined(OS_MACOSX) |
| 416 | 415 |
| 417 } // namespace shell | 416 } // namespace shell |
| 418 } // namespace ash | 417 } // namespace ash |
| OLD | NEW |