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 Q = QskPushButton;
|
||||
|
||||
setFlagHint( Q::Panel | QskAspect::Direction, Qsk::LeftToRight );
|
||||
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||
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::Metric, qskDuration );
|
||||
setAnimation( Q::Text | A::Color, qskDuration );
|
||||
|
@ -566,7 +566,7 @@ void Editor::setupPushButton()
|
||||
using Q = QskPushButton;
|
||||
|
||||
// Panel
|
||||
|
||||
setFlagHint( Q::Panel | QskAspect::Direction, Qsk::TopToBottom );
|
||||
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||
|
||||
setMargin( Q::Panel, 0 );
|
||||
@ -594,6 +594,9 @@ void Editor::setupPushButton()
|
||||
|
||||
setColor( Q::Text, m_pal.themeForeground );
|
||||
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
||||
|
||||
// Graphic
|
||||
setPadding( Q::Graphic, 2 );
|
||||
}
|
||||
|
||||
void Editor::setupDialogButton()
|
||||
|
@ -32,6 +32,7 @@ class QSK_EXPORT QskAspect
|
||||
NoPrimitive = 0,
|
||||
|
||||
Alignment,
|
||||
Direction,
|
||||
Style,
|
||||
GraphicRole,
|
||||
FontRole,
|
||||
|
@ -77,11 +77,24 @@ QRectF QskPushButtonSkinlet::textRect(
|
||||
|
||||
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 );
|
||||
|
||||
qreal h = button->effectiveFontHeight( QskPushButton::Text );
|
||||
if ( h < r.height() )
|
||||
r.setTop( r.bottom() - h );
|
||||
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 );
|
||||
if ( h < r.height() )
|
||||
r.setTop( r.bottom() - h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
@ -94,7 +107,10 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||
|
||||
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 );
|
||||
qreal h = textRect.height() + button->spacingHint( QskPushButton::Panel );
|
||||
@ -106,6 +122,7 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||
}
|
||||
|
||||
const auto maxSize = button->graphicSourceSize();
|
||||
|
||||
if ( maxSize.width() >= 0 || maxSize.height() >= 0 )
|
||||
{
|
||||
// limiting the size by graphicSize
|
||||
@ -134,15 +151,34 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||
const double scaleFactor =
|
||||
qMin( r.width() / sz.width(), r.height() / sz.height() );
|
||||
|
||||
// early aligning to avoid pointless operations, that finally will
|
||||
// have no effect, when drawing to an integer based paint device
|
||||
|
||||
const int w = qFloor( scaleFactor * sz.width() );
|
||||
const int h = qFloor( scaleFactor * sz.height() );
|
||||
const int x = qFloor( r.center().x() - 0.5 * w );
|
||||
const int y = qFloor( r.center().y() - 0.5 * h );
|
||||
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
|
||||
// have no effect, when drawing to an integer based paint device
|
||||
|
||||
x = qFloor( r.center().x() - 0.5 * w );
|
||||
y = qFloor( r.center().y() - 0.5 * h );
|
||||
}
|
||||
}
|
||||
|
||||
r = QRectF( x, y, w, h );
|
||||
const auto padding = button->paddingHint( QskPushButton::Graphic );
|
||||
r = r.marginsRemoved( padding );
|
||||
}
|
||||
|
||||
return r;
|
||||
@ -213,10 +249,25 @@ 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;
|
||||
size.rwidth() = qMax( size.width(), w );
|
||||
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 = size.expandedTo( button->strutSizeHint( QskPushButton::Panel ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user