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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 SkColor g_colors[] = {SK_ColorRED, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorGREEN}; | 45 SkColor g_colors[] = {SK_ColorRED, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorGREEN}; |
46 int g_color_index = 0; | 46 int g_color_index = 0; |
47 | 47 |
48 class ModalWindow : public views::WidgetDelegateView, | 48 class ModalWindow : public views::WidgetDelegateView, |
49 public views::ButtonListener { | 49 public views::ButtonListener { |
50 public: | 50 public: |
51 explicit ModalWindow(ui::ModalType modal_type) | 51 explicit ModalWindow(ui::ModalType modal_type) |
52 : modal_type_(modal_type), | 52 : modal_type_(modal_type), |
53 color_(g_colors[g_color_index]), | 53 color_(g_colors[g_color_index]), |
54 open_button_( | 54 open_button_(MdTextButton::Create(this, base::ASCIIToUTF16("Moar!"))) { |
55 MdTextButton::CreateMdButton(this, base::ASCIIToUTF16("Moar!"))) { | |
56 ++g_color_index %= arraysize(g_colors); | 55 ++g_color_index %= arraysize(g_colors); |
57 AddChildView(open_button_); | 56 AddChildView(open_button_); |
58 } | 57 } |
59 ~ModalWindow() override {} | 58 ~ModalWindow() override {} |
60 | 59 |
61 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { | 60 static void OpenModalWindow(aura::Window* parent, ui::ModalType modal_type) { |
62 views::Widget* widget = views::Widget::CreateWindowWithParent( | 61 views::Widget* widget = views::Widget::CreateWindowWithParent( |
63 new ModalWindow(modal_type), parent); | 62 new ModalWindow(modal_type), parent); |
64 widget->GetNativeView()->SetName("ModalWindow"); | 63 widget->GetNativeView()->SetName("ModalWindow"); |
65 widget->Show(); | 64 widget->Show(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 166 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
168 new WindowTypeLauncher, Shell::GetPrimaryRootWindow(), | 167 new WindowTypeLauncher, Shell::GetPrimaryRootWindow(), |
169 gfx::Rect(120, 150, 300, 410)); | 168 gfx::Rect(120, 150, 300, 410)); |
170 widget->GetNativeView()->SetName("WindowTypeLauncher"); | 169 widget->GetNativeView()->SetName("WindowTypeLauncher"); |
171 ::wm::SetShadowType(widget->GetNativeView(), ::wm::SHADOW_TYPE_RECTANGULAR); | 170 ::wm::SetShadowType(widget->GetNativeView(), ::wm::SHADOW_TYPE_RECTANGULAR); |
172 widget->Show(); | 171 widget->Show(); |
173 } | 172 } |
174 | 173 |
175 WindowTypeLauncher::WindowTypeLauncher() | 174 WindowTypeLauncher::WindowTypeLauncher() |
176 : create_button_( | 175 : create_button_( |
177 MdTextButton::CreateMdButton(this, | 176 MdTextButton::Create(this, base::ASCIIToUTF16("Create Window"))), |
178 base::ASCIIToUTF16("Create Window"))), | |
179 panel_button_( | 177 panel_button_( |
180 MdTextButton::CreateMdButton(this, | 178 MdTextButton::Create(this, base::ASCIIToUTF16("Create Panel"))), |
181 base::ASCIIToUTF16("Create Panel"))), | 179 create_nonresizable_button_(MdTextButton::Create( |
182 create_nonresizable_button_(MdTextButton::CreateMdButton( | |
183 this, | 180 this, |
184 base::ASCIIToUTF16("Create Non-Resizable Window"))), | 181 base::ASCIIToUTF16("Create Non-Resizable Window"))), |
185 bubble_button_(MdTextButton::CreateMdButton( | 182 bubble_button_( |
186 this, | 183 MdTextButton::Create(this, |
187 base::ASCIIToUTF16("Create Pointy Bubble"))), | 184 base::ASCIIToUTF16("Create Pointy Bubble"))), |
188 lock_button_( | 185 lock_button_( |
189 MdTextButton::CreateMdButton(this, | 186 MdTextButton::Create(this, base::ASCIIToUTF16("Lock Screen"))), |
190 base::ASCIIToUTF16("Lock Screen"))), | 187 widgets_button_( |
191 widgets_button_(MdTextButton::CreateMdButton( | 188 MdTextButton::Create(this, |
192 this, | 189 base::ASCIIToUTF16("Show Example Widgets"))), |
193 base::ASCIIToUTF16("Show Example Widgets"))), | 190 system_modal_button_( |
194 system_modal_button_(MdTextButton::CreateMdButton( | 191 MdTextButton::Create(this, |
195 this, | 192 base::ASCIIToUTF16("Open System Modal Window"))), |
196 base::ASCIIToUTF16("Open System Modal Window"))), | 193 window_modal_button_( |
197 window_modal_button_(MdTextButton::CreateMdButton( | 194 MdTextButton::Create(this, |
198 this, | 195 base::ASCIIToUTF16("Open Window Modal Window"))), |
199 base::ASCIIToUTF16("Open Window Modal Window"))), | 196 child_modal_button_( |
200 child_modal_button_(MdTextButton::CreateMdButton( | 197 MdTextButton::Create(this, |
201 this, | 198 base::ASCIIToUTF16("Open Child Modal Window"))), |
202 base::ASCIIToUTF16("Open Child Modal Window"))), | 199 transient_button_(MdTextButton::Create( |
203 transient_button_(MdTextButton::CreateMdButton( | |
204 this, | 200 this, |
205 base::ASCIIToUTF16("Open Non-Modal Transient Window"))), | 201 base::ASCIIToUTF16("Open Non-Modal Transient Window"))), |
206 examples_button_(MdTextButton::CreateMdButton( | 202 examples_button_(MdTextButton::Create( |
207 this, | 203 this, |
208 base::ASCIIToUTF16("Open Views Examples Window"))), | 204 base::ASCIIToUTF16("Open Views Examples Window"))), |
209 show_hide_window_button_(MdTextButton::CreateMdButton( | 205 show_hide_window_button_( |
210 this, | 206 MdTextButton::Create(this, base::ASCIIToUTF16("Show/Hide a Window"))), |
211 base::ASCIIToUTF16("Show/Hide a Window"))), | 207 show_web_notification_(MdTextButton::Create( |
212 show_web_notification_(MdTextButton::CreateMdButton( | |
213 this, | 208 this, |
214 base::ASCIIToUTF16("Show a web/app notification"))) { | 209 base::ASCIIToUTF16("Show a web/app notification"))) { |
215 views::GridLayout* layout = new views::GridLayout(this); | 210 views::GridLayout* layout = new views::GridLayout(this); |
216 layout->SetInsets(5, 5, 5, 5); | 211 layout->SetInsets(5, 5, 5, 5); |
217 SetLayoutManager(layout); | 212 SetLayoutManager(layout); |
218 views::ColumnSet* column_set = layout->AddColumnSet(0); | 213 views::ColumnSet* column_set = layout->AddColumnSet(0); |
219 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 214 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
220 0, views::GridLayout::USE_PREF, 0, 0); | 215 0, views::GridLayout::USE_PREF, 0, 0); |
221 AddViewToLayout(layout, create_button_); | 216 AddViewToLayout(layout, create_button_); |
222 AddViewToLayout(layout, panel_button_); | 217 AddViewToLayout(layout, panel_button_); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 views::MenuRunner::ASYNC)); | 341 views::MenuRunner::ASYNC)); |
347 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 342 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
348 views::MENU_ANCHOR_TOPLEFT, | 343 views::MENU_ANCHOR_TOPLEFT, |
349 source_type) == MenuRunner::MENU_DELETED) { | 344 source_type) == MenuRunner::MENU_DELETED) { |
350 return; | 345 return; |
351 } | 346 } |
352 } | 347 } |
353 | 348 |
354 } // namespace shell | 349 } // namespace shell |
355 } // namespace ash | 350 } // namespace ash |
OLD | NEW |