blob: 369e586c1b7e1f26608513174a202840aff5e9ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// 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_GTK_INFOBAR_ARROW_MODEL_H_
#define CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_
#include <gtk/gtk.h>
#include "app/slide_animation.h"
#include "third_party/skia/include/core/SkPaint.h"
namespace gfx {
class Point;
}
class InfoBar;
// A helper class that tracks the state of an infobar arrow and provides a
// utility to draw it.
class InfoBarArrowModel : public AnimationDelegate {
public:
class Observer {
public:
// The arrow has changed states; relevant widgets need to be repainted.
virtual void PaintStateChanged() = 0;
};
explicit InfoBarArrowModel(Observer* observer);
virtual ~InfoBarArrowModel();
// An infobar has been added or removed that will affect the state of this
// arrow.
void ShowArrowFor(InfoBar* bar, bool animate);
// Returns true if the arrow is showing at all.
bool NeedToDrawInfoBarArrow();
// Paints the arrow on |widget|, in response to |expose|, with the bottom
// center of the arrow at |origin|, drawing a border with |border_color|.
void Paint(GtkWidget* widget,
GdkEventExpose* expose,
const gfx::Point& origin,
const GdkColor& border_color);
// Overridden from AnimationDelegate.
virtual void AnimationEnded(const Animation* animation);
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationCanceled(const Animation* animation);
private:
// A pair of colors used to draw a gradient for an arrow.
struct InfoBarColors {
SkColor top;
SkColor bottom;
};
// Calculates the currently showing arrow color, which is a blend of the new
// arrow color and the old arrow color.
InfoBarColors CurrentInfoBarColors();
// The view that owns us.
Observer* observer_;
// An animation that tracks the progress of the transition from the last color
// to the new color.
SlideAnimation animation_;
// The color we are animating towards.
InfoBarColors target_colors_;
// The last color we showed (the one we are animating away from).
InfoBarColors previous_colors_;
DISALLOW_COPY_AND_ASSIGN(InfoBarArrowModel);
};
#endif // CHROME_BROWSER_GTK_INFOBAR_ARROW_MODEL_H_
|