• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
22 class SkStackViewLayout : public SkView::Layout {
23 public:
24     SkStackViewLayout();
25 
26     enum Orient {
27         kHorizontal_Orient,
28         kVertical_Orient,
29 
30         kOrientCount
31     };
getOrient()32     Orient  getOrient() const { return (Orient)fOrient; }
33     void    setOrient(Orient);
34 
35     void        getMargin(SkRect*) const;
36     void        setMargin(const SkRect&);
37 
getSpacer()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     };
getPack()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     };
getAlign()63     Align   getAlign() const { return (Align)fAlign; }
64     void    setAlign(Align);
65 
getRound()66     bool    getRound() const { return SkToBool(fRound); }
67     void    setRound(bool);
68 
69 protected:
70     virtual void onLayoutChildren(SkView* parent);
71     virtual void onInflate(const SkDOM&, const SkDOM::Node*);
72 
73 private:
74     SkRect      fMargin;
75     SkScalar    fSpacer;
76     uint8_t     fOrient, fPack, fAlign, fRound;
77 };
78 
79 class SkFillViewLayout : public SkView::Layout {
80 public:
81             SkFillViewLayout();
82     void    getMargin(SkRect*) const;
83     void    setMargin(const SkRect&);
84 
85 protected:
86     // overrides;
87     virtual void onLayoutChildren(SkView* parent);
88     virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
89 
90 private:
91     SkRect  fMargin;
92     typedef SkView::Layout INHERITED;
93 };
94 
95 #endif
96 
97