Merge branch 'master' of https://github.com/uwerat/qskinny
This commit is contained in:
commit
9fbcedfc2c
|
@ -428,6 +428,7 @@ void Editor::setupPushButton()
|
||||||
using namespace QskRgb;
|
using namespace QskRgb;
|
||||||
using Q = QskPushButton;
|
using Q = QskPushButton;
|
||||||
|
|
||||||
|
setFlagHint( Q::Panel | QskAspect::Direction, Qsk::LeftToRight );
|
||||||
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||||
setSpacing( Q::Panel, 4 );
|
setSpacing( Q::Panel, 4 );
|
||||||
|
|
||||||
|
@ -474,6 +475,8 @@ void Editor::setupPushButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPadding( Q::Graphic, 5 );
|
||||||
|
|
||||||
setAnimation( Q::Panel | A::Color, qskDuration );
|
setAnimation( Q::Panel | A::Color, qskDuration );
|
||||||
setAnimation( Q::Panel | A::Metric, qskDuration );
|
setAnimation( Q::Panel | A::Metric, qskDuration );
|
||||||
setAnimation( Q::Text | A::Color, qskDuration );
|
setAnimation( Q::Text | A::Color, qskDuration );
|
||||||
|
|
|
@ -566,7 +566,7 @@ void Editor::setupPushButton()
|
||||||
using Q = QskPushButton;
|
using Q = QskPushButton;
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
|
setFlagHint( Q::Panel | QskAspect::Direction, Qsk::TopToBottom );
|
||||||
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||||
|
|
||||||
setMargin( Q::Panel, 0 );
|
setMargin( Q::Panel, 0 );
|
||||||
|
@ -594,6 +594,9 @@ void Editor::setupPushButton()
|
||||||
|
|
||||||
setColor( Q::Text, m_pal.themeForeground );
|
setColor( Q::Text, m_pal.themeForeground );
|
||||||
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
||||||
|
|
||||||
|
// Graphic
|
||||||
|
setPadding( Q::Graphic, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setupDialogButton()
|
void Editor::setupDialogButton()
|
||||||
|
|
|
@ -32,6 +32,7 @@ class QSK_EXPORT QskAspect
|
||||||
NoPrimitive = 0,
|
NoPrimitive = 0,
|
||||||
|
|
||||||
Alignment,
|
Alignment,
|
||||||
|
Direction,
|
||||||
Style,
|
Style,
|
||||||
GraphicRole,
|
GraphicRole,
|
||||||
FontRole,
|
FontRole,
|
||||||
|
|
|
@ -77,12 +77,25 @@ QRectF QskPushButtonSkinlet::textRect(
|
||||||
|
|
||||||
if ( button->hasGraphic() )
|
if ( button->hasGraphic() )
|
||||||
{
|
{
|
||||||
// in case of having text + graphic we put the text at the bottom
|
const auto orientation = button->flagHint( QskPushButton::Panel | QskAspect::Direction, Qsk::LeftToRight );
|
||||||
|
|
||||||
|
switch( orientation )
|
||||||
|
{
|
||||||
|
case Qsk::LeftToRight:
|
||||||
|
{
|
||||||
|
const auto graphicsRect = subControlRect( button, contentsRect, QskPushButton::Graphic );
|
||||||
|
const auto spacing = button->metric( QskPushButton::Panel | QskAspect::Spacing );
|
||||||
|
r.setX( r.x() + graphicsRect.width() + spacing );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // Qsk::TopToBottom, the other ones are not handled yet
|
||||||
|
{
|
||||||
qreal h = button->effectiveFontHeight( QskPushButton::Text );
|
qreal h = button->effectiveFontHeight( QskPushButton::Text );
|
||||||
if ( h < r.height() )
|
if ( h < r.height() )
|
||||||
r.setTop( r.bottom() - h );
|
r.setTop( r.bottom() - h );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +107,10 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||||
|
|
||||||
auto r = button->subControlContentsRect( contentsRect, QskPushButton::Panel );
|
auto r = button->subControlContentsRect( contentsRect, QskPushButton::Panel );
|
||||||
|
|
||||||
if ( !button->text().isEmpty() )
|
const auto orientation = button->flagHint( QskPushButton::Panel
|
||||||
|
| QskAspect::Direction, Qsk::LeftToRight );
|
||||||
|
|
||||||
|
if ( !button->text().isEmpty() && orientation == Qsk::TopToBottom )
|
||||||
{
|
{
|
||||||
const auto textRect = subControlRect( button, contentsRect, QskPushButton::Text );
|
const auto textRect = subControlRect( button, contentsRect, QskPushButton::Text );
|
||||||
qreal h = textRect.height() + button->spacingHint( QskPushButton::Panel );
|
qreal h = textRect.height() + button->spacingHint( QskPushButton::Panel );
|
||||||
|
@ -106,6 +122,7 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto maxSize = button->graphicSourceSize();
|
const auto maxSize = button->graphicSourceSize();
|
||||||
|
|
||||||
if ( maxSize.width() >= 0 || maxSize.height() >= 0 )
|
if ( maxSize.width() >= 0 || maxSize.height() >= 0 )
|
||||||
{
|
{
|
||||||
// limiting the size by graphicSize
|
// limiting the size by graphicSize
|
||||||
|
@ -134,15 +151,34 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||||
const double scaleFactor =
|
const double scaleFactor =
|
||||||
qMin( r.width() / sz.width(), r.height() / sz.height() );
|
qMin( r.width() / sz.width(), r.height() / sz.height() );
|
||||||
|
|
||||||
|
const int w = qFloor( scaleFactor * sz.width() );
|
||||||
|
const int h = qFloor( scaleFactor * sz.height() );
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
const auto orientation = button->flagHint( QskPushButton::Panel
|
||||||
|
| QskAspect::Direction, Qsk::LeftToRight );
|
||||||
|
|
||||||
|
switch( orientation )
|
||||||
|
{
|
||||||
|
case Qsk::LeftToRight:
|
||||||
|
{
|
||||||
|
x = r.left();
|
||||||
|
y = r.top();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // TopToBottom
|
||||||
|
{
|
||||||
// early aligning to avoid pointless operations, that finally will
|
// early aligning to avoid pointless operations, that finally will
|
||||||
// have no effect, when drawing to an integer based paint device
|
// have no effect, when drawing to an integer based paint device
|
||||||
|
|
||||||
const int w = qFloor( scaleFactor * sz.width() );
|
x = qFloor( r.center().x() - 0.5 * w );
|
||||||
const int h = qFloor( scaleFactor * sz.height() );
|
y = qFloor( r.center().y() - 0.5 * h );
|
||||||
const int x = qFloor( r.center().x() - 0.5 * w );
|
}
|
||||||
const int y = qFloor( r.center().y() - 0.5 * h );
|
}
|
||||||
|
|
||||||
r = QRectF( x, y, w, h );
|
r = QRectF( x, y, w, h );
|
||||||
|
const auto padding = button->paddingHint( QskPushButton::Graphic );
|
||||||
|
r = r.marginsRemoved( padding );
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -213,11 +249,26 @@ QSizeF QskPushButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal padding = 2.0; // paddingHint( Graphic ) ???
|
const QMarginsF padding = button->paddingHint( QskPushButton::Graphic );
|
||||||
|
|
||||||
size.rheight() += 2 * padding + h;
|
const auto orientation = button->flagHint( QskPushButton::Panel
|
||||||
|
| QskAspect::Direction, Qsk::LeftToRight );
|
||||||
|
|
||||||
|
switch( orientation )
|
||||||
|
{
|
||||||
|
case Qsk::LeftToRight:
|
||||||
|
{
|
||||||
|
size.rwidth() += padding.left() + w + padding.right();
|
||||||
|
size.rheight() = qMax( size.height(), h );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // TopToBottom
|
||||||
|
{
|
||||||
|
size.rheight() += padding.top() + h + padding.bottom();
|
||||||
size.rwidth() = qMax( size.width(), w );
|
size.rwidth() = qMax( size.width(), w );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size = size.expandedTo( button->strutSizeHint( QskPushButton::Panel ) );
|
size = size.expandedTo( button->strutSizeHint( QskPushButton::Panel ) );
|
||||||
size = button->outerBoxSize( QskPushButton::Panel, size );
|
size = button->outerBoxSize( QskPushButton::Panel, size );
|
||||||
|
|
Loading…
Reference in New Issue