Home | History | Annotate | Download | only in views
      1 
      2 /*
      3  * Copyright 2006 The Android Open Source Project
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #ifndef SkStackViewLayout_DEFINED
     11 #define SkStackViewLayout_DEFINED
     12 
     13 #include "SkView.h"
     14 
     15 class SkStackViewLayout : public SkView::Layout {
     16 public:
     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,
     40 
     41         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 
     62 protected:
     63     virtual void onLayoutChildren(SkView* parent);
     64     virtual void onInflate(const SkDOM&, const SkDOM::Node*);
     65 
     66 private:
     67     SkRect      fMargin;
     68     SkScalar    fSpacer;
     69     uint8_t     fOrient, fPack, fAlign, fRound;
     70 };
     71 
     72 class SkFillViewLayout : public SkView::Layout {
     73 public:
     74             SkFillViewLayout();
     75     void    getMargin(SkRect*) const;
     76     void    setMargin(const SkRect&);
     77 
     78 protected:
     79     // overrides;
     80     virtual void onLayoutChildren(SkView* parent);
     81     virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
     82 
     83 private:
     84     SkRect  fMargin;
     85     typedef SkView::Layout INHERITED;
     86 };
     87 
     88 #endif
     89