tab button: Fix size hint
... and style properly for Material
This commit is contained in:
parent
0c17aa3a81
commit
d0934cb0fd
@ -984,7 +984,7 @@ void Editor::setupTabButton()
|
|||||||
using A = QskAspect;
|
using A = QskAspect;
|
||||||
using Q = QskTabButton;
|
using Q = QskTabButton;
|
||||||
|
|
||||||
setStrutSize( Q::Panel, 48_dp, 48_dp );
|
setStrutSize( Q::Panel, 48_dp, 64_dp );
|
||||||
setGradient( Q::Panel, m_pal.surface );
|
setGradient( Q::Panel, m_pal.surface );
|
||||||
|
|
||||||
setColor( Q::Text, m_pal.onSurfaceVariant );
|
setColor( Q::Text, m_pal.onSurfaceVariant );
|
||||||
@ -994,44 +994,15 @@ void Editor::setupTabButton()
|
|||||||
setColor( Q::Text | Q::Checked, m_pal.primary );
|
setColor( Q::Text | Q::Checked, m_pal.primary );
|
||||||
setColor( Q::Text | Q::Hovered, m_pal.primary );
|
setColor( Q::Text | Q::Hovered, m_pal.primary );
|
||||||
|
|
||||||
for ( const auto variation : { A::Left, A::Right, A::Top, A::Bottom } )
|
|
||||||
{
|
|
||||||
const auto aspect = Q::Panel | variation;
|
|
||||||
|
|
||||||
Qt::Edge edge;
|
|
||||||
|
|
||||||
switch( variation )
|
|
||||||
{
|
|
||||||
case A::Left:
|
|
||||||
edge = Qt::RightEdge;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case A::Right:
|
|
||||||
edge = Qt::LeftEdge;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case A::Top:
|
|
||||||
edge = Qt::BottomEdge;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case A::Bottom:
|
|
||||||
edge = Qt::TopEdge;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
edge = Qt::Edge( 0 ); // making gcc4 happy
|
|
||||||
}
|
|
||||||
|
|
||||||
QskBoxBorderMetrics border;
|
QskBoxBorderMetrics border;
|
||||||
border.setWidthAt( edge, 3_dp );
|
border.setWidthAt( Qt::BottomEdge, 3_dp );
|
||||||
setBoxBorderMetrics( aspect, border );
|
setBoxBorderMetrics( Q::Panel, border );
|
||||||
|
|
||||||
QskBoxBorderColors borderColors( m_pal.surface );
|
QskBoxBorderColors borderColors( m_pal.surface );
|
||||||
setBoxBorderColors( aspect, borderColors );
|
setBoxBorderColors( Q::Panel, borderColors );
|
||||||
|
|
||||||
borderColors.setGradientAt( edge, m_pal.primary );
|
borderColors.setGradientAt( Qt::BottomEdge, m_pal.primary );
|
||||||
setBoxBorderColors( aspect | Q::Checked, borderColors );
|
setBoxBorderColors( Q::Panel | Q::Checked, borderColors );
|
||||||
}
|
|
||||||
|
|
||||||
setGradient( Q::Panel | Q::Hovered,
|
setGradient( Q::Panel | Q::Hovered,
|
||||||
QskRgb::toTransparentF( m_pal.surface, m_pal.hoverOpacity ) );
|
QskRgb::toTransparentF( m_pal.surface, m_pal.hoverOpacity ) );
|
||||||
|
@ -57,20 +57,26 @@ QSGNode* QskTabButtonSkinlet::updateSubNode(
|
|||||||
QSizeF QskTabButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
|
QSizeF QskTabButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
Qt::SizeHint which, const QSizeF& ) const
|
Qt::SizeHint which, const QSizeF& ) const
|
||||||
{
|
{
|
||||||
|
using Q = QskTabButton;
|
||||||
|
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
const auto tabButton = static_cast< const QskTabButton* >( skinnable );
|
const auto tabButton = static_cast< const QskTabButton* >( skinnable );
|
||||||
|
|
||||||
auto size = tabButton->strutSizeHint( QskTabButton::Panel );
|
QSizeF size;
|
||||||
const auto text = tabButton->text();
|
const auto text = tabButton->text();
|
||||||
|
|
||||||
if ( !text.isEmpty() )
|
if ( !text.isEmpty() )
|
||||||
{
|
{
|
||||||
const QFontMetricsF fm( tabButton->effectiveFont( QskTabButton::Text ) );
|
const QFontMetricsF fm( tabButton->effectiveFont( QskTabButton::Text ) );
|
||||||
size += fm.size( Qt::TextShowMnemonic, text );
|
size = fm.size( Qt::TextShowMnemonic, text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size = tabButton->outerBoxSize( Q::Panel, size );
|
||||||
|
size = size.expandedTo( tabButton->strutSizeHint( Q::Panel ) );
|
||||||
|
size = size.grownBy( skinnable->marginHint( Q::Panel ) );
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user