diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index e496a556..87b53ccf 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -247,9 +247,9 @@ void Editor::setupMenu() setBoxBorderMetrics( Q::Separator, 0 ); setGradient( Q::Separator, m_pal.darker125 ); - setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) ); - setSpacing( Q::Cell, 5 ); - setGradient( Q::Cell, Qt::transparent ); + setPadding( Q::Segment, QskMargins( 2, 10, 2, 10 ) ); + setSpacing( Q::Segment, 5 ); + setGradient( Q::Segment, Qt::transparent ); setGradient( Q::Cursor, m_pal.accentColor ); diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index fd45d94a..afc1777f 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -346,9 +346,9 @@ void Editor::setupMenu() setMetric( Q::Separator | A::Size, qskDpiScaled( 2 ) ); setSeparator( Q::Separator | A::Horizontal ); - setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) ); - setSpacing( Q::Cell, 5 ); - setGradient( Q::Cell, Qt::transparent ); + setPadding( Q::Segment, QskMargins( 2, 10, 2, 10 ) ); + setSpacing( Q::Segment, 5 ); + setGradient( Q::Segment, Qt::transparent ); setGradient( Q::Cursor, m_pal.highlighted ); diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index 249765e4..54a329d1 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -13,7 +13,7 @@ #include QSK_SUBCONTROL( QskMenu, Panel ) -QSK_SUBCONTROL( QskMenu, Cell ) +QSK_SUBCONTROL( QskMenu, Segment ) QSK_SUBCONTROL( QskMenu, Cursor ) QSK_SUBCONTROL( QskMenu, Text ) QSK_SUBCONTROL( QskMenu, Graphic ) @@ -30,8 +30,11 @@ namespace : graphicSource( graphicSource ) , text( text ) { +#if 1 + // lazy loading TODO ... if( !graphicSource.isEmpty() ) graphic = Qsk::loadGraphic( graphicSource ); +#endif } QUrl graphicSource; @@ -287,19 +290,16 @@ void QskMenu::traverse( int steps ) if ( newIndex < 0 ) newIndex += count(); - if ( hasAnimationHint( Cursor | QskAspect::Position | QskAspect::Metric ) ) - { - // when cycling we want slide in + // when cycling we want slide in - if ( index < 0 ) - setPositionHint( Cursor, count() ); + int startIndex = m_data->currentIndex; - if ( index >= count() ) - setPositionHint( Cursor, -1 ); - - movePositionHint( Cursor, newIndex ); - } + if ( index < 0 ) + startIndex = count(); + else if ( index >= count() ) + startIndex = -1; + movePositionHint( Cursor, startIndex, newIndex ); setCurrentIndex( newIndex ); } @@ -374,13 +374,13 @@ void QskMenu::setSelectedIndex( int index ) QRectF QskMenu::cellRect( int index ) const { return effectiveSkinlet()->sampleRect( - this, contentsRect(), QskMenu::Cell, index ); + this, contentsRect(), QskMenu::Segment, index ); } int QskMenu::indexAtPosition( const QPointF& pos ) const { return effectiveSkinlet()->sampleIndexAt( - this, contentsRect(), QskMenu::Cell, pos ); + this, contentsRect(), QskMenu::Segment, pos ); } int QskMenu::exec() diff --git a/src/controls/QskMenu.h b/src/controls/QskMenu.h index 3ab551e6..beb3261d 100644 --- a/src/controls/QskMenu.h +++ b/src/controls/QskMenu.h @@ -32,7 +32,7 @@ class QSK_EXPORT QskMenu : public QskPopup using Inherited = QskPopup; public: - QSK_SUBCONTROLS( Panel, Cell, Cursor, Text, Graphic, Separator ) + QSK_SUBCONTROLS( Panel, Segment, Cursor, Text, Graphic, Separator ) QSK_STATES( Selected ) QskMenu( QQuickItem* parentItem = nullptr ); @@ -45,7 +45,7 @@ class QSK_EXPORT QskMenu : public QskPopup void setOrigin( const QPointF& ); QPointF origin() const; - void setTextOptions( const QskTextOptions& textOptions ); + void setTextOptions( const QskTextOptions& ); QskTextOptions textOptions() const; // insert, remove, functors, actions, QskGraphic ... diff --git a/src/controls/QskMenuSkinlet.cpp b/src/controls/QskMenuSkinlet.cpp index 356fde4c..fc151bff 100644 --- a/src/controls/QskMenuSkinlet.cpp +++ b/src/controls/QskMenuSkinlet.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -60,7 +59,7 @@ class QskMenuSkinlet::PrivateData void enableCache( bool on ) { m_isCaching = on; - m_cellHeight = m_cellWidth = m_graphicWidth = m_textWidth = -1.0; + m_segmentHeight = m_segmentWidth = m_graphicWidth = m_textWidth = -1.0; } inline int separatorsBefore( const QskMenu* menu, int index ) const @@ -101,30 +100,30 @@ class QskMenuSkinlet::PrivateData return textWidthInternal( menu ); } - inline qreal cellWidth( const QskMenu* menu ) const + inline qreal segmentWidth( const QskMenu* menu ) const { if ( m_isCaching ) { - if ( m_cellWidth < 0.0 ) - m_cellWidth = cellWidthInternal( menu ); + if ( m_segmentWidth < 0.0 ) + m_segmentWidth = segmentWidthInternal( menu ); - return m_cellWidth; + return m_segmentWidth; } - return cellWidthInternal( menu ); + return segmentWidthInternal( menu ); } - inline qreal cellHeight( const QskMenu* menu ) const + inline qreal segmentHeight( const QskMenu* menu ) const { if ( m_isCaching ) { - if ( m_cellHeight < 0.0 ) - m_cellHeight = cellHeightInternal( menu ); + if ( m_segmentHeight < 0.0 ) + m_segmentHeight = segmentHeightInternal( menu ); - return m_cellHeight; + return m_segmentHeight; } - return cellHeightInternal( menu ); + return segmentHeightInternal( menu ); } private: @@ -182,33 +181,33 @@ class QskMenuSkinlet::PrivateData return maxWidth; } - qreal cellWidthInternal( const QskMenu* menu ) const + qreal segmentWidthInternal( const QskMenu* menu ) const { using Q = QskMenu; - const auto spacing = menu->spacingHint( Q::Cell ); - const auto padding = menu->paddingHint( Q::Cell ); + const auto spacing = menu->spacingHint( Q::Segment ); + const auto padding = menu->paddingHint( Q::Segment ); auto w = graphicWidth( menu ) + spacing + textWidth( menu ); w += padding.left() + padding.right(); - const auto minWidth = menu->strutSizeHint( Q::Cell ).width(); + const auto minWidth = menu->strutSizeHint( Q::Segment ).width(); return qMax( w, minWidth ); } - qreal cellHeightInternal( const QskMenu* menu ) const + qreal segmentHeightInternal( const QskMenu* menu ) const { using Q = QskMenu; const auto graphicHeight = menu->strutSizeHint( Q::Graphic ).height(); const auto textHeight = menu->effectiveFontHeight( Q::Text ); - const auto padding = menu->paddingHint( Q::Cell ); + const auto padding = menu->paddingHint( Q::Segment ); qreal h = qMax( graphicHeight, textHeight ); h += padding.top() + padding.bottom(); - const auto minHeight = menu->strutSizeHint( Q::Cell ).height(); + const auto minHeight = menu->strutSizeHint( Q::Segment ).height(); h = qMax( h, minHeight ); return h; @@ -218,8 +217,8 @@ class QskMenuSkinlet::PrivateData mutable qreal m_graphicWidth = -1.0; mutable qreal m_textWidth = -1.0; - mutable qreal m_cellHeight = -1.0; - mutable qreal m_cellWidth = -1.0; + mutable qreal m_segmentHeight = -1.0; + mutable qreal m_segmentWidth = -1.0; }; QskMenuSkinlet::QskMenuSkinlet( QskSkin* skin ) @@ -234,10 +233,10 @@ QskMenuSkinlet::~QskMenuSkinlet() = default; QRectF QskMenuSkinlet::cursorRect( const QskSkinnable* skinnable, const QRectF& contentsRect, int index ) const { - const auto count = sampleCount( skinnable, QskMenu::Cell ); + const auto count = sampleCount( skinnable, QskMenu::Segment ); auto rect = sampleRect( skinnable, contentsRect, - QskMenu::Cell, qBound( 0, index, count ) ); + QskMenu::Segment, qBound( 0, index, count ) ); if ( index < 0 ) rect.setBottom( rect.top() ); @@ -295,11 +294,11 @@ QRectF QskMenuSkinlet::sampleRect( const auto menu = static_cast< const QskMenu* >( skinnable ); - if ( subControl == Q::Cell ) + if ( subControl == Q::Segment ) { const auto r = menu->subControlContentsRect( Q::Panel ); - auto h = m_data->cellHeight( menu ); + auto h = m_data->segmentHeight( menu ); if ( int n = m_data->separatorsBefore( menu, index ) ) { @@ -314,7 +313,7 @@ QRectF QskMenuSkinlet::sampleRect( if ( subControl == QskMenu::Graphic || subControl == QskMenu::Text ) { - const auto r = sampleRect( menu, contentsRect, Q::Cell, index ); + const auto r = sampleRect( menu, contentsRect, Q::Segment, index ); const auto graphicWidth = m_data->graphicWidth( menu ); if ( subControl == QskMenu::Graphic ) @@ -330,7 +329,7 @@ QRectF QskMenuSkinlet::sampleRect( if ( graphicWidth > 0.0 ) { - const auto spacing = skinnable->spacingHint( Q::Cell ); + const auto spacing = skinnable->spacingHint( Q::Segment ); textRect.setX( r.x() + graphicWidth + spacing ); } @@ -348,8 +347,8 @@ QRectF QskMenuSkinlet::sampleRect( if ( pos < menu->count() ) { - const auto cellRect = sampleRect( skinnable, contentsRect, Q::Cell, pos ); - r.setBottom( cellRect.top() ); // spacing ??? + const auto segmentRect = sampleRect( skinnable, contentsRect, Q::Segment, pos ); + r.setBottom( segmentRect.top() ); // spacing ??? } const qreal h = menu->metric( Q::Separator | QskAspect::Size ); @@ -375,7 +374,7 @@ int QskMenuSkinlet::sampleCount( { using Q = QskMenu; - if ( subControl == Q::Cell || subControl == Q::Graphic || subControl == Q::Text ) + if ( subControl == Q::Segment || subControl == Q::Graphic || subControl == Q::Text ) { const auto menu = static_cast< const QskMenu* >( skinnable ); return menu->count(); @@ -397,7 +396,7 @@ QskAspect::States QskMenuSkinlet::sampleStates( auto states = Inherited::sampleStates( skinnable, subControl, index ); - if ( subControl == Q::Cell || subControl == Q::Graphic || subControl == Q::Text ) + if ( subControl == Q::Segment || subControl == Q::Graphic || subControl == Q::Text ) { const auto menu = static_cast< const QskMenu* >( skinnable ); if ( menu->currentIndex() == index ) @@ -433,8 +432,8 @@ QSGNode* QskMenuSkinlet::updateContentsNode( QSGNode* QskMenuSkinlet::updateMenuNode( const QskSkinnable* skinnable, QSGNode* contentsNode ) const { - enum { Panel, Cell, Cursor, Graphic, Text, Separator }; - static QVector< quint8 > roles = { Panel, Separator, Cell, Cursor, Graphic, Text }; + enum { Panel, Segment, Cursor, Graphic, Text, Separator }; + static QVector< quint8 > roles = { Panel, Separator, Segment, Cursor, Graphic, Text }; if ( contentsNode == nullptr ) contentsNode = new QSGNode(); @@ -452,9 +451,9 @@ QSGNode* QskMenuSkinlet::updateMenuNode( newNode = updateBoxNode( skinnable, oldNode, QskMenu::Panel ); break; } - case Cell: + case Segment: { - newNode = updateSeriesNode( skinnable, QskMenu::Cell, oldNode ); + newNode = updateSeriesNode( skinnable, QskMenu::Segment, oldNode ); break; } case Cursor: @@ -494,7 +493,7 @@ QSGNode* QskMenuSkinlet::updateSampleNode( const QskSkinnable* skinnable, const auto rect = sampleRect( menu, menu->contentsRect(), subControl, index ); - if ( subControl == Q::Cell ) + if ( subControl == Q::Segment ) { return updateBoxNode( menu, node, rect, subControl ); } @@ -522,7 +521,7 @@ QSGNode* QskMenuSkinlet::updateSampleNode( const QskSkinnable* skinnable, subControl, Qt::AlignVCenter | Qt::AlignLeft ); return QskSkinlet::updateTextNode( menu, node, rect, alignment, - text, QskTextOptions(), Q::Text ); + text, menu->textOptions(), Q::Text ); } if ( subControl == Q::Separator ) @@ -547,10 +546,10 @@ QSizeF QskMenuSkinlet::sizeHint( const QskSkinnable* skinnable, qreal w = 0.0; qreal h = 0.0; - if ( const auto count = sampleCount( skinnable, Q::Cell ) ) + if ( const auto count = sampleCount( skinnable, Q::Segment ) ) { - w = m_data->cellWidth( menu ); - h = count * m_data->cellHeight( menu ); + w = m_data->segmentWidth( menu ); + h = count * m_data->segmentHeight( menu ); } if ( const auto count = sampleCount( skinnable, Q::Separator ) )