summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/shelf/alternate_app_list_button.cc7
-rw-r--r--ash/shelf/app_list_button.cc4
-rw-r--r--ash/shelf/shelf_button.cc10
-rw-r--r--ash/shelf/shelf_button.h1
-rw-r--r--ash/shelf/shelf_view.cc4
-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
14 files changed, 70 insertions, 39 deletions
diff --git a/ash/shelf/alternate_app_list_button.cc b/ash/shelf/alternate_app_list_button.cc
index 4ce2834..bf442d1 100644
--- a/ash/shelf/alternate_app_list_button.cc
+++ b/ash/shelf/alternate_app_list_button.cc
@@ -4,8 +4,10 @@
#include "ash/shelf/alternate_app_list_button.h"
+#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
#include "ash/launcher/launcher_types.h"
+#include "ash/shelf/shelf_button.h"
#include "ash/shelf/shelf_button_host.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
@@ -22,6 +24,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/controls/button/image_button.h"
+#include "ui/views/painter.h"
namespace ash {
namespace internal {
@@ -39,6 +42,8 @@ AlternateAppListButton::AlternateAppListButton(views::ButtonListener* listener,
SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE));
SetSize(gfx::Size(ShelfLayoutManager::kShelfSize,
ShelfLayoutManager::kShelfSize));
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
}
AlternateAppListButton::~AlternateAppListButton() {
@@ -156,7 +161,7 @@ void AlternateAppListButton::OnPaint(gfx::Canvas* canvas) {
forground_bounds.x(),
forground_bounds.y());
- OnPaintFocusBorder(canvas);
+ views::Painter::PaintFocusPainter(this, canvas, focus_painter());
}
void AlternateAppListButton::GetAccessibleState(
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index a9612bf..697ed77 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "ash/ash_constants.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shelf/shelf_button_host.h"
#include "grit/ash_resources.h"
@@ -17,6 +18,7 @@
#include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/views/painter.h"
namespace ash {
namespace internal {
@@ -43,6 +45,8 @@ AppListButton::AppListButton(views::ButtonListener* listener,
SetAccessibleName(l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE));
SetSize(gfx::Size(kLauncherPreferredSize, kLauncherPreferredSize));
SetImageAlignment(ImageButton::ALIGN_CENTER, ImageButton::ALIGN_TOP);
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
}
AppListButton::~AppListButton() {
diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc
index 4b10b8f..93a44e1 100644
--- a/ash/shelf/shelf_button.cc
+++ b/ash/shelf/shelf_button.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "ash/ash_constants.h"
#include "ash/ash_switches.h"
#include "ash/shelf/shelf_button_host.h"
#include "ash/shelf/shelf_layout_manager.h"
@@ -470,6 +471,15 @@ void ShelfButton::OnBlur() {
CustomButton::OnBlur();
}
+void ShelfButton::OnPaint(gfx::Canvas* canvas) {
+ CustomButton::OnPaint(canvas);
+ if (HasFocus()) {
+ gfx::Rect paint_bounds(GetLocalBounds());
+ paint_bounds.Inset(1, 1, 1, 1);
+ canvas->DrawSolidFocusRect(paint_bounds, kFocusBorderColor);
+ }
+}
+
void ShelfButton::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_TAP_DOWN:
diff --git a/ash/shelf/shelf_button.h b/ash/shelf/shelf_button.h
index 1bfc510..60158f2 100644
--- a/ash/shelf/shelf_button.h
+++ b/ash/shelf/shelf_button.h
@@ -107,6 +107,7 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
virtual void OnFocus() OVERRIDE;
virtual void OnBlur() OVERRIDE;
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
// ui::EventHandler overrides:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 274014f..c31f63a 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -51,7 +51,6 @@
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/focus/focus_search.h"
-#include "ui/views/focus_border.h"
#include "ui/views/view_model.h"
#include "ui/views/view_model_utils.h"
#include "ui/views/widget/widget.h"
@@ -932,9 +931,6 @@ views::View* ShelfView::CreateViewForItem(const LauncherItem& item) {
break;
}
view->set_context_menu_controller(this);
- view->set_focus_border(views::FocusBorder::CreateSolidFocusBorder(
- kFocusBorderColor,
- gfx::Insets(1, 1, 1, 1)));
DCHECK(view);
ConfigureChildView(view);
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);
};