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/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 views::Widget* widget = views::Widget::CreateWindowWithParent( | 59 views::Widget* widget = views::Widget::CreateWindowWithParent( |
60 new ModalWindow(modal_type), parent); | 60 new ModalWindow(modal_type), parent); |
61 widget->GetNativeView()->SetName("ModalWindow"); | 61 widget->GetNativeView()->SetName("ModalWindow"); |
62 widget->Show(); | 62 widget->Show(); |
63 } | 63 } |
64 | 64 |
65 // Overridden from views::View: | 65 // Overridden from views::View: |
66 void OnPaint(gfx::Canvas* canvas) override { | 66 void OnPaint(gfx::Canvas* canvas) override { |
67 canvas->FillRect(GetLocalBounds(), color_); | 67 canvas->FillRect(GetLocalBounds(), color_); |
68 } | 68 } |
69 gfx::Size GetPreferredSize() const override { return gfx::Size(200, 200); } | 69 gfx::Size CalculatePreferredSize() const override { |
sky
2017/05/22 17:30:58
Ditto.
| |
70 return gfx::Size(200, 200); | |
71 } | |
70 void Layout() override { | 72 void Layout() override { |
71 gfx::Size open_ps = open_button_->GetPreferredSize(); | 73 gfx::Size open_ps = open_button_->GetPreferredSize(); |
72 gfx::Rect local_bounds = GetLocalBounds(); | 74 gfx::Rect local_bounds = GetLocalBounds(); |
73 open_button_->SetBounds(5, local_bounds.bottom() - open_ps.height() - 5, | 75 open_button_->SetBounds(5, local_bounds.bottom() - open_ps.height() - 5, |
74 open_ps.width(), open_ps.height()); | 76 open_ps.width(), open_ps.height()); |
75 } | 77 } |
76 | 78 |
77 // Overridden from views::WidgetDelegate: | 79 // Overridden from views::WidgetDelegate: |
78 bool CanResize() const override { return true; } | 80 bool CanResize() const override { return true; } |
79 base::string16 GetWindowTitle() const override { | 81 base::string16 GetWindowTitle() const override { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 if (non_modal_transient_->IsVisible()) | 120 if (non_modal_transient_->IsVisible()) |
119 non_modal_transient_->Hide(); | 121 non_modal_transient_->Hide(); |
120 else | 122 else |
121 non_modal_transient_->Show(); | 123 non_modal_transient_->Show(); |
122 } | 124 } |
123 | 125 |
124 // Overridden from views::View: | 126 // Overridden from views::View: |
125 void OnPaint(gfx::Canvas* canvas) override { | 127 void OnPaint(gfx::Canvas* canvas) override { |
126 canvas->FillRect(GetLocalBounds(), color_); | 128 canvas->FillRect(GetLocalBounds(), color_); |
127 } | 129 } |
128 gfx::Size GetPreferredSize() const override { return gfx::Size(250, 250); } | 130 gfx::Size CalculatePreferredSize() const override { |
131 return gfx::Size(250, 250); | |
132 } | |
129 | 133 |
130 // Overridden from views::WidgetDelegate: | 134 // Overridden from views::WidgetDelegate: |
131 bool CanResize() const override { return true; } | 135 bool CanResize() const override { return true; } |
132 base::string16 GetWindowTitle() const override { | 136 base::string16 GetWindowTitle() const override { |
133 return base::ASCIIToUTF16("Non-Modal Transient"); | 137 return base::ASCIIToUTF16("Non-Modal Transient"); |
134 } | 138 } |
135 void DeleteDelegate() override { | 139 void DeleteDelegate() override { |
136 if (GetWidget() == non_modal_transient_) | 140 if (GetWidget() == non_modal_transient_) |
137 non_modal_transient_ = NULL; | 141 non_modal_transient_ = NULL; |
138 | 142 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 MenuItemView::NORMAL); | 334 MenuItemView::NORMAL); |
331 // MenuRunner takes ownership of root. | 335 // MenuRunner takes ownership of root. |
332 menu_runner_.reset(new MenuRunner( | 336 menu_runner_.reset(new MenuRunner( |
333 root, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); | 337 root, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); |
334 menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 338 menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
335 views::MENU_ANCHOR_TOPLEFT, source_type); | 339 views::MENU_ANCHOR_TOPLEFT, source_type); |
336 } | 340 } |
337 | 341 |
338 } // namespace shell | 342 } // namespace shell |
339 } // namespace ash | 343 } // namespace ash |
OLD | NEW |