Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / system / tray / tray_views.cc
blobf21eb05c34d31df3eee60e94f9a8f396777c27c7
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.
5 #include "ash/system/tray/tray_views.h"
7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_item_view.h"
9 #include "ui/gfx/font.h"
10 #include "ui/views/border.h"
11 #include "ui/views/controls/label.h"
13 namespace ash {
14 namespace internal {
16 void SetupLabelForTray(views::Label* label) {
17 // Making label_font static to avoid the time penalty of DeriveFont for
18 // all but the first call.
19 static const gfx::Font label_font(gfx::Font().DeriveFont(1, gfx::Font::BOLD));
20 label->SetFont(label_font);
21 label->SetAutoColorReadabilityEnabled(false);
22 label->SetEnabledColor(SK_ColorWHITE);
23 label->SetBackgroundColor(SkColorSetARGB(0, 255, 255, 255));
24 label->SetShadowColors(SkColorSetARGB(64, 0, 0, 0),
25 SkColorSetARGB(64, 0, 0, 0));
26 label->SetShadowOffset(0, 1);
29 void SetTrayImageItemBorder(views::View* tray_view,
30 ShelfAlignment alignment) {
31 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
32 alignment == SHELF_ALIGNMENT_TOP) {
33 tray_view->set_border(views::Border::CreateEmptyBorder(
34 0, kTrayImageItemHorizontalPaddingBottomAlignment,
35 0, kTrayImageItemHorizontalPaddingBottomAlignment));
36 } else {
37 tray_view->set_border(views::Border::CreateEmptyBorder(
38 kTrayImageItemVerticalPaddingVerticalAlignment,
39 kTrayImageItemHorizontalPaddingVerticalAlignment,
40 kTrayImageItemVerticalPaddingVerticalAlignment,
41 kTrayImageItemHorizontalPaddingVerticalAlignment));
45 void SetTrayLabelItemBorder(TrayItemView* tray_view,
46 ShelfAlignment alignment) {
47 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
48 alignment == SHELF_ALIGNMENT_TOP) {
49 tray_view->set_border(views::Border::CreateEmptyBorder(
50 0, kTrayLabelItemHorizontalPaddingBottomAlignment,
51 0, kTrayLabelItemHorizontalPaddingBottomAlignment));
52 } else {
53 // Center the label for vertical launcher alignment.
54 int horizontal_padding = (tray_view->GetPreferredSize().width() -
55 tray_view->label()->GetPreferredSize().width()) / 2;
56 tray_view->set_border(views::Border::CreateEmptyBorder(
57 kTrayLabelItemVerticalPaddingVeriticalAlignment,
58 horizontal_padding,
59 kTrayLabelItemVerticalPaddingVeriticalAlignment,
60 horizontal_padding));
64 } // namespace internal
65 } // namespace ash