1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/views/SkStackViewLayout.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkStackViewLayout_DEFINED 1.14 +#define SkStackViewLayout_DEFINED 1.15 + 1.16 +#include "SkView.h" 1.17 + 1.18 +class SkStackViewLayout : public SkView::Layout { 1.19 +public: 1.20 + SkStackViewLayout(); 1.21 + 1.22 + enum Orient { 1.23 + kHorizontal_Orient, 1.24 + kVertical_Orient, 1.25 + 1.26 + kOrientCount 1.27 + }; 1.28 + Orient getOrient() const { return (Orient)fOrient; } 1.29 + void setOrient(Orient); 1.30 + 1.31 + void getMargin(SkRect*) const; 1.32 + void setMargin(const SkRect&); 1.33 + 1.34 + SkScalar getSpacer() const { return fSpacer; } 1.35 + void setSpacer(SkScalar); 1.36 + 1.37 + /** Controls the posititioning in the same direction as the orientation 1.38 + */ 1.39 + enum Pack { 1.40 + kStart_Pack, 1.41 + kCenter_Pack, 1.42 + kEnd_Pack, 1.43 + 1.44 + kPackCount 1.45 + }; 1.46 + Pack getPack() const { return (Pack)fPack; } 1.47 + void setPack(Pack); 1.48 + 1.49 + /** Controls the posititioning at right angles to the orientation 1.50 + */ 1.51 + enum Align { 1.52 + kStart_Align, 1.53 + kCenter_Align, 1.54 + kEnd_Align, 1.55 + kStretch_Align, 1.56 + 1.57 + kAlignCount 1.58 + }; 1.59 + Align getAlign() const { return (Align)fAlign; } 1.60 + void setAlign(Align); 1.61 + 1.62 + bool getRound() const { return SkToBool(fRound); } 1.63 + void setRound(bool); 1.64 + 1.65 +protected: 1.66 + virtual void onLayoutChildren(SkView* parent); 1.67 + virtual void onInflate(const SkDOM&, const SkDOM::Node*); 1.68 + 1.69 +private: 1.70 + SkRect fMargin; 1.71 + SkScalar fSpacer; 1.72 + uint8_t fOrient, fPack, fAlign, fRound; 1.73 +}; 1.74 + 1.75 +class SkFillViewLayout : public SkView::Layout { 1.76 +public: 1.77 + SkFillViewLayout(); 1.78 + void getMargin(SkRect*) const; 1.79 + void setMargin(const SkRect&); 1.80 + 1.81 +protected: 1.82 + // overrides; 1.83 + virtual void onLayoutChildren(SkView* parent); 1.84 + virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 1.85 + 1.86 +private: 1.87 + SkRect fMargin; 1.88 + typedef SkView::Layout INHERITED; 1.89 +}; 1.90 + 1.91 +#endif