| Index: chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h
|
| diff --git a/chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h b/chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f4cdcd078bf526659830b31960c1e66d299be0e1
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/cocoa/toolbar/app_toolbar_button_icon.h
|
| @@ -0,0 +1,81 @@
|
| +// Copyright 2017 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_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
|
| +#define CHROME_BROWSER_UI_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
|
| +
|
| +#import <Cocoa/Cocoa.h>
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/mac/scoped_nsobject.h"
|
| +#include "base/time/time.h"
|
| +#include "third_party/skia/include/core/SkColor.h"
|
| +#include "ui/gfx/animation/animation_delegate.h"
|
| +
|
| +namespace gfx {
|
| +class SlideAnimation;
|
| +} // namespace gfx
|
| +
|
| +@class AppToolbarButton;
|
| +
|
| +// This class is used to represent and paint a dot on the app menu.
|
| +class AppMenuDot {
|
| + public:
|
| + AppMenuDot(base::TimeDelta delay,
|
| + float width_open_interval,
|
| + float stroke_open_interval);
|
| +
|
| + void DrawDot(NSPoint center_pt,
|
| + NSSize imageSize,
|
| + SkColor startColor,
|
| + SkColor targetColor,
|
| + const gfx::SlideAnimation* animation);
|
| +
|
| + private:
|
| + // The delay before the dot starts animating in ms.
|
| + const base::TimeDelta delay_;
|
| +
|
| + // The percentage of the overall animation duration it takes to animate the
|
| + // width and stroke to their open state.
|
| + const float width_open_interval_;
|
| + const float stroke_open_interval_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AppMenuDot);
|
| +};
|
| +
|
| +// This class is used for animating and drawing the app menu icon.
|
| +class AppToolbarButtonIcon : public gfx::AnimationDelegate {
|
| + public:
|
| + AppToolbarButtonIcon(AppToolbarButton* owner, SkColor start_color);
|
| +
|
| + ~AppToolbarButtonIcon() override;
|
| +
|
| + // Draws the App Menu Icon according to the given |frame|.
|
| + void DrawIcon(NSRect frame);
|
| +
|
| + // Starts the animation if it's not already running.
|
| + void StartAnimation();
|
| +
|
| + // gfx::AnimationDelegate:
|
| + void AnimationEnded(const gfx::Animation* animation) override;
|
| + void AnimationProgressed(const gfx::Animation* animation) override;
|
| +
|
| + void set_target_color(SkColor target_color) { target_color_ = target_color; }
|
| +
|
| + private:
|
| + std::unique_ptr<gfx::SlideAnimation> animation_;
|
| +
|
| + AppMenuDot bottom_dot_;
|
| + AppMenuDot center_dot_;
|
| + AppMenuDot top_dot_;
|
| +
|
| + // The color the icon is animating from/to.
|
| + SkColor start_color_;
|
| + SkColor target_color_;
|
| +
|
| + AppToolbarButton* owner_; // weak.
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_APP_TOOLBAR_BUTTON_ICON_H_
|
|
|