| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <list> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/callback.h" | |
| 13 #include "chrome/browser/chromeos/status/status_area_button.h" | |
| 14 #include "ui/views/accessible_pane_view.h" | |
| 15 #include "ui/views/view.h" | |
| 16 #include "ui/views/widget/widget.h" | |
| 17 #include "ui/views/widget/widget_delegate.h" | |
| 18 | |
| 19 // This class is used to wrap the small informative widgets in the upper-right | |
| 20 // of the window title bar. It is used on ChromeOS only. | |
| 21 class StatusAreaView : public views::AccessiblePaneView, | |
| 22 public views::Widget::Observer, | |
| 23 public base::SupportsWeakPtr<StatusAreaView>, | |
| 24 public views::WidgetDelegate { | |
| 25 public: | |
| 26 enum ButtonBorder { | |
| 27 NO_BORDER, | |
| 28 HAS_BORDER | |
| 29 }; | |
| 30 | |
| 31 StatusAreaView(); | |
| 32 virtual ~StatusAreaView(); | |
| 33 | |
| 34 void AddButton(StatusAreaButton* button, ButtonBorder border); | |
| 35 void RemoveButton(StatusAreaButton* button); | |
| 36 | |
| 37 void MakeButtonsActive(bool active); | |
| 38 void UpdateButtonVisibility(); | |
| 39 | |
| 40 // Refresh the style used to paint all buttons' text. Schedules repaint. | |
| 41 void UpdateButtonTextStyle(); | |
| 42 | |
| 43 // Takes focus and transfers it to the first (last if |reverse| is true). | |
| 44 // After focus has traversed through all elements, clears focus and calls | |
| 45 // |return_focus_cb(reverse)| from the message loop. | |
| 46 typedef base::Callback<void(bool)> ReturnFocusCallback; | |
| 47 void TakeFocus(bool reverse, | |
| 48 const ReturnFocusCallback& return_focus_cb); | |
| 49 | |
| 50 // views::View* overrides. | |
| 51 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 52 virtual void Layout() OVERRIDE; | |
| 53 virtual void PreferredSizeChanged() OVERRIDE; | |
| 54 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | |
| 55 | |
| 56 // views::WidgetDelegate overrides: | |
| 57 virtual bool CanActivate() const OVERRIDE; | |
| 58 virtual void DeleteDelegate() OVERRIDE; | |
| 59 virtual views::Widget* GetWidget() OVERRIDE; | |
| 60 virtual const views::Widget* GetWidget() const OVERRIDE; | |
| 61 | |
| 62 private: | |
| 63 // Overridden from views::FocusChangeListener: | |
| 64 virtual void OnDidChangeFocus(views::View* focused_before, | |
| 65 views::View* focused_now) OVERRIDE; | |
| 66 | |
| 67 // Overriden from views::Widget::Observer: | |
| 68 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
| 69 bool active) OVERRIDE; | |
| 70 | |
| 71 // Overriden from views::AccessiblePaneView: | |
| 72 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) | |
| 73 OVERRIDE; | |
| 74 | |
| 75 StatusAreaButton::Delegate* delegate_; | |
| 76 | |
| 77 // True if focus needs to be returned via |return_focus_cb_| when it wraps. | |
| 78 bool need_return_focus_; | |
| 79 // True if focus return should be skipped for next focus change. | |
| 80 bool skip_next_focus_return_; | |
| 81 ReturnFocusCallback return_focus_cb_; | |
| 82 | |
| 83 std::list<StatusAreaButton*> buttons_; | |
| 84 | |
| 85 // Clears focus and calls |return_focus_cb_|. | |
| 86 void ReturnFocus(bool reverse); | |
| 87 | |
| 88 // Clears focus (called when widget is deactivated). | |
| 89 void ClearFocus(); | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); | |
| 92 }; | |
| 93 | |
| 94 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | |
| OLD | NEW |