blob: 8000319fcb9f1c74cc67c6d7fce977c355a5c87c [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkStackViewLayout_DEFINED
18#define SkStackViewLayout_DEFINED
19
20#include "SkView.h"
21
22class SkStackViewLayout : public SkView::Layout {
23public:
24 SkStackViewLayout();
25
26 enum Orient {
27 kHorizontal_Orient,
28 kVertical_Orient,
29
30 kOrientCount
31 };
32 Orient getOrient() const { return (Orient)fOrient; }
33 void setOrient(Orient);
34
35 void getMargin(SkRect*) const;
36 void setMargin(const SkRect&);
37
38 SkScalar getSpacer() const { return fSpacer; }
39 void setSpacer(SkScalar);
40
41 /** Controls the posititioning in the same direction as the orientation
42 */
43 enum Pack {
44 kStart_Pack,
45 kCenter_Pack,
46 kEnd_Pack,
47
48 kPackCount
49 };
50 Pack getPack() const { return (Pack)fPack; }
51 void setPack(Pack);
52
53 /** Controls the posititioning at right angles to the orientation
54 */
55 enum Align {
56 kStart_Align,
57 kCenter_Align,
58 kEnd_Align,
59 kStretch_Align,
60
61 kAlignCount
62 };
63 Align getAlign() const { return (Align)fAlign; }
64 void setAlign(Align);
65
66 bool getRound() const { return SkToBool(fRound); }
67 void setRound(bool);
68
69protected:
70 virtual void onLayoutChildren(SkView* parent);
71 virtual void onInflate(const SkDOM&, const SkDOM::Node*);
72
73private:
74 SkRect fMargin;
75 SkScalar fSpacer;
76 uint8_t fOrient, fPack, fAlign, fRound;
77};
78
79class SkFillViewLayout : public SkView::Layout {
80public:
81 SkFillViewLayout();
82 void getMargin(SkRect*) const;
83 void setMargin(const SkRect&);
84
85protected:
86 // overrides;
87 virtual void onLayoutChildren(SkView* parent);
88 virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
89
90private:
91 SkRect fMargin;
92 typedef SkView::Layout INHERITED;
93};
94
95#endif
96