summaryrefslogtreecommitdiffstats
path: root/ash/system
diff options
context:
space:
mode:
Diffstat (limited to 'ash/system')
-rw-r--r--ash/system/tray/actionable_view.cc36
-rw-r--r--ash/system/tray/actionable_view.h13
-rw-r--r--ash/system/tray/fixed_sized_scroll_view.cc5
-rw-r--r--ash/system/tray/fixed_sized_scroll_view.h1
-rw-r--r--ash/system/tray/tray_background_view.cc15
-rw-r--r--ash/system/tray/tray_background_view.h2
-rw-r--r--ash/system/tray/tray_popup_header_button.cc7
-rw-r--r--ash/system/tray/tray_popup_label_button.cc3
-rw-r--r--ash/system/tray/tray_popup_label_button.h1
9 files changed, 49 insertions, 34 deletions
diff --git a/ash/system/tray/actionable_view.cc b/ash/system/tray/actionable_view.cc
index 9a21b04..40d90b4 100644
--- a/ash/system/tray/actionable_view.cc
+++ b/ash/system/tray/actionable_view.cc
@@ -22,12 +22,16 @@ ActionableView::ActionableView()
ActionableView::~ActionableView() {
}
-void ActionableView::DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds) {
- gfx::Rect rect = bounds;
+void ActionableView::OnPaintFocus(gfx::Canvas* canvas) {
+ gfx::Rect rect(GetFocusBounds());
rect.Inset(1, 1, 3, 2);
canvas->DrawSolidFocusRect(rect, kFocusBorderColor);
}
+gfx::Rect ActionableView::GetFocusBounds() {
+ return GetLocalBounds();
+}
+
const char* ActionableView::GetClassName() const {
return kViewClassName;
}
@@ -59,9 +63,26 @@ void ActionableView::SetAccessibleName(const base::string16& name) {
accessible_name_ = name;
}
-void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if (HasFocus())
- DrawBorder(canvas, GetLocalBounds());
+void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) {
+ state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
+ state->name = accessible_name_;
+}
+
+void ActionableView::OnPaint(gfx::Canvas* canvas) {
+ View::OnPaint(canvas);
+ OnPaintFocus(canvas);
+}
+
+void ActionableView::OnFocus() {
+ View::OnFocus();
+ // We render differently when focused.
+ SchedulePaint();
+}
+
+void ActionableView::OnBlur() {
+ View::OnBlur();
+ // We render differently when focused.
+ SchedulePaint();
}
void ActionableView::OnGestureEvent(ui::GestureEvent* event) {
@@ -69,10 +90,5 @@ void ActionableView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
}
-void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) {
- state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
- state->name = accessible_name_;
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/system/tray/actionable_view.h b/ash/system/tray/actionable_view.h
index 0d0f1a1..f2b3ec1 100644
--- a/ash/system/tray/actionable_view.h
+++ b/ash/system/tray/actionable_view.h
@@ -21,6 +21,8 @@ namespace internal {
// Exported for SystemTray.
class ASH_EXPORT ActionableView : public views::View {
public:
+ static const char kViewClassName[];
+
ActionableView();
virtual ~ActionableView();
@@ -28,10 +30,11 @@ class ASH_EXPORT ActionableView : public views::View {
void SetAccessibleName(const base::string16& name);
const base::string16& accessible_name() const { return accessible_name_; }
- static const char kViewClassName[];
-
protected:
- void DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds);
+ void OnPaintFocus(gfx::Canvas* canvas);
+
+ // Returns the bounds to paint the focus rectangle in.
+ virtual gfx::Rect GetFocusBounds();
// Performs an action when user clicks on the view (on mouse-press event), or
// presses a key when this view is in focus. Returns true if the event has
@@ -45,7 +48,9 @@ class ASH_EXPORT ActionableView : public views::View {
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
- virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnFocus() OVERRIDE;
+ virtual void OnBlur() OVERRIDE;
// Overridden from ui::EventHandler.
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
diff --git a/ash/system/tray/fixed_sized_scroll_view.cc b/ash/system/tray/fixed_sized_scroll_view.cc
index 59b524b..d3fff9ad 100644
--- a/ash/system/tray/fixed_sized_scroll_view.cc
+++ b/ash/system/tray/fixed_sized_scroll_view.cc
@@ -9,7 +9,6 @@ namespace internal {
FixedSizedScrollView::FixedSizedScrollView() {
set_notify_enter_exit_on_child(true);
- set_focus_border(NULL);
}
FixedSizedScrollView::~FixedSizedScrollView() {
@@ -54,9 +53,5 @@ void FixedSizedScrollView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
contents()->SetBoundsRect(bounds);
}
-void FixedSizedScrollView::OnPaintFocusBorder(gfx::Canvas* canvas) {
- // Do not paint the focus border.
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/system/tray/fixed_sized_scroll_view.h b/ash/system/tray/fixed_sized_scroll_view.h
index c5d9bc0..aff53c2 100644
--- a/ash/system/tray/fixed_sized_scroll_view.h
+++ b/ash/system/tray/fixed_sized_scroll_view.h
@@ -33,7 +33,6 @@ class FixedSizedScrollView : public views::ScrollView {
protected:
// Overridden from views::View:
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
- virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
private:
gfx::Size fixed_size_;
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 3939b70..9eb80c1 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -379,14 +379,6 @@ void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
PreferredSizeChanged();
}
-void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) {
- // The tray itself expands to the right and bottom edge of the screen to make
- // sure clicking on the edges brings up the popup. However, the focus border
- // should be only around the container.
- if (HasFocus())
- DrawBorder(canvas, GetContentsBounds());
-}
-
void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = GetAccessibleNameForTray();
@@ -403,6 +395,13 @@ bool TrayBackgroundView::PerformAction(const ui::Event& event) {
return false;
}
+gfx::Rect TrayBackgroundView::GetFocusBounds() {
+ // The tray itself expands to the right and bottom edge of the screen to make
+ // sure clicking on the edges brings up the popup. However, the focus border
+ // should be only around the container.
+ return GetContentsBounds();
+}
+
void TrayBackgroundView::UpdateBackground(int alpha) {
// The animator should never fire when the alternate shelf layout is used.
if (!background_ || draw_background_as_active_)
diff --git a/ash/system/tray/tray_background_view.h b/ash/system/tray/tray_background_view.h
index b459684..0f6e2f7 100644
--- a/ash/system/tray/tray_background_view.h
+++ b/ash/system/tray/tray_background_view.h
@@ -70,12 +70,12 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
- virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE;
// Overridden from internal::ActionableView.
virtual bool PerformAction(const ui::Event& event) OVERRIDE;
+ virtual gfx::Rect GetFocusBounds() OVERRIDE;
// Overridden from internal::BackgroundAnimatorDelegate.
virtual void UpdateBackground(int alpha) OVERRIDE;
diff --git a/ash/system/tray/tray_popup_header_button.cc b/ash/system/tray/tray_popup_header_button.cc
index ceeda04..e9430e5 100644
--- a/ash/system/tray/tray_popup_header_button.cc
+++ b/ash/system/tray/tray_popup_header_button.cc
@@ -8,6 +8,7 @@
#include "ash/system/tray/tray_constants.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
+#include "ui/views/painter.h"
namespace ash {
namespace internal {
@@ -38,9 +39,9 @@ TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
set_focusable(true);
set_request_focus_on_press(false);
- set_focus_border(views::FocusBorder::CreateSolidFocusBorder(
- kFocusBorderColor,
- gfx::Insets(1, 2, 2, 3)));
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor,
+ gfx::Insets(1, 2, 2, 3)));
}
TrayPopupHeaderButton::~TrayPopupHeaderButton() {}
diff --git a/ash/system/tray/tray_popup_label_button.cc b/ash/system/tray/tray_popup_label_button.cc
index aa72a3b..2f97c37 100644
--- a/ash/system/tray/tray_popup_label_button.cc
+++ b/ash/system/tray/tray_popup_label_button.cc
@@ -8,6 +8,7 @@
#include "ash/system/tray/tray_popup_label_button_border.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/rect.h"
+#include "ui/views/painter.h"
namespace ash {
namespace internal {
@@ -20,7 +21,7 @@ TrayPopupLabelButton::TrayPopupLabelButton(views::ButtonListener* listener,
set_request_focus_on_press(false);
set_animate_on_state_change(false);
SetHorizontalAlignment(gfx::ALIGN_CENTER);
- set_focus_border(views::FocusBorder::CreateSolidFocusBorder(
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
kFocusBorderColor,
gfx::Insets(1, 1, 2, 2)));
}
diff --git a/ash/system/tray/tray_popup_label_button.h b/ash/system/tray/tray_popup_label_button.h
index 83ff439..a1f9db6 100644
--- a/ash/system/tray/tray_popup_label_button.h
+++ b/ash/system/tray/tray_popup_label_button.h
@@ -21,7 +21,6 @@ class TrayPopupLabelButton : public views::LabelButton {
virtual ~TrayPopupLabelButton();
private:
-
DISALLOW_COPY_AND_ASSIGN(TrayPopupLabelButton);
};