| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // Shows the dropdown bar. | 68 // Shows the dropdown bar. |
| 69 virtual void Show(bool animate); | 69 virtual void Show(bool animate); |
| 70 // Hides the dropdown bar. | 70 // Hides the dropdown bar. |
| 71 virtual void Hide(bool animate); | 71 virtual void Hide(bool animate); |
| 72 | 72 |
| 73 // Returns the rectangle representing where to position the dropdown widget. | 73 // Returns the rectangle representing where to position the dropdown widget. |
| 74 virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect) = 0; | 74 virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect) = 0; |
| 75 | 75 |
| 76 // Moves the widget to the provided location, moves it to top | 76 // Moves the widget to the provided location, moves it to top |
| 77 // in the z-order (HWND_TOP, not HWND_TOPMOST for windows) and shows | 77 // in the z-order (HWND_TOP, not HWND_TOPMOST for windows), and sets the size |
| 78 // the widget (if hidden). | 78 // of the |view_|. |
| 79 virtual void SetDialogPosition(const gfx::Rect& new_pos) = 0; | 79 virtual void SetDialogPosition(const gfx::Rect& new_pos); |
| 80 | 80 |
| 81 // Overridden from views::FocusChangeListener: | 81 // Overridden from views::FocusChangeListener: |
| 82 void OnWillChangeFocus(views::View* focused_before, | 82 void OnWillChangeFocus(views::View* focused_before, |
| 83 views::View* focused_now) override; | 83 views::View* focused_now) override; |
| 84 void OnDidChangeFocus(views::View* focused_before, | 84 void OnDidChangeFocus(views::View* focused_before, |
| 85 views::View* focused_now) override; | 85 views::View* focused_now) override; |
| 86 | 86 |
| 87 // Overridden from ui::AcceleratorTarget: | 87 // Overridden from ui::AcceleratorTarget: |
| 88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override = 0; | 88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override = 0; |
| 89 bool CanHandleAccelerators() const override = 0; | 89 bool CanHandleAccelerators() const override = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 // Resets the focus tracker. | 126 // Resets the focus tracker. |
| 127 void ResetFocusTracker(); | 127 void ResetFocusTracker(); |
| 128 | 128 |
| 129 // The focus manager we register with to keep track of focus changes. | 129 // The focus manager we register with to keep track of focus changes. |
| 130 views::FocusManager* focus_manager() const { return focus_manager_; } | 130 views::FocusManager* focus_manager() const { return focus_manager_; } |
| 131 | 131 |
| 132 // Returns the host widget. | 132 // Returns the host widget. |
| 133 views::Widget* host() const { return host_.get(); } | 133 views::Widget* host() const { return host_.get(); } |
| 134 | 134 |
| 135 // Returns the animation offset. | |
| 136 int animation_offset() const { return animation_offset_; } | |
| 137 | |
| 138 // Retrieves the boundary that the dropdown widget has to work with | 135 // Retrieves the boundary that the dropdown widget has to work with |
| 139 // within the Chrome frame window. The boundary differs depending on | 136 // within the Chrome frame window. The boundary differs depending on |
| 140 // the dropdown bar implementation. The default implementation | 137 // the dropdown bar implementation. The default implementation |
| 141 // returns the boundary of browser_view and the drop down | 138 // returns the boundary of browser_view and the drop down |
| 142 // can be shown in any client area. | 139 // can be shown in any client area. |
| 143 virtual void GetWidgetBounds(gfx::Rect* bounds); | 140 virtual void GetWidgetBounds(gfx::Rect* bounds); |
| 144 | 141 |
| 145 // Returns the animation for the dropdown. | 142 // Returns the animation for the dropdown. |
| 146 gfx::SlideAnimation* animation() { | 143 gfx::SlideAnimation* animation() { |
| 147 return animation_.get(); | 144 return animation_.get(); |
| 148 } | 145 } |
| 149 | 146 |
| 150 private: | 147 private: |
| 151 // Set the view whose position in the |browser_view_| view hierarchy | 148 // Set the view whose position in the |browser_view_| view hierarchy |
| 152 // determines the z-order of |host_| relative to views with layers and | 149 // determines the z-order of |host_| relative to views with layers and |
| 153 // views with associated NativeViews. | 150 // views with associated NativeViews. |
| 154 void SetHostViewNative(views::View* host_view); | 151 void SetHostViewNative(views::View* host_view); |
| 155 | 152 |
| 156 // The BrowserView that created us. | 153 // The BrowserView that created us. |
| 157 BrowserView* browser_view_; | 154 BrowserView* browser_view_; |
| 158 | 155 |
| 156 // A parent View to |view_| that is used to clip when animating the bar |
| 157 // between the shown and hidden states. |
| 158 views::View* clip_view_; |
| 159 |
| 159 // Our view, which is responsible for drawing the UI. | 160 // Our view, which is responsible for drawing the UI. |
| 160 views::View* view_; | 161 views::View* view_; |
| 161 DropdownBarHostDelegate* delegate_; | 162 DropdownBarHostDelegate* delegate_; |
| 162 | 163 |
| 163 // The y position pixel offset of the widget while animating the | |
| 164 // dropdown widget. | |
| 165 int animation_offset_; | |
| 166 | |
| 167 // The animation class to use when opening the Dropdown widget. | 164 // The animation class to use when opening the Dropdown widget. |
| 168 scoped_ptr<gfx::SlideAnimation> animation_; | 165 scoped_ptr<gfx::SlideAnimation> animation_; |
| 169 | 166 |
| 170 // The focus manager we register with to keep track of focus changes. | 167 // The focus manager we register with to keep track of focus changes. |
| 171 views::FocusManager* focus_manager_; | 168 views::FocusManager* focus_manager_; |
| 172 | 169 |
| 173 // True if the accelerator target for Esc key is registered. | 170 // True if the accelerator target for Esc key is registered. |
| 174 bool esc_accel_target_registered_; | 171 bool esc_accel_target_registered_; |
| 175 | 172 |
| 176 // Tracks and stores the last focused view which is not the DropdownBarView | 173 // Tracks and stores the last focused view which is not the DropdownBarView |
| 177 // or any of its children. Used to restore focus once the DropdownBarView is | 174 // or any of its children. Used to restore focus once the DropdownBarView is |
| 178 // closed. | 175 // closed. |
| 179 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; | 176 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; |
| 180 | 177 |
| 181 // Host is the Widget implementation that is created and maintained by the | 178 // Host is the Widget implementation that is created and maintained by the |
| 182 // dropdown bar. It contains the DropdownBarView. | 179 // dropdown bar. It contains the DropdownBarView. |
| 183 scoped_ptr<views::Widget> host_; | 180 scoped_ptr<views::Widget> host_; |
| 184 | 181 |
| 185 // A flag to manually manage visibility. GTK/X11 is asynchronous and | 182 // A flag to manually manage visibility. GTK/X11 is asynchronous and |
| 186 // the state of the widget can be out of sync. | 183 // the state of the widget can be out of sync. |
| 187 bool is_visible_; | 184 bool is_visible_; |
| 188 | 185 |
| 189 DISALLOW_COPY_AND_ASSIGN(DropdownBarHost); | 186 DISALLOW_COPY_AND_ASSIGN(DropdownBarHost); |
| 190 }; | 187 }; |
| 191 | 188 |
| 192 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ | 189 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
| OLD | NEW |