| 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/panel_window.h" | 5 #include "ash/shell/panel_window.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/panels/panel_frame_view.h" | 9 #include "ash/wm/panels/panel_frame_view.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 views::Widget* PanelWindow::CreatePanelWindow(const gfx::Rect& rect) { | 26 views::Widget* PanelWindow::CreatePanelWindow(const gfx::Rect& rect) { |
| 27 PanelWindow* panel_window = new PanelWindow("Example Panel Window"); | 27 PanelWindow* panel_window = new PanelWindow("Example Panel Window"); |
| 28 panel_window->params().bounds = rect; | 28 panel_window->params().bounds = rect; |
| 29 panel_window->params().context = Shell::GetPrimaryRootWindow(); | 29 panel_window->params().context = Shell::GetPrimaryRootWindow(); |
| 30 return panel_window->CreateWidget(); | 30 return panel_window->CreateWidget(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 PanelWindow::PanelWindow(const std::string& name) | 33 PanelWindow::PanelWindow(const std::string& name) |
| 34 : name_(name), | 34 : name_(name), params_(views::Widget::InitParams::TYPE_PANEL) { |
| 35 params_(views::Widget::InitParams::TYPE_PANEL) { | |
| 36 params_.delegate = this; | 35 params_.delegate = this; |
| 37 } | 36 } |
| 38 | 37 |
| 39 PanelWindow::~PanelWindow() { | 38 PanelWindow::~PanelWindow() {} |
| 40 } | |
| 41 | 39 |
| 42 views::Widget* PanelWindow::CreateWidget() { | 40 views::Widget* PanelWindow::CreateWidget() { |
| 43 views::Widget* widget = new views::Widget; | 41 views::Widget* widget = new views::Widget; |
| 44 | 42 |
| 45 if (params().bounds.width() == 0) | 43 if (params().bounds.width() == 0) |
| 46 params().bounds.set_width(kDefaultWidth); | 44 params().bounds.set_width(kDefaultWidth); |
| 47 if (params().bounds.height() == 0) | 45 if (params().bounds.height() == 0) |
| 48 params().bounds.set_height(kDefaultHeight); | 46 params().bounds.set_height(kDefaultHeight); |
| 49 params().bounds = ScreenUtil::ConvertRectToScreen( | 47 params().bounds = ScreenUtil::ConvertRectToScreen( |
| 50 Shell::GetTargetRootWindow(), | 48 Shell::GetTargetRootWindow(), params().bounds); |
| 51 params().bounds); | |
| 52 | 49 |
| 53 widget->Init(params()); | 50 widget->Init(params()); |
| 54 widget->GetNativeView()->SetName(name_); | 51 widget->GetNativeView()->SetName(name_); |
| 55 widget->Show(); | 52 widget->Show(); |
| 56 | 53 |
| 57 return widget; | 54 return widget; |
| 58 } | 55 } |
| 59 | 56 |
| 60 gfx::Size PanelWindow::GetPreferredSize() const { | 57 gfx::Size PanelWindow::GetPreferredSize() const { |
| 61 return gfx::Size(kMinWidth, kMinHeight); | 58 return gfx::Size(kMinWidth, kMinHeight); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 84 bool PanelWindow::CanMinimize() const { | 81 bool PanelWindow::CanMinimize() const { |
| 85 return false; | 82 return false; |
| 86 } | 83 } |
| 87 | 84 |
| 88 views::NonClientFrameView* PanelWindow::CreateNonClientFrameView( | 85 views::NonClientFrameView* PanelWindow::CreateNonClientFrameView( |
| 89 views::Widget* widget) { | 86 views::Widget* widget) { |
| 90 return new PanelFrameView(widget, PanelFrameView::FRAME_NONE); | 87 return new PanelFrameView(widget, PanelFrameView::FRAME_NONE); |
| 91 } | 88 } |
| 92 | 89 |
| 93 } // namespace ash | 90 } // namespace ash |
| OLD | NEW |