QskSkinnable::subControlRect introduced to avoid having to use

QskSkinlet in application code
This commit is contained in:
Uwe Rathmann 2017-08-28 10:15:47 +02:00
parent 93f5552a4e
commit 46da086092
8 changed files with 22 additions and 28 deletions

View File

@ -4,7 +4,6 @@
*****************************************************************************/
#include "QskBox.h"
#include "QskSkinlet.h"
QSK_SUBCONTROL( QskBox, Panel )
@ -19,7 +18,7 @@ QskBox::~QskBox()
QRectF QskBox::layoutRect() const
{
return innerBox( Panel, effectiveSkinlet()->subControlRect( this, Panel ) );
return innerBox( Panel, subControlRect( Panel ) );
}
QSizeF QskBox::contentsSizeHint() const

View File

@ -4,7 +4,6 @@
*****************************************************************************/
#include "QskScrollView.h"
#include "QskScrollViewSkinlet.h"
#include "QskPanGestureRecognizer.h"
#include "QskFlickAnimator.h"
#include "QskGesture.h"
@ -184,14 +183,14 @@ QRectF QskScrollView::viewContentsRect() const
{
// Border/Padding
const int bw = metric( Viewport | QskAspect::Border );
const QRectF r = effectiveSkinlet()->subControlRect( this, Viewport );
const QRectF r = subControlRect( Viewport );
return r.adjusted( bw, bw, -bw, -bw );
}
QRectF QskScrollView::gestureRect() const
{
return effectiveSkinlet()->subControlRect( this, Viewport );
return subControlRect( Viewport );
}
void QskScrollView::geometryChangeEvent( QskGeometryChangeEvent* event )
@ -204,12 +203,9 @@ void QskScrollView::geometryChangeEvent( QskGeometryChangeEvent* event )
void QskScrollView::mousePressEvent( QMouseEvent* event )
{
const QskScrollViewSkinlet* skinlet =
static_cast< const QskScrollViewSkinlet* >( effectiveSkinlet() );
if ( skinlet->subControlRect( this, VerticalScrollBar ).contains( event->pos() ) )
if ( subControlRect( VerticalScrollBar ).contains( event->pos() ) )
{
const QRectF handleRect = skinlet->subControlRect( this, VerticalScrollHandle );
const QRectF handleRect = subControlRect( VerticalScrollHandle );
if ( handleRect.contains( event->pos() ) )
{
@ -235,9 +231,9 @@ void QskScrollView::mousePressEvent( QMouseEvent* event )
return;
}
if ( skinlet->subControlRect( this, HorizontalScrollBar ).contains( event->pos() ) )
if ( subControlRect( HorizontalScrollBar ).contains( event->pos() ) )
{
const QRectF handleRect = skinlet->subControlRect( this, HorizontalScrollHandle );
const QRectF handleRect = subControlRect( HorizontalScrollHandle );
if ( handleRect.contains( event->pos() ) )
{
@ -279,8 +275,7 @@ void QskScrollView::mouseMoveEvent( QMouseEvent* event )
if ( m_data->isScrolling == Qt::Horizontal )
{
const qreal dx = event->x() - m_data->scrollPressPos;
const qreal w = effectiveSkinlet()->subControlRect(
this, HorizontalScrollBar ).width();
const qreal w = subControlRect( HorizontalScrollBar ).width();
pos.rx() += dx / w * m_data->scrollableSize.width();
m_data->scrollPressPos = event->x();
@ -288,8 +283,7 @@ void QskScrollView::mouseMoveEvent( QMouseEvent* event )
else if ( m_data->isScrolling == Qt::Vertical )
{
const qreal dy = event->y() - m_data->scrollPressPos;
const qreal h = effectiveSkinlet()->subControlRect(
this, VerticalScrollBar ).height();
const qreal h = subControlRect( VerticalScrollBar ).height();
pos.ry() += dy / h * m_data->scrollableSize.height();
m_data->scrollPressPos = event->y();

View File

@ -767,6 +767,11 @@ QskAspect::Subcontrol QskSkinnable::effectiveSubcontrol(
return subControl;
}
QRectF QskSkinnable::subControlRect( QskAspect::Subcontrol subControl ) const
{
return effectiveSkinlet()->subControlRect( this, subControl );
}
QskControl* QskSkinnable::controlCast()
{
return qskIsControl( this )

View File

@ -113,6 +113,8 @@ public:
QRectF innerBox( QskAspect::Aspect, const QRectF& outerBox ) const;
QRectF outerBox( QskAspect::Aspect, const QRectF& innerBox ) const;
QRectF subControlRect( QskAspect::Subcontrol ) const;
virtual const QskSkinlet* effectiveSkinlet() const;
QskSkin* effectiveSkin() const;

View File

@ -5,7 +5,6 @@
#include "QskSlider.h"
#include "QskAspect.h"
#include "QskSkinlet.h"
#include "QskAnimationHint.h"
#include <QtMath>
@ -119,7 +118,7 @@ QSizeF QskSlider::handleSize() const
QRectF QskSlider::handleRect() const
{
return effectiveSkinlet()->subControlRect( this, QskSlider::Handle );
return subControlRect( QskSlider::Handle );
}
void QskSlider::mousePressEvent( QMouseEvent* event )
@ -160,7 +159,7 @@ void QskSlider::mouseMoveEvent( QMouseEvent* event )
#endif
}
const auto r = effectiveSkinlet()->subControlRect( this, Scale );
const auto r = subControlRect( Scale );
qreal newValue;

View File

@ -5,7 +5,6 @@
#include "QskSubWindow.h"
#include "QskAspect.h"
#include "QskSkinlet.h"
#include "QskSkin.h"
#include "QskFunctions.h"
@ -121,7 +120,7 @@ bool QskSubWindow::testWindowButton( WindowButton button ) const
QRectF QskSubWindow::titleBarRect() const
{
return effectiveSkinlet()->subControlRect( this, QskSubWindow::TitleBar );
return subControlRect( QskSubWindow::TitleBar );
}
bool QskSubWindow::event( QEvent* event )
@ -134,7 +133,7 @@ bool QskSubWindow::event( QEvent* event )
QRectF QskSubWindow::layoutRect() const
{
return innerBox( Panel, effectiveSkinlet()->subControlRect( this, Panel ) );
return innerBox( Panel, subControlRect( Panel ) );
}
void QskSubWindow::updateLayout()

View File

@ -6,7 +6,6 @@
#include "QskSubWindowArea.h"
#include "QskSubWindow.h"
#include "QskGradient.h"
#include "QskSkinlet.h"
#include "QskFunctions.h"
#include "QskEvent.h"

View File

@ -9,7 +9,6 @@
#include "QskStackBox.h"
#include "QskStackBoxAnimator.h"
#include "QskAspect.h"
#include "QskSkinlet.h"
#include "QskAnimationHint.h"
QSK_SUBCONTROL( QskTabView, TabBar )
@ -224,10 +223,8 @@ bool QskTabView::event( QEvent* event )
void QskTabView::updateLayout()
{
const QskSkinlet* skinlet = effectiveSkinlet();
m_data->tabBar->setGeometry( skinlet->subControlRect( this, TabBar ) );
m_data->stackBox->setGeometry( skinlet->subControlRect( this, Page ) );
m_data->tabBar->setGeometry( subControlRect( TabBar ) );
m_data->stackBox->setGeometry( subControlRect( Page ) );
}
#include "moc_QskTabView.cpp"