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
78
79
80
81
82
83
84
85
86
87
|
#include "SkBorderView.h"
#include "SkAnimator.h"
#include "SkWidgetViews.h"
#include "SkSystemEventTypes.h"
#include "SkTime.h"
#include "SkStackViewLayout.h"
SkBorderView::SkBorderView() : fTop(SkIntToScalar(0)), fLeft(SkIntToScalar(0)),
fRight(SkIntToScalar(0)), fBottom(SkIntToScalar(0))
{
fAnim.setHostEventSink(this);
init_skin_anim(kBorder_SkinEnum, &fAnim);
}
SkBorderView::~SkBorderView()
{
}
void SkBorderView::setSkin(const char skin[])
{
init_skin_anim(skin, &fAnim);
}
/* virtual */ void SkBorderView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
this->INHERITED::onInflate(dom, node);
}
/*virtual*/ void SkBorderView::onSizeChange()
{
this->INHERITED::onSizeChange();
SkEvent evt("user");
evt.setString("id", "setDim");
evt.setScalar("dimX", this->width());
evt.setScalar("dimY", this->height());
fAnim.doUserEvent(evt);
}
/*virtual*/ void SkBorderView::onDraw(SkCanvas* canvas)
{
SkPaint paint;
SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs());
if (diff == SkAnimator::kDifferent)
this->inval(NULL);
else if (diff == SkAnimator::kPartiallyDifferent)
{
SkRect bounds;
fAnim.getInvalBounds(&bounds);
this->inval(&bounds);
}
}
/*virtual*/ bool SkBorderView::onEvent(const SkEvent& evt)
{
if (evt.isType(SK_EventType_Inval))
{
this->inval(NULL);
return true;
}
if (evt.isType("recommendDim"))
{
evt.findScalar("leftMargin", &fLeft);
evt.findScalar("rightMargin", &fRight);
evt.findScalar("topMargin", &fTop);
evt.findScalar("bottomMargin", &fBottom);
//setup_views.cpp uses SkView::Layout instead of SkStackViewLayout
//but that gives me an error
SkStackViewLayout* layout;
fMargin.set(fLeft, fTop, fRight, fBottom);
if (this->getLayout())
{
layout = (SkStackViewLayout*)this->getLayout();
layout->setMargin(fMargin);
}
else
{
layout = new SkStackViewLayout;
layout->setMargin(fMargin);
this->setLayout(layout)->unref();
}
this->invokeLayout();
}
return this->INHERITED::onEvent(evt);
}
|