diff --git a/examples/layouts/GridLayoutPage.cpp b/examples/layouts/GridLayoutPage.cpp new file mode 100644 index 00000000..235f612d --- /dev/null +++ b/examples/layouts/GridLayoutPage.cpp @@ -0,0 +1,48 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#include "GridLayoutPage.h" +#include "TestRectangle.h" + +#include +#include + +namespace +{ + class Box : public QskGridBox + { + public: + Box( QQuickItem* parent = nullptr ) + : QskGridBox( parent ) + { + setObjectName( "GridBox" ); + + setBackgroundColor( Qt::white ); + setMargins( 10 ); + + addItem( new TestRectangle( "PaleVioletRed" ), 0, 0, 1, 2 ); + addItem( new TestRectangle( "DarkSeaGreen" ), 1, 0, 2, 1 ); + addItem( new TestRectangle( "SkyBlue" ), 2, 1, 1, 1 ); + addItem( new TestRectangle( "NavajoWhite" ), 0, 2, 4, 1 ); + } + + void mirror() + { + setLayoutMirroring( !layoutMirroring() ); + } + }; +} + +GridLayoutPage::GridLayoutPage( QQuickItem* parent ) + : QskControl( parent ) +{ +#if 1 + setMargins( 10 ); + setBackgroundColor( QskRgbValue::LightSteelBlue ); +#endif + + setAutoLayoutChildren( true ); + new Box( this ); +} diff --git a/examples/layouts/GridLayoutPage.h b/examples/layouts/GridLayoutPage.h new file mode 100644 index 00000000..38812b68 --- /dev/null +++ b/examples/layouts/GridLayoutPage.h @@ -0,0 +1,17 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#ifndef GRID_LAYOUT_PAGE +#define GRID_LAYOUT_PAGE 1 + +#include + +class GridLayoutPage : public QskControl +{ + public: + GridLayoutPage( QQuickItem* parent = nullptr ); +}; + +#endif diff --git a/examples/layouts/layouts.pro b/examples/layouts/layouts.pro index 38f7e869..bf8a6f23 100644 --- a/examples/layouts/layouts.pro +++ b/examples/layouts/layouts.pro @@ -4,6 +4,7 @@ HEADERS += \ TestRectangle.h \ ButtonBox.h \ FlowLayoutPage.h \ + GridLayoutPage.h \ LinearLayoutPage.h \ DynamicConstraintsPage.h \ StackLayoutPage.h @@ -12,6 +13,7 @@ SOURCES += \ TestRectangle.cpp \ ButtonBox.cpp \ FlowLayoutPage.cpp \ + GridLayoutPage.cpp \ LinearLayoutPage.cpp \ DynamicConstraintsPage.cpp \ StackLayoutPage.cpp \ diff --git a/examples/layouts/main.cpp b/examples/layouts/main.cpp index dbcfb1f2..f8642efd 100644 --- a/examples/layouts/main.cpp +++ b/examples/layouts/main.cpp @@ -6,6 +6,7 @@ #include "DynamicConstraintsPage.h" #include "FlowLayoutPage.h" #include "LinearLayoutPage.h" +#include "GridLayoutPage.h" #include "StackLayoutPage.h" #include @@ -52,11 +53,13 @@ int main( int argc, char* argv[] ) SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts ); auto tabView = new QskTabView(); + tabView->setMargins( 10 ); tabView->setTabPosition( Qsk::Left ); - tabView->addTab( "Grid Layout", new DummyLabel( "Grid Layout - TODO ..." ) ); + tabView->addTab( "Grid Layout", new GridLayoutPage() ); tabView->addTab( "Flow Layout", new FlowLayoutPage() ); tabView->addTab( "Linear Layout", new LinearLayoutPage() ); + int dynamicIndex = tabView->addTab( "Dynamic\nConstraints", new DynamicConstraintsPage() ); auto button = tabView->buttonAt( dynamicIndex );