| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); } | 71 gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); } |
| 72 void Layout() override { | 72 void Layout() override { |
| 73 gfx::Size open_ps = open_button_->GetPreferredSize(); | 73 gfx::Size open_ps = open_button_->GetPreferredSize(); |
| 74 gfx::Rect local_bounds = GetLocalBounds(); | 74 gfx::Rect local_bounds = GetLocalBounds(); |
| 75 open_button_->SetBounds(5, local_bounds.bottom() - open_ps.height() - 5, | 75 open_button_->SetBounds(5, local_bounds.bottom() - open_ps.height() - 5, |
| 76 open_ps.width(), open_ps.height()); | 76 open_ps.width(), open_ps.height()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Overridden from views::WidgetDelegate: | 79 // Overridden from views::WidgetDelegate: |
| 80 views::View* GetContentsView() override { return this; } | |
| 81 bool CanResize() const override { return true; } | 80 bool CanResize() const override { return true; } |
| 82 base::string16 GetWindowTitle() const override { | 81 base::string16 GetWindowTitle() const override { |
| 83 return base::ASCIIToUTF16("Modal Window"); | 82 return base::ASCIIToUTF16("Modal Window"); |
| 84 } | 83 } |
| 85 ui::ModalType GetModalType() const override { return modal_type_; } | 84 ui::ModalType GetModalType() const override { return modal_type_; } |
| 86 | 85 |
| 87 // Overridden from views::ButtonListener: | 86 // Overridden from views::ButtonListener: |
| 88 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 87 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 89 DCHECK(sender == open_button_); | 88 DCHECK(sender == open_button_); |
| 90 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_); | 89 OpenModalWindow(GetWidget()->GetNativeView(), modal_type_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 non_modal_transient_->Show(); | 123 non_modal_transient_->Show(); |
| 125 } | 124 } |
| 126 | 125 |
| 127 // Overridden from views::View: | 126 // Overridden from views::View: |
| 128 void OnPaint(gfx::Canvas* canvas) override { | 127 void OnPaint(gfx::Canvas* canvas) override { |
| 129 canvas->FillRect(GetLocalBounds(), color_); | 128 canvas->FillRect(GetLocalBounds(), color_); |
| 130 } | 129 } |
| 131 gfx::Size GetPreferredSize() const override { return gfx::Size(250, 250); } | 130 gfx::Size GetPreferredSize() const override { return gfx::Size(250, 250); } |
| 132 | 131 |
| 133 // Overridden from views::WidgetDelegate: | 132 // Overridden from views::WidgetDelegate: |
| 134 views::View* GetContentsView() override { return this; } | |
| 135 bool CanResize() const override { return true; } | 133 bool CanResize() const override { return true; } |
| 136 base::string16 GetWindowTitle() const override { | 134 base::string16 GetWindowTitle() const override { |
| 137 return base::ASCIIToUTF16("Non-Modal Transient"); | 135 return base::ASCIIToUTF16("Non-Modal Transient"); |
| 138 } | 136 } |
| 139 void DeleteDelegate() override { | 137 void DeleteDelegate() override { |
| 140 if (GetWidget() == non_modal_transient_) | 138 if (GetWidget() == non_modal_transient_) |
| 141 non_modal_transient_ = NULL; | 139 non_modal_transient_ = NULL; |
| 142 | 140 |
| 143 delete this; | 141 delete this; |
| 144 } | 142 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 231 |
| 234 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { | 232 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { |
| 235 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 233 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
| 236 } | 234 } |
| 237 | 235 |
| 238 bool WindowTypeLauncher::OnMousePressed(const ui::MouseEvent& event) { | 236 bool WindowTypeLauncher::OnMousePressed(const ui::MouseEvent& event) { |
| 239 // Overridden so we get OnMouseReleased and can show the context menu. | 237 // Overridden so we get OnMouseReleased and can show the context menu. |
| 240 return true; | 238 return true; |
| 241 } | 239 } |
| 242 | 240 |
| 243 views::View* WindowTypeLauncher::GetContentsView() { | |
| 244 return this; | |
| 245 } | |
| 246 | |
| 247 bool WindowTypeLauncher::CanResize() const { | 241 bool WindowTypeLauncher::CanResize() const { |
| 248 return true; | 242 return true; |
| 249 } | 243 } |
| 250 | 244 |
| 251 base::string16 WindowTypeLauncher::GetWindowTitle() const { | 245 base::string16 WindowTypeLauncher::GetWindowTitle() const { |
| 252 return base::ASCIIToUTF16("Examples: Window Builder"); | 246 return base::ASCIIToUTF16("Examples: Window Builder"); |
| 253 } | 247 } |
| 254 | 248 |
| 255 bool WindowTypeLauncher::CanMaximize() const { | 249 bool WindowTypeLauncher::CanMaximize() const { |
| 256 return true; | 250 return true; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 views::MenuRunner::ASYNC)); | 335 views::MenuRunner::ASYNC)); |
| 342 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 336 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
| 343 views::MENU_ANCHOR_TOPLEFT, | 337 views::MENU_ANCHOR_TOPLEFT, |
| 344 source_type) == MenuRunner::MENU_DELETED) { | 338 source_type) == MenuRunner::MENU_DELETED) { |
| 345 return; | 339 return; |
| 346 } | 340 } |
| 347 } | 341 } |
| 348 | 342 |
| 349 } // namespace shell | 343 } // namespace shell |
| 350 } // namespace ash | 344 } // namespace ash |
| OLD | NEW |