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

Side by Side Diff: chrome/browser/ui/panels/panel_overflow_strip.h

Issue 8776035: Add PanelOverflowStrip to handle panel overflow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux build on trybot Created 9 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_
7 #pragma once
8
9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h"
11 #include "ui/base/animation/animation_delegate.h"
12
13 class Browser;
14 class PanelManager;
15 namespace ui {
16 class SlideAnimation;
17 }
18
19 // Manipulates all the panels that are placed on the left-most overflow area.
20 class PanelOverflowStrip : public PanelMouseWatcherObserver,
21 public ui::AnimationDelegate {
22 public:
23 typedef std::vector<Panel*> Panels;
24
25 explicit PanelOverflowStrip(PanelManager* panel_manager);
26 virtual ~PanelOverflowStrip();
27
28 // Sets the display area of the overflow strip.
29 // |display_area| is in screen coordinates.
30 void SetDisplayArea(const gfx::Rect& display_area);
31
32 // Adds a panel to the strip. |is_new| indicates if the panel is a newly
33 // created panel or one that is transitioning from another grouping of panels.
34 void AddPanel(Panel* panel, bool is_new);
35
36 // Returns |false| if the panel is not in the strip.
37 bool Remove(Panel* panel);
38 void RemoveAll();
39
40 // Called when a panel's expansion state changes.
41 void OnPanelExpansionStateChanged(
42 Panel* panel, Panel::ExpansionState old_state);
43
44 // Refreshes the layouts for all panels to reflect any possible changes.
45 void Refresh();
46
47 void OnFullScreenModeChanged(bool is_full_screen);
48
49 int num_panels() const { return static_cast<int>(panels_.size()); }
50 Panel* first_panel() const {
51 return panels_.empty() ? NULL : panels_.front();
52 }
53
54 #ifdef UNIT_TEST
55 const Panels& panels() const { return panels_; }
56 #endif
57
58 private:
59 // Overridden from PanelMouseWatcherObserver:
60 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE;
61
62 // Overridden from AnimationDelegate:
63 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
64
65 void DoRefresh(size_t start_index, size_t end_index);
66
67 // Computes the layout of the |index| panel to fit into the area.
68 // Empty bounds will be returned if this is not possible due to not enough
69 // space.
70 gfx::Rect ComputeLayout(size_t index,
71 const gfx::Size& iconified_size) const;
72
73 // Used to pop up the titles for overflow panels when the mouse hovers over
74 // the overflow area.
75 bool ShouldShowOverflowTitles(const gfx::Point& mouse_position) const;
76 void ShowOverflowTitles(bool show_overflow_titles);
77
78 // Weak pointer since PanelManager owns PanelOverflowStrip instance.
79 PanelManager* panel_manager_;
80
81 // The queue for storing all panels.
82 Panels panels_;
83
84 // The overflow area where panels are iconified due to insufficient space
85 // in the panel strip.
86 gfx::Rect display_area_;
87
88 // For mouse hover-over effect.
89 bool are_overflow_titles_shown_;
90 scoped_ptr<ui::SlideAnimation> overflow_hover_animator_;
91 int overflow_hover_animator_start_width_;
92 int overflow_hover_animator_end_width_;
93
94 // Invalid panel index.
95 static const size_t kInvalidPanelIndex = static_cast<size_t>(-1);
96
97 DISALLOW_COPY_AND_ASSIGN(PanelOverflowStrip);
98 };
99
100 #endif // CHROME_BROWSER_UI_PANELS_PANEL_OVERFLOW_STRIP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698