gallery example started
This commit is contained in:
parent
2572409791
commit
8154bc42f7
|
|
@ -3,11 +3,11 @@ TEMPLATE = subdirs
|
||||||
# c++
|
# c++
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
desktop \
|
desktop \
|
||||||
|
gallery \
|
||||||
layouts \
|
layouts \
|
||||||
listbox \
|
listbox \
|
||||||
messagebox \
|
messagebox \
|
||||||
mycontrols \
|
mycontrols \
|
||||||
sliders \
|
|
||||||
thumbnails \
|
thumbnails \
|
||||||
tabview
|
tabview
|
||||||
|
|
||||||
|
|
@ -28,5 +28,4 @@ SUBDIRS += \
|
||||||
frames \
|
frames \
|
||||||
gbenchmark \
|
gbenchmark \
|
||||||
glabels \
|
glabels \
|
||||||
messageboxQml \
|
messageboxQml
|
||||||
tlabels
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "Page.h"
|
||||||
|
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskBoxShapeMetrics.h>
|
||||||
|
|
||||||
|
Page::Page( Qt::Orientation orientation, QQuickItem* parent )
|
||||||
|
: QskLinearBox( orientation, parent )
|
||||||
|
{
|
||||||
|
setBackgroundColor( Qt::gray );
|
||||||
|
|
||||||
|
setPanel( true );
|
||||||
|
setBoxShapeHint( QskBox::Panel, 8 );
|
||||||
|
setGradient( QskRgbValue::GhostWhite );
|
||||||
|
|
||||||
|
setMargins( 5 );
|
||||||
|
setPadding( 10 );
|
||||||
|
setSpacing( 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Page::setGradient( const QskGradient& gradient )
|
||||||
|
{
|
||||||
|
setGradientHint( QskBox::Panel, gradient );
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PAGE_H
|
||||||
|
#define PAGE_H
|
||||||
|
|
||||||
|
#include <QskLinearBox.h>
|
||||||
|
|
||||||
|
class Page : public QskLinearBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Page( Qt::Orientation, QQuickItem* parent = nullptr );
|
||||||
|
void setGradient( const QskGradient& );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
CONFIG += qskexample
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
label/LabelPage.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
label/LabelPage.cpp \
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
slider/CustomSlider.h \
|
||||||
|
slider/CustomSliderSkinlet.h \
|
||||||
|
slider/OtherSlider.h \
|
||||||
|
slider/SliderPage.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
slider/CustomSlider.cpp \
|
||||||
|
slider/CustomSliderSkinlet.cpp \
|
||||||
|
slider/OtherSlider.cpp \
|
||||||
|
slider/SliderPage.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
progressbar/ProgressBarPage.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
progressbar/ProgressBarPage.cpp \
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
Page.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
Page.cpp \
|
||||||
|
main.cpp
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "LabelPage.h"
|
||||||
|
#include <QskTextLabel.h>
|
||||||
|
#include <QskGraphicLabel.h>
|
||||||
|
#include <QskSeparator.h>
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class TextBox : public QskLinearBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextBox( QQuickItem* parent = nullptr )
|
||||||
|
: QskLinearBox( Qt::Vertical, 3, parent )
|
||||||
|
{
|
||||||
|
setMargins( 10 );
|
||||||
|
//setDefaultAlignment( Qt::AlignTop );
|
||||||
|
setExtraSpacingAt( Qt::BottomEdge );
|
||||||
|
|
||||||
|
const QStringList texts =
|
||||||
|
{ "Default", "Tiny", "Small", "Medium", "Large", "Huge" };
|
||||||
|
|
||||||
|
for ( int i = 0; i < texts.size(); i++ )
|
||||||
|
{
|
||||||
|
auto label = new QskTextLabel( texts[ i ] + " Font", this );
|
||||||
|
|
||||||
|
//label->setPanel( true );
|
||||||
|
label->setFontRole( i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IconBox : public QskLinearBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IconBox( QQuickItem* parent = nullptr )
|
||||||
|
: QskLinearBox( Qt::Horizontal, 3, parent )
|
||||||
|
{
|
||||||
|
setMargins( 10 );
|
||||||
|
setSpacing( 20 );
|
||||||
|
|
||||||
|
const char* icons[] =
|
||||||
|
{
|
||||||
|
"rectangle/royalblue",
|
||||||
|
"triangleright/thistle",
|
||||||
|
"ellipse/khaki",
|
||||||
|
"ring/sandybrown",
|
||||||
|
"star/darkviolet",
|
||||||
|
"hexagon/darkslategray"
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto prefix = QStringLiteral( "image://shapes/" );
|
||||||
|
|
||||||
|
for ( const auto icon : icons )
|
||||||
|
{
|
||||||
|
auto label = new QskGraphicLabel( prefix + icon, this );
|
||||||
|
label->setAlignment( Qt::AlignCenter );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
LabelPage::LabelPage( QQuickItem* parent )
|
||||||
|
: Page( Qt::Vertical, parent )
|
||||||
|
{
|
||||||
|
setGradient( QskRgbValue::AliceBlue );
|
||||||
|
setSpacing( 40 );
|
||||||
|
|
||||||
|
(void) new TextBox( this );
|
||||||
|
(void) new QskSeparator( this );
|
||||||
|
(void) new IconBox( this );
|
||||||
|
}
|
||||||
|
|
@ -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 LABEL_PAGE_H
|
||||||
|
#define LABEL_PAGE_H
|
||||||
|
|
||||||
|
#include "Page.h"
|
||||||
|
|
||||||
|
class LabelPage : public Page
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LabelPage( QQuickItem* = nullptr );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "label/LabelPage.h"
|
||||||
|
#include "progressbar/ProgressBarPage.h"
|
||||||
|
#include "slider/SliderPage.h"
|
||||||
|
|
||||||
|
#include <SkinnyFont.h>
|
||||||
|
#include <SkinnyShortcut.h>
|
||||||
|
#include <SkinnyShapeProvider.h>
|
||||||
|
|
||||||
|
#include <QskFocusIndicator.h>
|
||||||
|
#include <QskObjectCounter.h>
|
||||||
|
#include <QskTabView.h>
|
||||||
|
#include <QskWindow.h>
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
int main( int argc, char* argv[] )
|
||||||
|
{
|
||||||
|
#ifdef ITEM_STATISTICS
|
||||||
|
QskObjectCounter counter( true );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() );
|
||||||
|
|
||||||
|
QGuiApplication app( argc, argv );
|
||||||
|
|
||||||
|
SkinnyFont::init( &app );
|
||||||
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
|
auto tabView = new QskTabView();
|
||||||
|
|
||||||
|
tabView->setMargins( 10 );
|
||||||
|
tabView->setTabPosition( Qsk::Left );
|
||||||
|
tabView->setAutoFitTabs( true );
|
||||||
|
|
||||||
|
tabView->addTab( "Labels", new LabelPage() );
|
||||||
|
tabView->addTab( "Sliders", new SliderPage() );
|
||||||
|
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
|
||||||
|
|
||||||
|
QSize size( 800, 600 );
|
||||||
|
size = size.expandedTo( tabView->sizeHint().toSize() );
|
||||||
|
|
||||||
|
QskWindow window;
|
||||||
|
window.addItem( tabView );
|
||||||
|
window.addItem( new QskFocusIndicator() );
|
||||||
|
|
||||||
|
window.resize( size );
|
||||||
|
window.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "ProgressBarPage.h"
|
||||||
|
#include <QskProgressBar.h>
|
||||||
|
#include <QskGraphicProvider.h>
|
||||||
|
#include <QskGraphic.h>
|
||||||
|
#include <QskGradient.h>
|
||||||
|
#include <QskRgbPalette.h>
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class ProgressBar : public QskProgressBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressBar( QskLinearBox* box )
|
||||||
|
: QskProgressBar( box )
|
||||||
|
{
|
||||||
|
setOrientation( ( box->orientation() == Qt::Horizontal )
|
||||||
|
? Qt::Vertical : Qt::Horizontal );
|
||||||
|
|
||||||
|
setBoundaries( 0, 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTheme( QskRgbPalette::Theme theme )
|
||||||
|
{
|
||||||
|
const auto pal = QskRgbPalette::palette( theme );
|
||||||
|
|
||||||
|
QVector< QRgb > rgb;
|
||||||
|
rgb += pal.rgb( QskRgbPalette::W200 );
|
||||||
|
rgb += pal.rgb( QskRgbPalette::W400 );
|
||||||
|
rgb += pal.rgb( QskRgbPalette::W600 );
|
||||||
|
rgb += pal.rgb( QskRgbPalette::W900 );
|
||||||
|
|
||||||
|
const auto stops = QskRgbPalette::colorStops( rgb, true );
|
||||||
|
|
||||||
|
setBarGradient( QskGradient( orientation(), stops ) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressBarPage::ProgressBarPage( QQuickItem* parent )
|
||||||
|
: Page( Qt::Horizontal, parent )
|
||||||
|
{
|
||||||
|
setGradient( QskRgbValue::AliceBlue );
|
||||||
|
setSpacing( 40 );
|
||||||
|
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressBarPage::populate()
|
||||||
|
{
|
||||||
|
auto hBox = new QskLinearBox( Qt::Horizontal, this );
|
||||||
|
hBox->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
||||||
|
hBox->setSpacing( 20 );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( hBox );
|
||||||
|
bar->setValue( 35 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( hBox );
|
||||||
|
bar->setTheme( QskRgbPalette::BlueGrey );
|
||||||
|
bar->setValue( 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( hBox );
|
||||||
|
bar->setTheme( QskRgbPalette::Blue );
|
||||||
|
bar->setValue( 75 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( hBox );
|
||||||
|
bar->setTheme( QskRgbPalette::Blue );
|
||||||
|
bar->setOrigin( 60 );
|
||||||
|
bar->setValue( 25 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( hBox );
|
||||||
|
bar->setIndeterminate( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto vBox = new QskLinearBox( Qt::Vertical, this );
|
||||||
|
vBox->setSpacing( 20 );
|
||||||
|
vBox->setExtraSpacingAt( Qt::BottomEdge );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( vBox );
|
||||||
|
bar->setTheme( QskRgbPalette::DeepOrange );
|
||||||
|
bar->setValue( 100 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( vBox );
|
||||||
|
bar->setTheme( QskRgbPalette::Pink );
|
||||||
|
bar->setMaximum( 40 );
|
||||||
|
bar->setValue( 25 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( vBox );
|
||||||
|
bar->setTheme( QskRgbPalette::Pink );
|
||||||
|
bar->setOrigin( 40 );
|
||||||
|
bar->setValue( 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bar = new ProgressBar( vBox );
|
||||||
|
bar->setIndeterminate( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PROGRESS_BAR_PAGE_H
|
||||||
|
#define PROGRESS_BAR_PAGE_H
|
||||||
|
|
||||||
|
#include "Page.h"
|
||||||
|
|
||||||
|
class ProgressBarPage : public Page
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressBarPage( QQuickItem* = nullptr );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void populate();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "Slider.h"
|
#include "CustomSlider.h"
|
||||||
#include "SliderSkinlet.h"
|
#include "CustomSliderSkinlet.h"
|
||||||
|
|
||||||
#include <QskAnimationHint.h>
|
#include <QskAnimationHint.h>
|
||||||
#include <QskAspect.h>
|
#include <QskAspect.h>
|
||||||
|
|
@ -12,10 +12,10 @@
|
||||||
#include <QskGradient.h>
|
#include <QskGradient.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
QSK_SUBCONTROL( Slider, Scale )
|
QSK_SUBCONTROL( CustomSlider, Scale )
|
||||||
QSK_SUBCONTROL( Slider, Decoration )
|
QSK_SUBCONTROL( CustomSlider, Decoration )
|
||||||
|
|
||||||
Slider::Slider( QQuickItem* parentItem )
|
CustomSlider::CustomSlider( QQuickItem* parentItem )
|
||||||
: QskSlider( parentItem )
|
: QskSlider( parentItem )
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
using namespace QskAspect;
|
||||||
|
|
@ -44,7 +44,7 @@ Slider::Slider( QQuickItem* parentItem )
|
||||||
|
|
||||||
// using an individual skinlet, not known by the skin
|
// using an individual skinlet, not known by the skin
|
||||||
|
|
||||||
auto skinlet = new SliderSkinlet();
|
auto skinlet = new CustomSliderSkinlet();
|
||||||
skinlet->setOwnedBySkinnable( true );
|
skinlet->setOwnedBySkinnable( true );
|
||||||
|
|
||||||
setSkinlet( skinlet );
|
setSkinlet( skinlet );
|
||||||
|
|
@ -53,7 +53,7 @@ Slider::Slider( QQuickItem* parentItem )
|
||||||
this, &QskControl::focusIndicatorRectChanged );
|
this, &QskControl::focusIndicatorRectChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF Slider::contentsSizeHint(
|
QSizeF CustomSlider::contentsSizeHint(
|
||||||
Qt::SizeHint which, const QSizeF& constraint ) const
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
{
|
{
|
||||||
auto size = Inherited::contentsSizeHint( which, constraint );
|
auto size = Inherited::contentsSizeHint( which, constraint );
|
||||||
|
|
@ -64,7 +64,7 @@ QSizeF Slider::contentsSizeHint(
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Slider::focusIndicatorRect() const
|
QRectF CustomSlider::focusIndicatorRect() const
|
||||||
{
|
{
|
||||||
return subControlRect( QskSlider::Handle );
|
return subControlRect( QskSlider::Handle );
|
||||||
}
|
}
|
||||||
|
|
@ -3,19 +3,19 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SLIDER_H
|
#ifndef CUSTOM_SLIDER_H
|
||||||
#define SLIDER_H
|
#define CUSTOM_SLIDER_H
|
||||||
|
|
||||||
#include <QskSlider.h>
|
#include <QskSlider.h>
|
||||||
|
|
||||||
class Slider : public QskSlider
|
class CustomSlider : public QskSlider
|
||||||
{
|
{
|
||||||
using Inherited = QskSlider;
|
using Inherited = QskSlider;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Scale, Decoration )
|
QSK_SUBCONTROLS( Scale, Decoration )
|
||||||
|
|
||||||
Slider( QQuickItem* parent = nullptr );
|
CustomSlider( QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
QRectF focusIndicatorRect() const override;
|
QRectF focusIndicatorRect() const override;
|
||||||
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "SliderSkinlet.h"
|
#include "CustomSliderSkinlet.h"
|
||||||
#include "Slider.h"
|
#include "CustomSlider.h"
|
||||||
|
|
||||||
#include <QskAspect.h>
|
#include <QskAspect.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
@ -26,10 +26,13 @@ static const qreal qskMargin = 20;
|
||||||
static const qreal qskPeak = 10;
|
static const qreal qskPeak = 10;
|
||||||
|
|
||||||
static QFont qskLabelFont;
|
static QFont qskLabelFont;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class TicksNode : public QSGGeometryNode
|
namespace
|
||||||
{
|
{
|
||||||
|
class TicksNode : public QSGGeometryNode
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
TicksNode( const QColor& color )
|
TicksNode( const QColor& color )
|
||||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
|
||||||
|
|
@ -46,10 +49,10 @@ class TicksNode : public QSGGeometryNode
|
||||||
private:
|
private:
|
||||||
QSGFlatColorMaterial m_material;
|
QSGFlatColorMaterial m_material;
|
||||||
QSGGeometry m_geometry;
|
QSGGeometry m_geometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HandleNode : public QSGGeometryNode
|
class HandleNode : public QSGGeometryNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HandleNode()
|
HandleNode()
|
||||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 8 * 2 )
|
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 8 * 2 )
|
||||||
|
|
@ -108,19 +111,16 @@ class HandleNode : public QSGGeometryNode
|
||||||
|
|
||||||
QSGFlatColorMaterial m_material;
|
QSGFlatColorMaterial m_material;
|
||||||
QSGGeometry m_geometry;
|
QSGGeometry m_geometry;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SliderSkinlet::SliderSkinlet()
|
CustomSliderSkinlet::CustomSliderSkinlet()
|
||||||
{
|
{
|
||||||
qskLabelFont = QFont();
|
qskLabelFont = QFont();
|
||||||
setNodeRoles( { ScaleRole, FillRole, DecorationRole, HandleRole } );
|
setNodeRoles( { ScaleRole, FillRole, DecorationRole, HandleRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
SliderSkinlet::~SliderSkinlet()
|
QRectF CustomSliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF SliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
|
||||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||||
{
|
{
|
||||||
const auto slider = static_cast< const QskSlider* >( skinnable );
|
const auto slider = static_cast< const QskSlider* >( skinnable );
|
||||||
|
|
@ -137,11 +137,11 @@ QRectF SliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
{
|
{
|
||||||
return handleRect( slider, contentsRect );
|
return handleRect( slider, contentsRect );
|
||||||
}
|
}
|
||||||
else if ( subControl == Slider::Scale )
|
else if ( subControl == CustomSlider::Scale )
|
||||||
{
|
{
|
||||||
return scaleRect( contentsRect );
|
return scaleRect( contentsRect );
|
||||||
}
|
}
|
||||||
else if ( subControl == Slider::Decoration )
|
else if ( subControl == CustomSlider::Decoration )
|
||||||
{
|
{
|
||||||
return decorationRect( slider, contentsRect );
|
return decorationRect( slider, contentsRect );
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +149,7 @@ QRectF SliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* SliderSkinlet::updateSubNode(
|
QSGNode* CustomSliderSkinlet::updateSubNode(
|
||||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
const auto slider = static_cast< const QskSlider* >( skinnable );
|
const auto slider = static_cast< const QskSlider* >( skinnable );
|
||||||
|
|
@ -173,7 +173,7 @@ QSGNode* SliderSkinlet::updateSubNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF SliderSkinlet::scaleRect( const QRectF& contentsRect ) const
|
QRectF CustomSliderSkinlet::scaleRect( const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
auto r = contentsRect;
|
auto r = contentsRect;
|
||||||
|
|
||||||
|
|
@ -185,10 +185,10 @@ QRectF SliderSkinlet::scaleRect( const QRectF& contentsRect ) const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF SliderSkinlet::fillRect(
|
QRectF CustomSliderSkinlet::fillRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
auto r = subControlRect( slider, contentsRect, Slider::Scale );
|
auto r = subControlRect( slider, contentsRect, CustomSlider::Scale );
|
||||||
|
|
||||||
r.setTop( r.bottom() - qskMinorTick );
|
r.setTop( r.bottom() - qskMinorTick );
|
||||||
r.setWidth( r.width() * slider->valueAsRatio() );
|
r.setWidth( r.width() * slider->valueAsRatio() );
|
||||||
|
|
@ -196,23 +196,23 @@ QRectF SliderSkinlet::fillRect(
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF SliderSkinlet::decorationRect(
|
QRectF CustomSliderSkinlet::decorationRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
// decoration exceeds scale !!!!
|
// decoration exceeds scale !!!!
|
||||||
|
|
||||||
auto r = subControlRect( slider, contentsRect, Slider::Scale );
|
auto r = subControlRect( slider, contentsRect, CustomSlider::Scale );
|
||||||
r.setBottom( r.top() );
|
r.setBottom( r.top() );
|
||||||
r.setTop( r.bottom() - QFontMetricsF( qskLabelFont ).height() );
|
r.setTop( r.bottom() - QFontMetricsF( qskLabelFont ).height() );
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF SliderSkinlet::handleRect(
|
QRectF CustomSliderSkinlet::handleRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
const QRectF fillRect = subControlRect( slider, contentsRect, QskSlider::Fill );
|
const QRectF fillRect = subControlRect( slider, contentsRect, QskSlider::Fill );
|
||||||
const QRectF scaleRect = subControlRect( slider, contentsRect, Slider::Scale );
|
const QRectF scaleRect = subControlRect( slider, contentsRect, CustomSlider::Scale );
|
||||||
|
|
||||||
QRectF handleRect( 0, scaleRect.bottom(), 80, 50 );
|
QRectF handleRect( 0, scaleRect.bottom(), 80, 50 );
|
||||||
handleRect.moveCenter( QPointF( fillRect.right(), handleRect.center().y() ) );
|
handleRect.moveCenter( QPointF( fillRect.right(), handleRect.center().y() ) );
|
||||||
|
|
@ -225,18 +225,18 @@ QRectF SliderSkinlet::handleRect(
|
||||||
return handleRect;
|
return handleRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* SliderSkinlet::updateScaleNode(
|
QSGNode* CustomSliderSkinlet::updateScaleNode(
|
||||||
const QskSlider* slider, QSGNode* node ) const
|
const QskSlider* slider, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
const auto scaleRect = subControlRect(
|
const auto scaleRect = subControlRect(
|
||||||
slider, slider->contentsRect(), Slider::Scale );
|
slider, slider->contentsRect(), CustomSlider::Scale );
|
||||||
|
|
||||||
if ( scaleRect.isEmpty() )
|
if ( scaleRect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto ticksNode = static_cast< TicksNode* >( node );
|
auto ticksNode = static_cast< TicksNode* >( node );
|
||||||
if ( ticksNode == nullptr )
|
if ( ticksNode == nullptr )
|
||||||
ticksNode = new TicksNode( slider->color( Slider::Scale ) );
|
ticksNode = new TicksNode( slider->color( CustomSlider::Scale ) );
|
||||||
|
|
||||||
const int tickCount = std::floor( slider->boundaryLength() / slider->stepSize() ) + 1;
|
const int tickCount = std::floor( slider->boundaryLength() / slider->stepSize() ) + 1;
|
||||||
|
|
||||||
|
|
@ -268,11 +268,11 @@ QSGNode* SliderSkinlet::updateScaleNode(
|
||||||
return ticksNode;
|
return ticksNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* SliderSkinlet::updateDecorationNode(
|
QSGNode* CustomSliderSkinlet::updateDecorationNode(
|
||||||
const QskSlider* slider, QSGNode* node ) const
|
const QskSlider* slider, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
const QRectF decorationRect = subControlRect(
|
const QRectF decorationRect = subControlRect(
|
||||||
slider, slider->contentsRect(), Slider::Decoration );
|
slider, slider->contentsRect(), CustomSlider::Decoration );
|
||||||
|
|
||||||
if ( decorationRect.isEmpty() )
|
if ( decorationRect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -320,7 +320,7 @@ QSGNode* SliderSkinlet::updateDecorationNode(
|
||||||
return decorationNode;
|
return decorationNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* SliderSkinlet::updateHandleNode(
|
QSGNode* CustomSliderSkinlet::updateHandleNode(
|
||||||
const QskSlider* slider, QSGNode* node ) const
|
const QskSlider* slider, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
const QRectF handleRect = subControlRect(
|
const QRectF handleRect = subControlRect(
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SLIDER_SKINLET_H
|
#ifndef CUSTOM_SLIDER_SKINLET_H
|
||||||
#define SLIDER_SKINLET_H
|
#define CUSTOM_SLIDER_SKINLET_H
|
||||||
|
|
||||||
#include <QskSliderSkinlet.h>
|
#include <QskSliderSkinlet.h>
|
||||||
|
|
||||||
class QSGTransformNode;
|
class QSGTransformNode;
|
||||||
|
|
||||||
class SliderSkinlet : public QskSliderSkinlet
|
class CustomSliderSkinlet : public QskSliderSkinlet
|
||||||
{
|
{
|
||||||
using Inherited = QskSliderSkinlet;
|
using Inherited = QskSliderSkinlet;
|
||||||
|
|
||||||
|
|
@ -22,8 +22,7 @@ class SliderSkinlet : public QskSliderSkinlet
|
||||||
DecorationRole
|
DecorationRole
|
||||||
};
|
};
|
||||||
|
|
||||||
SliderSkinlet();
|
CustomSliderSkinlet();
|
||||||
~SliderSkinlet() override;
|
|
||||||
|
|
||||||
QRectF subControlRect( const QskSkinnable*,
|
QRectF subControlRect( const QskSkinnable*,
|
||||||
const QRectF&, QskAspect::Subcontrol ) const override;
|
const QRectF&, QskAspect::Subcontrol ) const override;
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "OtherSlider.h"
|
||||||
|
|
||||||
|
#include <QskAspect.h>
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskBoxShapeMetrics.h>
|
||||||
|
#include <QskBoxBorderMetrics.h>
|
||||||
|
#include <QskBoxBorderColors.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
OtherSlider::OtherSlider( QQuickItem* parentItem )
|
||||||
|
: QskSlider( parentItem )
|
||||||
|
{
|
||||||
|
using namespace QskAspect;
|
||||||
|
using namespace QskRgbValue;
|
||||||
|
|
||||||
|
const qreal h = 30;
|
||||||
|
const qreal w = 2.0 * h;
|
||||||
|
const qreal paddingW = 0.5 * w + 1;
|
||||||
|
|
||||||
|
// Panel
|
||||||
|
|
||||||
|
for ( auto placement : { Horizontal, Vertical } )
|
||||||
|
{
|
||||||
|
const Aspect aspect = Panel | placement;
|
||||||
|
|
||||||
|
setMetric( aspect | Size, h );
|
||||||
|
setBoxShapeHint( aspect, 4 );
|
||||||
|
setBoxBorderMetricsHint( aspect, 1 );
|
||||||
|
setBoxBorderColorsHint( aspect, Grey900 );
|
||||||
|
setGradientHint( aspect, Grey400 );
|
||||||
|
|
||||||
|
if ( placement == Horizontal )
|
||||||
|
setMarginsHint( aspect | Padding, QMarginsF( paddingW, 0, paddingW, 0 ) );
|
||||||
|
else
|
||||||
|
setMarginsHint( aspect | Padding, QMarginsF( 0, paddingW, 0, paddingW ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Groove
|
||||||
|
|
||||||
|
for ( auto placement : { Horizontal, Vertical } )
|
||||||
|
{
|
||||||
|
const Aspect aspect = Groove | placement;
|
||||||
|
|
||||||
|
setMetric( aspect | Size, 4 );
|
||||||
|
setBoxBorderMetricsHint( aspect, 0 );
|
||||||
|
setBoxShapeHint( aspect, 1 );
|
||||||
|
|
||||||
|
setGradientHint( aspect, Qt::black );
|
||||||
|
}
|
||||||
|
|
||||||
|
// no Fill
|
||||||
|
for ( auto placement : { Horizontal, Vertical } )
|
||||||
|
{
|
||||||
|
const Aspect aspect = Fill | placement;
|
||||||
|
setMetric( aspect | Size, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle
|
||||||
|
|
||||||
|
for ( auto placement : { Horizontal, Vertical } )
|
||||||
|
{
|
||||||
|
const Aspect aspect = Handle | placement;
|
||||||
|
|
||||||
|
setBoxBorderMetricsHint( aspect, 1 );
|
||||||
|
setBoxShapeHint( aspect, 4 );
|
||||||
|
|
||||||
|
const qreal m = 0.5 * std::ceil( 0.5 * ( w - h ) ) + 1;
|
||||||
|
|
||||||
|
if ( placement == Horizontal )
|
||||||
|
setMarginsHint( aspect | Margin, QMarginsF( -m, 0, -m, 0 ) );
|
||||||
|
else
|
||||||
|
setMarginsHint( aspect | Margin, QMarginsF( 0, -m, 0, -m ) );
|
||||||
|
|
||||||
|
for ( auto state : { NoState, Pressed } )
|
||||||
|
{
|
||||||
|
setBoxBorderColorsHint( aspect | state, Grey600 );
|
||||||
|
setGradientHint( aspect | state, Blue400 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef OTHER_SLIDER_H
|
||||||
|
#define OTHER_SLIDER_H
|
||||||
|
|
||||||
|
#include <QskSlider.h>
|
||||||
|
|
||||||
|
class OtherSlider : public QskSlider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Slider overriding many hints from the skin.
|
||||||
|
|
||||||
|
OtherSlider( QQuickItem* = nullptr );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "SliderPage.h"
|
||||||
|
#include "CustomSlider.h"
|
||||||
|
#include "OtherSlider.h"
|
||||||
|
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
|
SliderPage::SliderPage( QQuickItem* parentItem )
|
||||||
|
: Page( Qt::Vertical, parentItem )
|
||||||
|
{
|
||||||
|
setGradient( QskRgbValue::PeachPuff );
|
||||||
|
|
||||||
|
setMargins( 10 );
|
||||||
|
setSpacing( 20 );
|
||||||
|
|
||||||
|
populate();
|
||||||
|
|
||||||
|
const auto sliders = findChildren< QskSlider* >();
|
||||||
|
|
||||||
|
for ( auto slider : sliders )
|
||||||
|
{
|
||||||
|
slider->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||||
|
|
||||||
|
slider->setValue( slider->minimum() +
|
||||||
|
0.5 * ( slider->maximum() - slider->minimum() ) );
|
||||||
|
#if 0
|
||||||
|
connect( slider, &QskSlider::valueChanged,
|
||||||
|
[]( qreal value ) { qDebug() << value; } );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SliderPage::populate()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
auto slider = new QskSlider( this );
|
||||||
|
|
||||||
|
slider->setMinimum( 0 );
|
||||||
|
slider->setMaximum( 1000 );
|
||||||
|
slider->setPageSize( 10 );
|
||||||
|
slider->setStepSize( 10 );
|
||||||
|
slider->setSnap( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto slider = new OtherSlider( this );
|
||||||
|
|
||||||
|
slider->setMinimum( 0 );
|
||||||
|
slider->setMaximum( 10 );
|
||||||
|
slider->setStepSize( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto hBox = new QskLinearBox( Qt::Horizontal, this );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto slider = new QskSlider( Qt::Vertical, hBox );
|
||||||
|
|
||||||
|
slider->setMinimum( 0 );
|
||||||
|
slider->setMaximum( 1000 );
|
||||||
|
slider->setPageSize( 10 );
|
||||||
|
slider->setStepSize( 10 );
|
||||||
|
slider->setSnap( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto slider = new OtherSlider( hBox );
|
||||||
|
slider->setOrientation( Qt::Vertical );
|
||||||
|
|
||||||
|
slider->setMinimum( 0 );
|
||||||
|
slider->setMaximum( 10 );
|
||||||
|
slider->setStepSize( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto slider = new CustomSlider( this );
|
||||||
|
|
||||||
|
slider->setMargins( QMarginsF( 0, 15, 0, 15 ) );
|
||||||
|
slider->setSnap( true );
|
||||||
|
slider->setMinimum( 0 );
|
||||||
|
slider->setMaximum( 2000 );
|
||||||
|
slider->setStepSize( 10 );
|
||||||
|
slider->setPageSize( 10 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||||
|
* This file may be used under the terms of the 3-clause BSD License
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SLIDER_PAGE_H
|
||||||
|
#define SLIDER_PAGE_H
|
||||||
|
|
||||||
|
#include "Page.h"
|
||||||
|
|
||||||
|
class SliderPage : public Page
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SliderPage( QQuickItem* = nullptr );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void populate();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,223 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "Slider.h"
|
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
|
||||||
|
|
||||||
#include <QskAspect.h>
|
|
||||||
#include <QskBoxBorderColors.h>
|
|
||||||
#include <QskBoxBorderMetrics.h>
|
|
||||||
#include <QskBoxShapeMetrics.h>
|
|
||||||
#include <QskFocusIndicator.h>
|
|
||||||
#include <QskLinearBox.h>
|
|
||||||
#include <QskObjectCounter.h>
|
|
||||||
#include <QskPushButton.h>
|
|
||||||
#include <QskRgbValue.h>
|
|
||||||
#include <QskSeparator.h>
|
|
||||||
#include <QskSlider.h>
|
|
||||||
#include <QskWindow.h>
|
|
||||||
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QtMath>
|
|
||||||
|
|
||||||
class OtherSlider : public QskSlider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Slider overriding many hints from the skin.
|
|
||||||
|
|
||||||
OtherSlider( QQuickItem* parentItem = nullptr )
|
|
||||||
: QskSlider( parentItem )
|
|
||||||
{
|
|
||||||
using namespace QskAspect;
|
|
||||||
using namespace QskRgbValue;
|
|
||||||
|
|
||||||
const qreal h = 30;
|
|
||||||
const qreal w = 2.0 * h;
|
|
||||||
const qreal paddingW = 0.5 * w + 1;
|
|
||||||
|
|
||||||
// Panel
|
|
||||||
|
|
||||||
for ( auto placement : { Horizontal, Vertical } )
|
|
||||||
{
|
|
||||||
const Aspect aspect = Panel | placement;
|
|
||||||
|
|
||||||
setMetric( aspect | Size, h );
|
|
||||||
setBoxShapeHint( aspect, 4 );
|
|
||||||
setBoxBorderMetricsHint( aspect, 1 );
|
|
||||||
setBoxBorderColorsHint( aspect, Grey900 );
|
|
||||||
setGradientHint( aspect, Grey400 );
|
|
||||||
|
|
||||||
if ( placement == Horizontal )
|
|
||||||
setMarginsHint( aspect | Padding, QMarginsF( paddingW, 0, paddingW, 0 ) );
|
|
||||||
else
|
|
||||||
setMarginsHint( aspect | Padding, QMarginsF( 0, paddingW, 0, paddingW ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Groove
|
|
||||||
|
|
||||||
for ( auto placement : { Horizontal, Vertical } )
|
|
||||||
{
|
|
||||||
const Aspect aspect = Groove | placement;
|
|
||||||
|
|
||||||
setMetric( aspect | Size, 4 );
|
|
||||||
setBoxBorderMetricsHint( aspect, 0 );
|
|
||||||
setBoxShapeHint( aspect, 1 );
|
|
||||||
|
|
||||||
setGradientHint( aspect, Qt::black );
|
|
||||||
}
|
|
||||||
|
|
||||||
// no Fill
|
|
||||||
for ( auto placement : { Horizontal, Vertical } )
|
|
||||||
{
|
|
||||||
const Aspect aspect = Fill | placement;
|
|
||||||
setMetric( aspect | Size, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle
|
|
||||||
|
|
||||||
for ( auto placement : { Horizontal, Vertical } )
|
|
||||||
{
|
|
||||||
const Aspect aspect = Handle | placement;
|
|
||||||
|
|
||||||
setBoxBorderMetricsHint( aspect, 1 );
|
|
||||||
setBoxShapeHint( aspect, 4 );
|
|
||||||
|
|
||||||
const qreal m = 0.5 * qCeil( 0.5 * ( w - h ) ) + 1;
|
|
||||||
|
|
||||||
if ( placement == Horizontal )
|
|
||||||
setMarginsHint( aspect | Margin, QMarginsF( -m, 0, -m, 0 ) );
|
|
||||||
else
|
|
||||||
setMarginsHint( aspect | Margin, QMarginsF( 0, -m, 0, -m ) );
|
|
||||||
|
|
||||||
for ( auto state : { NoState, Pressed } )
|
|
||||||
{
|
|
||||||
setBoxBorderColorsHint( aspect | state, Grey600 );
|
|
||||||
setGradientHint( aspect | state, Blue400 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SliderBox : public QskLinearBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SliderBox( QQuickItem* parentItem = nullptr )
|
|
||||||
: QskLinearBox( Qt::Vertical, parentItem )
|
|
||||||
{
|
|
||||||
auto slider = new QskSlider( this );
|
|
||||||
slider->setMinimum( 0 );
|
|
||||||
slider->setMaximum( 1000 );
|
|
||||||
slider->setPageSize( 10 );
|
|
||||||
slider->setStepSize( 10 );
|
|
||||||
slider->setSnap( true );
|
|
||||||
|
|
||||||
( void ) new QskSeparator( Qt::Horizontal, this );
|
|
||||||
|
|
||||||
auto otherSlider = new OtherSlider( this );
|
|
||||||
|
|
||||||
otherSlider->setMinimum( 0 );
|
|
||||||
otherSlider->setMaximum( 10 );
|
|
||||||
otherSlider->setStepSize( 1 );
|
|
||||||
|
|
||||||
auto customSlider = new Slider( this );
|
|
||||||
customSlider->setMargins( QMarginsF( 0, 15, 0, 15 ) );
|
|
||||||
customSlider->setSnap( true );
|
|
||||||
customSlider->setMinimum( 0 );
|
|
||||||
customSlider->setMaximum( 2000 );
|
|
||||||
customSlider->setStepSize( 10 );
|
|
||||||
customSlider->setPageSize( 10 );
|
|
||||||
|
|
||||||
for ( int i = 0; i < count(); i++ )
|
|
||||||
{
|
|
||||||
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
|
||||||
{
|
|
||||||
slider->setObjectName( "Slider " + QString::number( i + 1 ) );
|
|
||||||
slider->setValue( slider->minimum() +
|
|
||||||
0.5 * ( slider->maximum() - slider->minimum() ) );
|
|
||||||
#if 0
|
|
||||||
connect( slider, &QskSlider::valueChanged,
|
|
||||||
[]( qreal value ) { qDebug() << value; } );
|
|
||||||
#endif
|
|
||||||
slider->setLayoutAlignmentHint( Qt::AlignCenter );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void flip()
|
|
||||||
{
|
|
||||||
setOrientation( inverted( orientation() ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < count(); i++ )
|
|
||||||
{
|
|
||||||
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
|
|
||||||
{
|
|
||||||
const Qt::Orientation orientation = inverted( slider->orientation() );
|
|
||||||
|
|
||||||
slider->setOrientation( orientation );
|
|
||||||
|
|
||||||
if ( i >= count() - 1 )
|
|
||||||
{
|
|
||||||
// we didn't implement the vertical mode of the heavily
|
|
||||||
// customized slider yet.
|
|
||||||
|
|
||||||
slider->setVisible( orientation == Qt::Horizontal );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( auto separator = qobject_cast< QskSeparator* >( itemAtIndex( i ) ) )
|
|
||||||
{
|
|
||||||
separator->setOrientation( inverted( separator->orientation() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Qt::Orientation inverted( Qt::Orientation orientation ) const
|
|
||||||
{
|
|
||||||
return ( orientation == Qt::Horizontal ) ? Qt::Vertical : Qt::Horizontal;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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 buttonFlip = new QskPushButton( "Flip" );
|
|
||||||
buttonFlip->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
|
||||||
buttonFlip->setFocus( true );
|
|
||||||
|
|
||||||
auto sliderBox = new SliderBox();
|
|
||||||
sliderBox->setBackgroundColor( QskRgbValue::PeachPuff );
|
|
||||||
|
|
||||||
QObject::connect( buttonFlip, &QskPushButton::clicked,
|
|
||||||
sliderBox, &SliderBox::flip );
|
|
||||||
|
|
||||||
auto mainBox = new QskLinearBox( Qt::Vertical );
|
|
||||||
mainBox->setDefaultAlignment( Qt::AlignLeft );
|
|
||||||
mainBox->setMargins( 10 );
|
|
||||||
mainBox->setSpacing( 10 );
|
|
||||||
mainBox->addItem( buttonFlip );
|
|
||||||
mainBox->addItem( sliderBox );
|
|
||||||
mainBox->setStretchFactor( sliderBox, 10 );
|
|
||||||
|
|
||||||
auto focusIndicator = new QskFocusIndicator();
|
|
||||||
focusIndicator->setObjectName( "FocusIndicator" );
|
|
||||||
|
|
||||||
QskWindow window;
|
|
||||||
window.addItem( mainBox );
|
|
||||||
window.addItem( focusIndicator );
|
|
||||||
window.resize( 800, qMax( 480, int( mainBox->sizeHint().height() + 0.5 ) ) );
|
|
||||||
window.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
CONFIG += qskexample
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
Slider.cpp \
|
|
||||||
SliderSkinlet.cpp \
|
|
||||||
main.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
Slider.h \
|
|
||||||
SliderSkinlet.h
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
||||||
* This file may be used under the terms of the 3-clause BSD License
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
|
||||||
#include <SkinnyShortcut.h>
|
|
||||||
|
|
||||||
#include <QskLinearBox.h>
|
|
||||||
#include <QskObjectCounter.h>
|
|
||||||
#include <QskTextLabel.h>
|
|
||||||
#include <QskWindow.h>
|
|
||||||
|
|
||||||
#include <QGuiApplication>
|
|
||||||
|
|
||||||
class TextBox : public QskLinearBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextBox( QQuickItem* parent = nullptr )
|
|
||||||
: QskLinearBox( Qt::Vertical, 3, parent )
|
|
||||||
{
|
|
||||||
setMargins( 10 );
|
|
||||||
setDefaultAlignment( Qt::AlignTop );
|
|
||||||
setExtraSpacingAt( Qt::BottomEdge );
|
|
||||||
|
|
||||||
const QStringList texts =
|
|
||||||
{ "Default", "Tiny", "Small", "Medium", "Large", "Huge" };
|
|
||||||
|
|
||||||
for ( int i = 0; i < texts.size(); i++ )
|
|
||||||
{
|
|
||||||
auto label = new QskTextLabel( texts[ i ] + " Font", this );
|
|
||||||
label->setPanel( true );
|
|
||||||
label->setFontRole( i );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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 TextBox();
|
|
||||||
|
|
||||||
QskWindow window;
|
|
||||||
window.setColor( Qt::lightGray );
|
|
||||||
window.addItem( box );
|
|
||||||
window.resize( box->sizeHint().toSize() );
|
|
||||||
|
|
||||||
window.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
CONFIG += qskexample
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp
|
|
||||||
Loading…
Reference in New Issue