blob: f2a7cf04c706bd2be8a83d7226d4f768ec2a6e7d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkStackViewLayout_DEFINED
11#define SkStackViewLayout_DEFINED
12
13#include "SkView.h"
14
15class SkStackViewLayout : public SkView::Layout {
16public:
17 SkStackViewLayout();
18
19 enum Orient {
20 kHorizontal_Orient,
21 kVertical_Orient,
22
23 kOrientCount
24 };
25 Orient getOrient() const { return (Orient)fOrient; }
26 void setOrient(Orient);
27
28 void getMargin(SkRect*) const;
29 void setMargin(const SkRect&);
30
31 SkScalar getSpacer() const { return fSpacer; }
32 void setSpacer(SkScalar);
33
34 /** Controls the posititioning in the same direction as the orientation
35 */
36 enum Pack {
37 kStart_Pack,
38 kCenter_Pack,
39 kEnd_Pack,
rmistry@google.comfbfcd562012-08-23 18:09:54 +000040
reed@android.com8a1c16f2008-12-17 15:59:43 +000041 kPackCount
42 };
43 Pack getPack() const { return (Pack)fPack; }
44 void setPack(Pack);
45
46 /** Controls the posititioning at right angles to the orientation
47 */
48 enum Align {
49 kStart_Align,
50 kCenter_Align,
51 kEnd_Align,
52 kStretch_Align,
53
54 kAlignCount
55 };
56 Align getAlign() const { return (Align)fAlign; }
57 void setAlign(Align);
58
59 bool getRound() const { return SkToBool(fRound); }
60 void setRound(bool);
61
62protected:
63 virtual void onLayoutChildren(SkView* parent);
64 virtual void onInflate(const SkDOM&, const SkDOM::Node*);
65
66private:
67 SkRect fMargin;
68 SkScalar fSpacer;
69 uint8_t fOrient, fPack, fAlign, fRound;
70};
71
72class SkFillViewLayout : public SkView::Layout {
73public:
74 SkFillViewLayout();
75 void getMargin(SkRect*) const;
76 void setMargin(const SkRect&);
77
78protected:
79 // overrides;
80 virtual void onLayoutChildren(SkView* parent);
81 virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
82
83private:
84 SkRect fMargin;
85 typedef SkView::Layout INHERITED;
86};
87
88#endif