Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: ash/common/system/tray/tray_popup_label_button_border.cc

Issue 2686703002: Remove TrayPopupLabelButton (a pre-MD class) and its assets. (Closed)
Patch Set: nit Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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/common/system/tray/tray_popup_label_button_border.h"
6
7 #include "base/i18n/rtl.h"
8 #include "grit/ash_resources.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/geometry/vector2d.h"
11 #include "ui/gfx/scoped_canvas.h"
12 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/controls/button/label_button.h"
14 #include "ui/views/native_theme_delegate.h"
15
16 namespace ash {
17
18 TrayPopupLabelButtonBorder::TrayPopupLabelButtonBorder()
19 : LabelButtonAssetBorder(views::Button::STYLE_TEXTBUTTON) {
20 const int kTrayPopupLabelButtonBorderImagesNormal[] = {
21 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
22 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
23 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
24 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
25 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
26 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
27 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
28 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
29 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
30 };
31 SetPainter(false, views::Button::STATE_NORMAL,
32 views::Painter::CreateImageGridPainter(
33 kTrayPopupLabelButtonBorderImagesNormal));
34 SetPainter(false, views::Button::STATE_DISABLED,
35 views::Painter::CreateImageGridPainter(
36 kTrayPopupLabelButtonBorderImagesNormal));
37
38 const int kTrayPopupLabelButtonBorderImagesHovered[] = {
39 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
40 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
41 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
42 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
43 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_HOVER_BACKGROUND,
44 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
45 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
46 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
47 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_BORDER,
48 };
49 SetPainter(false, views::Button::STATE_HOVERED,
50 views::Painter::CreateImageGridPainter(
51 kTrayPopupLabelButtonBorderImagesHovered));
52 SetPainter(false, views::Button::STATE_PRESSED,
53 views::Painter::CreateImageGridPainter(
54 kTrayPopupLabelButtonBorderImagesHovered));
55
56 const int kTrayPopupLabelButtonPaddingHorizontal = 16;
57 const int kTrayPopupLabelButtonPaddingVertical = 8;
58 set_insets(gfx::Insets(kTrayPopupLabelButtonPaddingVertical,
59 kTrayPopupLabelButtonPaddingHorizontal,
60 kTrayPopupLabelButtonPaddingVertical,
61 kTrayPopupLabelButtonPaddingHorizontal));
62 }
63
64 TrayPopupLabelButtonBorder::~TrayPopupLabelButtonBorder() {}
65
66 void TrayPopupLabelButtonBorder::Paint(const views::View& view,
67 gfx::Canvas* canvas) {
68 const views::NativeThemeDelegate* native_theme_delegate =
69 static_cast<const views::LabelButton*>(&view);
70 ui::NativeTheme::ExtraParams extra;
71 const ui::NativeTheme::State state =
72 native_theme_delegate->GetThemeState(&extra);
73 if (state == ui::NativeTheme::kNormal ||
74 state == ui::NativeTheme::kDisabled) {
75 // In normal and disabled state, the border is a vertical bar separating the
76 // button from the preceding sibling. If this button is its parent's first
77 // visible child, the separator bar should be omitted.
78 const views::View* first_visible_child = NULL;
79 for (int i = 0; i < view.parent()->child_count(); ++i) {
80 const views::View* child = view.parent()->child_at(i);
81 if (child->visible()) {
82 first_visible_child = child;
83 break;
84 }
85 }
86 if (first_visible_child == &view)
87 return;
88 }
89 gfx::ScopedRTLFlipCanvas scoped_canvas(canvas, view.width());
90 LabelButtonAssetBorder::Paint(view, canvas);
91 }
92
93 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_label_button_border.h ('k') | ash/common/system/tray/tray_popup_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698