| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/wm/compact_status_area_layout_manager.h" | |
| 6 | |
| 7 #include "ash/shell.h" | |
| 8 #include "base/auto_reset.h" | |
| 9 #include "base/i18n/rtl.h" | |
| 10 #include "ui/gfx/rect.h" | |
| 11 #include "ui/gfx/screen.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 | |
| 14 namespace ash { | |
| 15 namespace internal { | |
| 16 | |
| 17 //////////////////////////////////////////////////////////////////////////////// | |
| 18 // CompactStatusAreaLayoutManager, public: | |
| 19 | |
| 20 CompactStatusAreaLayoutManager::CompactStatusAreaLayoutManager( | |
| 21 views::Widget* status_widget) | |
| 22 : in_layout_(false), | |
| 23 status_widget_(status_widget) { | |
| 24 } | |
| 25 | |
| 26 CompactStatusAreaLayoutManager::~CompactStatusAreaLayoutManager() { | |
| 27 } | |
| 28 | |
| 29 //////////////////////////////////////////////////////////////////////////////// | |
| 30 // CompactStatusAreaLayoutManager, aura::LayoutManager implementation: | |
| 31 | |
| 32 void CompactStatusAreaLayoutManager::OnWindowResized() { | |
| 33 LayoutStatusArea(); | |
| 34 } | |
| 35 | |
| 36 void CompactStatusAreaLayoutManager::OnWindowAddedToLayout( | |
| 37 aura::Window* child) { | |
| 38 LayoutStatusArea(); | |
| 39 } | |
| 40 | |
| 41 void CompactStatusAreaLayoutManager::OnWillRemoveWindowFromLayout( | |
| 42 aura::Window* child) { | |
| 43 } | |
| 44 | |
| 45 void CompactStatusAreaLayoutManager::OnChildWindowVisibilityChanged( | |
| 46 aura::Window* child, bool visible) { | |
| 47 } | |
| 48 | |
| 49 void CompactStatusAreaLayoutManager::SetChildBounds( | |
| 50 aura::Window* child, const gfx::Rect& requested_bounds) { | |
| 51 SetChildBoundsDirect(child, requested_bounds); | |
| 52 if (!in_layout_) | |
| 53 LayoutStatusArea(); | |
| 54 } | |
| 55 | |
| 56 //////////////////////////////////////////////////////////////////////////////// | |
| 57 // CompactStatusAreaLayoutManager, private: | |
| 58 | |
| 59 void CompactStatusAreaLayoutManager::LayoutStatusArea() { | |
| 60 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | |
| 61 gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryMonitorBounds(); | |
| 62 gfx::Rect widget_bounds = status_widget_->GetRestoredBounds(); | |
| 63 gfx::Size offset = ash::Shell::GetInstance()->compact_status_area_offset(); | |
| 64 if (base::i18n::IsRTL()) { | |
| 65 // Place the widget in the top-left corner of the screen. | |
| 66 widget_bounds.set_x(monitor_bounds.x() + offset.width()); | |
| 67 } else { | |
| 68 // Place the widget in the top-right corner of the screen. | |
| 69 widget_bounds.set_x( | |
| 70 monitor_bounds.right() - widget_bounds.width() - offset.width()); | |
| 71 } | |
| 72 widget_bounds.set_y(offset.height()); | |
| 73 status_widget_->SetBounds(widget_bounds); | |
| 74 } | |
| 75 | |
| 76 } // namespace internal | |
| 77 } // namespace ash | |
| OLD | NEW |