| 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/system/status_area_widget_delegate.h" | 5 #include "ash/system/status_area_widget_delegate.h" |
| 6 | 6 |
| 7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/system/tray/tray_constants.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "grit/ui_resources.h" | 13 #include "grit/ui_resources.h" |
| 13 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/views/accessible_pane_view.h" | 18 #include "ui/views/accessible_pane_view.h" |
| 18 #include "ui/views/layout/grid_layout.h" | 19 #include "ui/views/layout/grid_layout.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 int kTraySpacing = 1; | 24 int kTraySpacing = 8; |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 namespace internal { | 29 namespace internal { |
| 29 | 30 |
| 30 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() | 31 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() |
| 31 : focus_cycler_for_testing_(NULL), | 32 : focus_cycler_for_testing_(NULL), |
| 32 alignment_(SHELF_ALIGNMENT_BOTTOM) { | 33 alignment_(SHELF_ALIGNMENT_BOTTOM) { |
| 33 } | 34 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 89 |
| 89 views::ColumnSet* columns = layout->AddColumnSet(0); | 90 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 90 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 91 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { |
| 91 for (int c = 0; c < child_count(); ++c) { | 92 for (int c = 0; c < child_count(); ++c) { |
| 92 if (c != 0) | 93 if (c != 0) |
| 93 columns->AddPaddingColumn(0, kTraySpacing); | 94 columns->AddPaddingColumn(0, kTraySpacing); |
| 94 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, | 95 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, |
| 95 0, /* resize percent */ | 96 0, /* resize percent */ |
| 96 views::GridLayout::USE_PREF, 0, 0); | 97 views::GridLayout::USE_PREF, 0, 0); |
| 97 } | 98 } |
| 99 columns->AddPaddingColumn(0, kPaddingFromRightEdgeOfScreenBottomAlignment); |
| 98 layout->StartRow(0, 0); | 100 layout->StartRow(0, 0); |
| 99 for (int c = 0; c < child_count(); ++c) | 101 for (int c = 0; c < child_count(); ++c) |
| 100 layout->AddView(child_at(c)); | 102 layout->AddView(child_at(c)); |
| 103 layout->AddPaddingRow(0, kPaddingFromBottomOfScreenBottomAlignment); |
| 101 } else { | 104 } else { |
| 105 columns->AddPaddingColumn( |
| 106 0, (alignment_ == SHELF_ALIGNMENT_LEFT) ? |
| 107 kPaddingFromOuterEdgeOfLauncherVerticalAlignment : |
| 108 kPaddingFromInnerEdgeOfLauncherVerticalAlignment); |
| 102 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, | 109 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, |
| 103 0, /* resize percent */ | 110 0, /* resize percent */ |
| 104 views::GridLayout::USE_PREF, 0, 0); | 111 views::GridLayout::USE_PREF, 0, 0); |
| 112 columns->AddPaddingColumn( |
| 113 0, (alignment_ == SHELF_ALIGNMENT_LEFT) ? |
| 114 kPaddingFromInnerEdgeOfLauncherVerticalAlignment : |
| 115 kPaddingFromOuterEdgeOfLauncherVerticalAlignment); |
| 105 for (int c = 0; c < child_count(); ++c) { | 116 for (int c = 0; c < child_count(); ++c) { |
| 106 if (c != 0) | 117 if (c != 0) |
| 107 layout->AddPaddingRow(0, kTraySpacing); | 118 layout->AddPaddingRow(0, kTraySpacing); |
| 108 layout->StartRow(0, 0); | 119 layout->StartRow(0, 0); |
| 109 layout->AddView(child_at(c)); | 120 layout->AddView(child_at(c)); |
| 110 } | 121 } |
| 122 layout->AddPaddingRow(0, kPaddingFromBottomOfScreenVerticalAlignment); |
| 111 } | 123 } |
| 112 Layout(); | 124 Layout(); |
| 113 UpdateWidgetSize(); | 125 UpdateWidgetSize(); |
| 114 } | 126 } |
| 115 | 127 |
| 116 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { | 128 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { |
| 117 // Need to resize the window when trays or items are added/removed. | 129 // Need to resize the window when trays or items are added/removed. |
| 118 UpdateWidgetSize(); | 130 UpdateWidgetSize(); |
| 119 } | 131 } |
| 120 | 132 |
| 121 void StatusAreaWidgetDelegate::UpdateWidgetSize() { | 133 void StatusAreaWidgetDelegate::UpdateWidgetSize() { |
| 122 if (GetWidget()) | 134 if (GetWidget()) |
| 123 GetWidget()->SetSize(GetPreferredSize()); | 135 GetWidget()->SetSize(GetPreferredSize()); |
| 124 } | 136 } |
| 125 | 137 |
| 126 } // namespace internal | 138 } // namespace internal |
| 127 } // namespace ash | 139 } // namespace ash |
| OLD | NEW |