diff --git a/examples/symbols/ButtonBox.cpp b/examples/symbols/ButtonBox.cpp deleted file mode 100644 index af30068e..00000000 --- a/examples/symbols/ButtonBox.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "ButtonBox.h" - -ButtonBox::ButtonBox( QQuickItem* parent ): - QskLinearBox( parent ) -{ - setDimension( 3 ); - setMargins( 5 ); - - insertButton( "RoyalBlue", SkinnyShapeFactory::Rectangle ); - insertButton( "IndianRed", SkinnyShapeFactory::Ellipse ); - insertButton( "DarkOliveGreen", SkinnyShapeFactory::Ring ); - insertButton( "SandyBrown", SkinnyShapeFactory::TriangleDown ); - insertButton( "DarkViolet", SkinnyShapeFactory::Star ); - insertButton( "DarkSlateGray", SkinnyShapeFactory::Hexagon ); - - itemAtIndex( 0 )->setFocus( true ); -} - -ButtonBox::~ButtonBox() -{ -} - -void ButtonBox::insertButton( const QColor& color, SkinnyShapeFactory::Shape shape ) -{ - QskGraphic graphic; - - QPen pen( Qt::black, 3 ); - pen.setJoinStyle( Qt::MiterJoin ); - pen.setCosmetic( true ); - - QPainter painter( &graphic ); - painter.setRenderHint( QPainter::Antialiasing, true ); - painter.setPen( pen ); - painter.setBrush( color ); - - painter.drawPath( SkinnyShapeFactory::shapePath( shape, QSizeF( 40, 40 ) ) ); - painter.end(); - - QskPushButton* button = new QskPushButton( this ); - button->setObjectName( QString( "Shape %1" ).arg( int( shape ) ) ); - button->setGraphic( graphic ); - button->setMetric( QskPushButton::Panel | QskAspect::Border, 3 ); - //button->setCorner( QskCorner( Qt::RelativeSize, 100 ) ); - button->setSizePolicy( QskSizePolicy::MinimumExpanding, - QskSizePolicy::MinimumExpanding ); - - connect( button, SIGNAL( clicked() ), SLOT( onButtonClick() ) ); -} - -void ButtonBox::onButtonClick() -{ - delete sender(); -} - -#include "moc_ButtonBox.cpp" diff --git a/examples/symbols/ButtonBox.h b/examples/symbols/ButtonBox.h deleted file mode 100644 index d09bb672..00000000 --- a/examples/symbols/ButtonBox.h +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#ifndef _BUTTON_BOX_H_ -#define _BUTTON_BOX_H_ - -#include -#include - -class ButtonBox : public QskLinearBox -{ - Q_OBJECT - -public: - ButtonBox( QQuickItem* parent = nullptr ); - virtual ~ButtonBox(); - -public Q_SLOTS: - void onButtonClick(); - -private: - void insertButton( const QColor&, SkinnyShapeFactory::Shape ); -}; - -#endif diff --git a/examples/symbols/main.cpp b/examples/symbols/main.cpp deleted file mode 100644 index 2c122c56..00000000 --- a/examples/symbols/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "ButtonBox.h" -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -int main( int argc, char* argv[] ) -{ -#ifdef ITEM_STATISTICS - QskObjectCounter counter( true ); -#endif - - QGuiApplication app( argc, argv ); - - SkinnyFont::init( &app ); - SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts ); - - auto box = new ButtonBox(); - box->setObjectName( "ButtonBox" ); - - auto button = new QskPushButton( "Check Me" ); - button->setObjectName( "CheckMe" ); - button->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); - button->setCheckable( true ); - button->setChecked( true ); - - QObject::connect( button, SIGNAL( toggled( bool ) ), - box, SLOT( setVisible( bool ) ) ); - - auto layoutBox = new QskLinearBox( Qt::Horizontal ); - layoutBox->setObjectName( "MainLayout" ); - layoutBox->setMargins( 5 ); - layoutBox->addItem( button ); - layoutBox->addItem( box ); - - auto focusIndicator = new QskFocusIndicator(); - focusIndicator->setObjectName( "FocusIndicator" ); - focusIndicator->setColor( QskFocusIndicator::Panel | QskAspect::Border, Qt::darkBlue ); - - QskWindow window; - window.resize( 600, 400 ); - window.addItem( layoutBox ); - window.addItem( focusIndicator ); - - window.show(); - - return app.exec(); -} diff --git a/examples/symbols/symbols.pro b/examples/symbols/symbols.pro deleted file mode 100644 index c60a896f..00000000 --- a/examples/symbols/symbols.pro +++ /dev/null @@ -1,13 +0,0 @@ -include( $${PWD}/../examples.pri ) - -TARGET = symbols - -QT += quick quick-private -CONFIG += no_private_qt_headers_warning - -HEADERS += \ - ButtonBox.h - -SOURCES += \ - ButtonBox.cpp \ - main.cpp diff --git a/examples/thumbnails/main.cpp b/examples/thumbnails/main.cpp new file mode 100644 index 00000000..34657120 --- /dev/null +++ b/examples/thumbnails/main.cpp @@ -0,0 +1,135 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +const int gridSize = 20; +const int thumbnailSize = 150; + +static QColor randomColor() +{ + static const char* colors[] = + { + "HotPink", + "MediumVioletRed", + "FireBrick", + "PeachPuff", + "Gold", + "RosyBrown", + "Maroon", + "Turquoise", + "CadetBlue", + "Teal", + "LightSteelBlue", + "CornflowerBlue", + "Thistle", + "Plum", + "DarkViolet", + "DarkSlateBlue", + "AntiqueWhite", + "MistyRose", + "Silver", + "DarkSlateGray" + }; + + const int index = qrand() % ( sizeof( colors ) / sizeof( colors[0] ) ); + return QColor( colors[ index ] ); +} + +static int randomShape() +{ + return qrand() % SkinnyShapeFactory::ShapeCount; +} + +class Thumbnail : public QskGraphicLabel +{ +public: + Thumbnail( const QColor& color, int shape, QQuickItem* parentItem ): + QskGraphicLabel( parentItem ) + { + using namespace SkinnyShapeFactory; + + const QSizeF size( thumbnailSize, thumbnailSize ); + + QskGraphic graphic; + + QPen pen( Qt::black, 3 ); + pen.setJoinStyle( Qt::MiterJoin ); + pen.setCosmetic( true ); + + QPainter painter( &graphic ); + painter.setRenderHint( QPainter::Antialiasing, true ); + painter.setPen( pen ); + painter.setBrush( color ); + + painter.drawPath( shapePath( static_cast< Shape >( shape ), size ) ); + painter.end(); + + setGraphic( graphic ); + setFixedSize( size ); + } +}; + +class IconGrid : public QskLinearBox +{ +public: + IconGrid( QQuickItem* parentItem = nullptr ): + QskLinearBox( Qt::Horizontal, gridSize, parentItem ) + { + setMargins( 20 ); + setSpacing( 20 ); + + for ( int col = 0; col < gridSize; col++ ) + { + for ( int row = 0; row < gridSize; row++ ) + (void) new Thumbnail( randomColor(), randomShape(), this ); + } + } +}; + +int main( int argc, char* argv[] ) +{ +#ifdef ITEM_STATISTICS + QskObjectCounter counter( true ); +#endif + + QGuiApplication app( argc, argv ); + + SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts ); + + /* + In a real world application a thumbnail viewer would probably implemented + with QskScrollView using scene graph node composition - like done + in QskListView. + + This example also shows, that blocking of the scene graph node creation + ( QskControl::DeferredUpdate + QskControl::CleanupOnVisibility ) + could be extended to respect being inside the window or a clip region. + + But here we only want to demonstrate how QskScrollArea works. + */ + + auto scrollArea = new QskScrollArea(); + scrollArea->setScrolledItem( new IconGrid() ); + + QskWindow window; + window.resize( 600, 600 ); + window.addItem( scrollArea ); + + window.show(); + + return app.exec(); +} diff --git a/examples/thumbnails/thumbnails.pro b/examples/thumbnails/thumbnails.pro new file mode 100644 index 00000000..7634d7bb --- /dev/null +++ b/examples/thumbnails/thumbnails.pro @@ -0,0 +1,6 @@ +include( $${PWD}/../examples.pri ) + +TARGET = thumbnails + +SOURCES += \ + main.cpp