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

Unified Diff: chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h

Issue 6250141: Sidebar mini tabs UI (views version).... Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h
===================================================================
--- chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h (revision 0)
+++ chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h (revision 0)
@@ -0,0 +1,143 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
+#define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
+#pragma once
+
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/scoped_ptr.h"
+#include "chrome/browser/ui/views/sidebar/sidebar_tab_controller.h"
+#include "chrome/browser/ui/views/sidebar/sidebar_tab_renderer_data.h"
+#include "views/animation/bounds_animator.h"
+#include "views/view.h"
+
+class SidebarBaseTab;
+class SidebarTabStripController;
+
+// Base class for the view tab strip implementations.
+class SidebarBaseTabStrip : public views::View,
+ public SidebarTabController,
+ private views::BoundsAnimatorObserver {
+ public:
+ explicit SidebarBaseTabStrip(SidebarTabStripController* controller);
+ virtual ~SidebarBaseTabStrip();
+
+ // views::View overrides:
+ virtual void OnBoundsChanged() OVERRIDE;
+
+ // SidebarTabController overrides:
+ virtual void SelectTab(SidebarBaseTab* tab);
+ virtual bool IsTabSelected(const SidebarBaseTab* tab);
+ virtual bool IsSidebarExpanded();
+
+ // Gets the number of Tabs in the tab strip.
+ // WARNING: this is the number of tabs displayed by the tab strip, which if
+ // an animation is ongoing is not necessarily the same as the number of tabs
+ // in the model.
+ int tab_count() const { return static_cast<int>(tab_data_.size()); }
+
+ // Returns the tab at the specified tab index.
+ SidebarBaseTab* base_tab_at_tab_index(int tab_index) const {
+ return tab_data_[tab_index].tab;
+ }
+
+ SidebarTabStripController* controller() const { return controller_.get(); }
+
+ // Returns true if Tabs in this SidebarTabStrip are currently changing size
+ // or position.
+ bool IsAnimating() const;
+
+ // Adds a tab at the specified index.
+ virtual void AddTabAt(int model_index,
+ bool animate,
+ const SidebarTabRendererData& data);
+
+ // Removes a tab at the specified index.
+ virtual void RemoveTabAt(int model_index, bool animate);
+
+ // Selects a tab at the specified index.
+ virtual void SelectTabAt(int new_model_index);
+
+ // Sets the tab data at the specified model index.
+ virtual void SetTabData(int model_index, const SidebarTabRendererData& data);
+
+ // Returns the tab at the specified model index.
+ SidebarBaseTab* GetBaseTabAtModelIndex(int model_index) const;
+
+ // Returns the index of the specified tab in the model coordiate system, or
+ // -1 if tab is closing or not valid.
+ int GetModelIndexOfBaseTab(const SidebarBaseTab* tab) const;
+
+ // Returns the index into |tab_data_| corresponding to the index from the
+ // TabStripModel, or |tab_data_.size()| if there is no tab representing
+ // |model_index|.
+ int ModelIndexToTabIndex(int model_index) const;
+
+ // Move all the views to their ideal bounds.
+ virtual void SetToIdealBounds();
+
+ protected:
+ // Creates and returns a new tab. The caller owns the returned tab.
+ virtual SidebarBaseTab* CreateTab() = 0;
+
+ // Invoked from |AddTabAt| after the newly created tab has been inserted.
+ virtual void StartInsertTabAnimation(int model_index) = 0;
+
+ // Starts the remove tab animation.
+ virtual void StartRemoveTabAnimation(int model_index) = 0;
+
+ // Resets the bounds of all tabs.
+ virtual void GenerateIdealBounds() = 0;
+
+ // Animates all the views to their ideal bounds.
+ // NOTE: this does *not* invoke GenerateIdealBounds, it uses the bounds
+ // currently set in ideal_bounds.
+ void AnimateToIdealBounds();
+
+ // Stops any ongoing animations.
+ void StopAnimating();
+
+ // Retrieves the ideal bounds for the tab at the specified index.
+ const gfx::Rect& ideal_bounds(int tab_data_index) {
+ return tab_data_[tab_data_index].ideal_bounds;
+ }
+ void set_ideal_bounds(int index, const gfx::Rect& bounds) {
+ tab_data_[index].ideal_bounds = bounds;
+ }
+
+ // Updates tab strip size to match the current size and position of all tabs.
+ void UpdateViewBounds();
+
+ private:
+ // The tabs we contain, and their last generated "good" bounds.
+ struct TabData {
+ SidebarBaseTab* tab;
+ gfx::Rect ideal_bounds;
+ };
+
+ // BoundsAnimatorObserver overrides:
+ virtual void OnBoundsAnimatorProgressed(
+ views::BoundsAnimator* animator) OVERRIDE;
+ virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE;
+
+ // Cleans up the tab at tab_data_index from the SidebarTabStrip.
+ void RemoveAndDeleteTab(int tab_data_index);
+
+ // Removes all tabs which are marked as closing.
+ void RemoveClosingTabs();
+
+ const scoped_ptr<SidebarTabStripController> controller_;
+
+ std::vector<TabData> tab_data_;
+
+ views::BoundsAnimator bounds_animator_;
+
+ DISALLOW_COPY_AND_ASSIGN(SidebarBaseTabStrip);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_STRIP_H_
+
Property changes on: chrome\browser\ui\views\sidebar\sidebar_base_tab_strip.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/ui/views/sidebar/sidebar_base_tab.cc ('k') | chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698