diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 18:44:31 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 18:44:31 +0000 |
commit | 7c0560f904487819f2c408c87899d1ccfa91c1fe (patch) | |
tree | da949466cd6dd09f5ce575b206a65b6ba0e1a2f9 /chrome/browser/views/tabs/tab_2.h | |
parent | 93a2c7241cddc33af51cdc3daea03e414f544ec8 (diff) | |
download | chromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.zip chromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.tar.gz chromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.tar.bz2 |
Basics of a new TabStrip.It's very, very rough, but I wanted to check it in so I don't have to keep typing svn pset as I pass patches back and forth between machines.Behind a command line flag --enable-tabtastic2.I'm trying to split the TabContents specific stuff off of the TabStrip so it's more generic (and more easily mocked for unit testing of various layout conditions). Hence TabStrip vs. BrowserTabStrip. TabStrip may move into views/ once this process is complete.Animator is a utility that can be associated with a View that (at this point) animates that View's bounds from wherever it is now to somewhere else. The TabStrip uses this to do animations for individual Tabs that are independent of each other - a limitation of the old TabStrip is that only one animation is ever active at a time so its animations are a little jumpy compared to other products.Also, detached tab dragging shows the live contents, with all animations/video/etc.Like I said, this is really rough, but I didn't want it to grow any bigger. I will write up a design doc later.http://crbug.com/9032TEST=TBD... will finally be doing some for TabStrip layout!
Review URL: http://codereview.chromium.org/42490
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/tab_2.h')
-rw-r--r-- | chrome/browser/views/tabs/tab_2.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/chrome/browser/views/tabs/tab_2.h b/chrome/browser/views/tabs/tab_2.h new file mode 100644 index 0000000..f5ae969 --- /dev/null +++ b/chrome/browser/views/tabs/tab_2.h @@ -0,0 +1,114 @@ +// Copyright (c) 2009 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_VIEWS_TABS_TAB_2_H_ +#define CHROME_BROWSER_VIEWS_TABS_TAB_2_H_ + +#include "base/string16.h" +#include "views/view.h" + +class Tab2; + +namespace gfx { +class Canvas; +class Path; +}; + +namespace views { +class AnimationContext; +class Animator; +class AnimatorDelegate; +} + +// An interface implemented by an object that provides data to the Tab2. +// The Tab2 sometimes owns the Tab2Model. See |removing_model_| in Tab2. +class Tab2Model { + public: + virtual ~Tab2Model() {} + + // Tab2 presentation state. + virtual string16 GetTitle(Tab2* tab) const = 0; + virtual bool IsSelected(Tab2* tab) const = 0; + + // The Tab2 has been clicked and should become selected. + virtual void SelectTab(Tab2* tab) = 0; + + // The mouse has been pressed down on the Tab2, pertinent information for any + // drag that might occur should be captured at this time. + virtual void CaptureDragInfo(Tab2* tab, + const views::MouseEvent& drag_event) = 0; + + // The mouse has been dragged after a press on the Tab2. + virtual bool DragTab(Tab2* tab, const views::MouseEvent& drag_event) = 0; + + // The current drag operation has ended. + virtual void DragEnded(Tab2* tab) = 0; + + // TODO(beng): get rid of this once animator is on View. + virtual views::AnimatorDelegate* AsAnimatorDelegate() = 0; +}; + +// A view that represents a Tab in a TabStrip2. +class Tab2 : public views::View { + public: + explicit Tab2(Tab2Model* model); + virtual ~Tab2(); + + bool dragging() const { return dragging_; } + + bool removing() const { return removing_; } + void set_removing(bool removing) { removing_ = removing; } + + // Assigns and takes ownership of a model object to be used when painting this + // Tab2 after the underlying data object has been removed from TabStrip2's + // model. + void SetRemovingModel(Tab2Model* model); + + // Returns true if the Tab2 is being animated. + bool IsAnimating() const; + + // Returns the Tab2's animator, creating one if necessary. + // TODO(beng): consider moving to views::View. + views::Animator* GetAnimator(); + + // Returns the ideal size of the Tab2. + static gfx::Size GetStandardSize(); + + // Adds the shape of the tab to the specified path. Used to create a clipped + // window during detached window dragging operations. + void AddTabShapeToPath(gfx::Path* path) const; + + // Overridden from views::View: + virtual gfx::Size GetPreferredSize(); + virtual void Layout(); + virtual void Paint(gfx::Canvas* canvas); + virtual bool OnMousePressed(const views::MouseEvent& event); + virtual bool OnMouseDragged(const views::MouseEvent& event); + virtual void OnMouseReleased(const views::MouseEvent& event, + bool canceled); + virtual void DidChangeBounds(const gfx::Rect& previous, + const gfx::Rect& current); + + private: + Tab2Model* model_; + + // True if the Tab2 is being dragged currently. + bool dragging_; + + // True if the Tab2 represents an object removed from its containing + // TabStrip2's model, and is currently being animated closed. + bool removing_; + + // Our animator. + scoped_ptr<views::Animator> animator_; + + // A dummy model to use for painting the tab after it's been removed from the + // TabStrip2's model but while it's still visible in the presentation (being + // animated out of existence). + scoped_ptr<Tab2Model> removing_model_; + + DISALLOW_COPY_AND_ASSIGN(Tab2); +}; + +#endif // #ifndef CHROME_BROWSER_VIEWS_TABS_TAB_2_H_ |