| Index: chrome/browser/ui/views/sidebar/sidebar_base_tab.h
|
| ===================================================================
|
| --- chrome/browser/ui/views/sidebar/sidebar_base_tab.h (revision 0)
|
| +++ chrome/browser/ui/views/sidebar/sidebar_base_tab.h (revision 0)
|
| @@ -0,0 +1,136 @@
|
| +// 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_H_
|
| +#define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_H_
|
| +#pragma once
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/ref_counted.h"
|
| +#include "base/scoped_ptr.h"
|
| +#include "chrome/browser/ui/views/sidebar/sidebar_tab_renderer_data.h"
|
| +#include "ui/base/animation/animation_container.h"
|
| +#include "ui/base/animation/animation_delegate.h"
|
| +#include "views/view.h"
|
| +
|
| +namespace ui {
|
| +class Animation;
|
| +class SlideAnimation;
|
| +class ThrobAnimation;
|
| +} // namespace ui
|
| +
|
| +class SidebarTabController;
|
| +
|
| +// Generic sidebar tab view. It caches all data necessary for tab rendering,
|
| +// handles painting and animation, receives user interaction events and forwards
|
| +// them to the controller.
|
| +// SidebarBaseTab does not make state transition and layout decisions,
|
| +// it should be done in the concrete child classes.
|
| +class SidebarBaseTab : public views::View,
|
| + private ui::AnimationDelegate {
|
| + public:
|
| + explicit SidebarBaseTab(SidebarTabController* controller);
|
| + virtual ~SidebarBaseTab();
|
| +
|
| + // views::View overrides:
|
| + virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
|
| + virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
|
| + virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
|
| + virtual bool GetTooltipText(const gfx::Point& p,
|
| + std::wstring* tooltip) OVERRIDE;
|
| + virtual AccessibilityTypes::Role GetAccessibleRole() OVERRIDE;
|
| +
|
| + // Sets the data this tabs displays. Invokes DataChanged for subclasses to
|
| + // update themselves appropriately.
|
| + void SetData(const SidebarTabRendererData& data);
|
| + const SidebarTabRendererData& data() const { return data_; }
|
| +
|
| + // Sets the network state. Returns true if the network state was changed.
|
| + bool UpdateLoadingAnimation(SidebarTabRendererData::NetworkState state);
|
| +
|
| + // Starts/Stops a pulse animation.
|
| + void StartPulse();
|
| + void StopPulse();
|
| +
|
| + // Used to set/check whether this tab is being animated closed.
|
| + void set_closing(bool closing) { closing_ = closing; }
|
| + bool closing() const { return closing_; }
|
| +
|
| + // Sets the container all animations run from.
|
| + void set_animation_container(ui::AnimationContainer* container) {
|
| + animation_container_ = container;
|
| + }
|
| + ui::AnimationContainer* animation_container() const {
|
| + return animation_container_.get();
|
| + }
|
| +
|
| + // Returns true if the tab is selected.
|
| + bool IsSelected() const;
|
| + // Returns true if the sidebar is expanded.
|
| + bool IsExpanded() const;
|
| +
|
| + // Returns the current shape of this tab.
|
| + virtual void GetShape(gfx::Path* shape) const = 0;
|
| +
|
| + protected:
|
| + // Invoked from SetData after |data_| has been updated to the new data.
|
| + virtual void DataChanged(const SidebarTabRendererData& old) {}
|
| +
|
| + // Invoked if data_.network_state changes, or the network_state is not none.
|
| + virtual void AdvanceLoadingAnimation(
|
| + SidebarTabRendererData::NetworkState old_state,
|
| + SidebarTabRendererData::NetworkState state);
|
| +
|
| + // Gets the throb value for the tab. When a tab is not selected the
|
| + // active background is drawn at |GetThrobValue()|%. This is used for hover,
|
| + // tab title change and pulsing.
|
| + double GetThrobValue();
|
| +
|
| + // Paints the icon at the specified coordinates.
|
| + void PaintIcon(gfx::Canvas* canvas, int x, int y, int alpha);
|
| +
|
| + private:
|
| + // The animation object used to swap the icon with the sad tab icon.
|
| + class IconCrashAnimation;
|
| +
|
| + // ui::AnimationDelegate overrides:
|
| + virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
|
| + virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
|
| + virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
|
| +
|
| + // Set the temporary offset for the icon. This is used during the crash
|
| + // animation.
|
| + void SetIconHidingOffset(int offset);
|
| +
|
| + void DisplayCrashedIcon();
|
| + void ResetCrashedIcon();
|
| +
|
| + // Starts/Stops the crash animation.
|
| + void StartCrashAnimation();
|
| + void StopCrashAnimation();
|
| +
|
| + // The controller.
|
| + SidebarTabController* const controller_;
|
| +
|
| + SidebarTabRendererData data_;
|
| +
|
| + // True if the tab is being closed.
|
| + bool closing_;
|
| +
|
| + scoped_refptr<ui::AnimationContainer> animation_container_;
|
| + scoped_ptr<ui::ThrobAnimation> pulse_animation_;
|
| + scoped_ptr<ui::SlideAnimation> hover_animation_;
|
| + scoped_ptr<IconCrashAnimation> crash_animation_;
|
| + // The offset used to animate the icon location.
|
| + // It's used when the corresponding sidebar's tab contents crashes.
|
| + int icon_hiding_offset_;
|
| + bool should_display_crashed_icon_;
|
| + // The current index of the loading animation.
|
| + int loading_animation_frame_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SidebarBaseTab);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_BASE_TAB_H_
|
| +
|
|
|
| Property changes on: chrome\browser\ui\views\sidebar\sidebar_base_tab.h
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|