Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ macro(qsk_setup_options)
option(BUILD_EXAMPLES "Build qskinny examples" ON)
option(BUILD_PLAYGROUND "Build qskinny playground" ON)

option(BUILD_UNITY "Enable unity builds" ON)

# we actually want to use cmake_dependent_option - minimum cmake version ??

option( BUILD_SVG2QVG_STANDALONE "Build svg2qvg without qskinny library dependency" ON )
Expand Down Expand Up @@ -81,7 +83,7 @@ endmacro()
############################################################################

project(QSkinny
LANGUAGES C CXX
LANGUAGES C CXX
HOMEPAGE_URL "https://github.com/uwerat/qskinny"
VERSION 0.8.0)

Expand Down Expand Up @@ -170,3 +172,11 @@ endif()
if(BUILD_PLAYGROUND)
add_subdirectory(playground)
endif()

if(BUILD_UNITY)
file(GLOB_RECURSE CPP_FILES
${CMAKE_CURRENT_BINARY_DIR}/*.cpp
)

set_source_files_properties(${CPP_FILES} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
4 changes: 2 additions & 2 deletions cmake/QskBuildFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function(qsk_add_executable target)
qt6_add_executable(${ARGV})

# we manually export our APIs to QML - might change in the future
set_target_properties(${target} PROPERTIES
set_target_properties(${target} PROPERTIES
QT_QML_MODULE_NO_IMPORT_SCAN 1)
else()
add_executable(${ARGV})
Expand Down Expand Up @@ -105,7 +105,7 @@ function(qsk_add_example target)
target_link_libraries(${target} PRIVATE qskqmlexport)
endif()

# for examples with subdirectories
# for examples with subdirectories
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_LIST_DIR})

endfunction()
Expand Down
3 changes: 3 additions & 0 deletions designsystems/fluent2/QskFluent2Skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ namespace
return static_cast< double >( value );
}

#ifndef __rgbGray
#define __rgbGray
inline constexpr QRgb rgbGray( int value, qreal opacity = 1.0 )
{
return qRgba( value, value, value, qRound( opacity * 255 ) );
}
#endif

/*
When application code is manipulating base colors manually the colors of
Expand Down
3 changes: 3 additions & 0 deletions designsystems/fluent2/QskFluent2Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

namespace
{
#ifndef __rgbGray
#define __rgbGray
inline constexpr QRgb rgbGray( int value, qreal opacity = 1.0 )
{
return qRgba( value, value, value, qRound( opacity * 255 ) );
}
#endif
}

QskFluent2Theme::QskFluent2Theme( QskSkin::ColorScheme colorScheme,
Expand Down
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,10 @@ set_target_properties(${target} PROPERTIES EXPORT_NAME ${PROJECT_NAME})
set_target_properties(${target} PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} )

if(BUILD_UNITY)
set_target_properties(${target} PROPERTIES UNITY_BUILD ON)
endif()

# packaging
set(PACKAGE_NAME ${PROJECT_NAME})

Expand Down Expand Up @@ -568,7 +572,7 @@ install(EXPORT ${PACKAGE_NAME}Targets
${PACKAGE_LOCATION})

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
install(FILES $<TARGET_PDB_FILE:${target}>
DESTINATION
install(FILES $<TARGET_PDB_FILE:${target}>
DESTINATION
${QSK_INSTALL_LIBS} OPTIONAL)
endif()
3 changes: 3 additions & 0 deletions src/common/QskArcMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ static inline QPainterPath qskOrthogonalPath(
return stroker.createStroke( arcPath );
}

#ifndef __qskInterpolated
#define __qskInterpolated
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
{
return from + ( to - from ) * ratio;
}
#endif

static inline qreal qskEffectiveThickness( qreal radius, qreal percentage )
{
Expand Down
11 changes: 7 additions & 4 deletions src/common/QskBoxShapeMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ static void qskRegisterBoxShapeMetrics()

Q_CONSTRUCTOR_FUNCTION( qskRegisterBoxShapeMetrics )

namespace QskBoxShapeMetricsImpl
{
static inline QSizeF qskInterpolatedSize(
const QSizeF& from, const QSizeF& to, qreal ratio )
{
return from + ( to - from ) * ratio;
}
}

static inline qreal qskAbsoluted( qreal length, qreal percentage )
{
Expand Down Expand Up @@ -150,10 +153,10 @@ QskBoxShapeMetrics QskBoxShapeMetrics::interpolated(
return to;

return QskBoxShapeMetrics(
qskInterpolatedSize( m_radii[ 0 ], to.m_radii[ 0 ], ratio ),
qskInterpolatedSize( m_radii[ 1 ], to.m_radii[ 1 ], ratio ),
qskInterpolatedSize( m_radii[ 2 ], to.m_radii[ 2 ], ratio ),
qskInterpolatedSize( m_radii[ 3 ], to.m_radii[ 3 ], ratio ),
QskBoxShapeMetricsImpl::qskInterpolatedSize( m_radii[ 0 ], to.m_radii[ 0 ], ratio ),
QskBoxShapeMetricsImpl::qskInterpolatedSize( m_radii[ 1 ], to.m_radii[ 1 ], ratio ),
QskBoxShapeMetricsImpl::qskInterpolatedSize( m_radii[ 2 ], to.m_radii[ 2 ], ratio ),
QskBoxShapeMetricsImpl::qskInterpolatedSize( m_radii[ 3 ], to.m_radii[ 3 ], ratio ),
to.m_sizeMode, to.m_scalingMode );
}

Expand Down
4 changes: 3 additions & 1 deletion src/common/QskGraduationMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ static void qskRegisterGraduationMetrics()

Q_CONSTRUCTOR_FUNCTION( qskRegisterGraduationMetrics )

#ifndef __qskInterpolated
#define __qskInterpolated
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
{
return from + ( to - from ) * ratio;
}

#endif
QskGraduationMetrics QskGraduationMetrics::interpolated(
const QskGraduationMetrics& to, const qreal ratio ) const noexcept
{
Expand Down
3 changes: 3 additions & 0 deletions src/common/QskMargins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ static void qskRegisterMargins()

Q_CONSTRUCTOR_FUNCTION( qskRegisterMargins )

#ifndef __qskInterpolated
#define __qskInterpolated
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
{
return from + ( to - from ) * ratio;
}
#endif

static inline QskMargins qskInterpolateMargins(
const QskMargins& m1, const QskMargins& m2, qreal progress )
Expand Down
3 changes: 3 additions & 0 deletions src/common/QskShadowMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ static void qskRegisterShadowMetrics()

Q_CONSTRUCTOR_FUNCTION( qskRegisterShadowMetrics )

#ifndef __qskInterpolated
#define __qskInterpolated
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
{
return from + ( to - from ) * ratio;
}
#endif

static inline qreal qskToAbsolute( qreal length, qreal percentage )
{
Expand Down
3 changes: 3 additions & 0 deletions src/common/QskStippleMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ QVector< qreal > qskDashPattern( Qt::PenStyle style )
return pattern[ style ];
}

#ifndef __qskInterpolated
#define __qskInterpolated
static inline qreal qskInterpolated( qreal from, qreal to, qreal ratio )
{
return from + ( to - from ) * ratio;
}
#endif

static inline QVector< qreal > qskInterpolatedSpaces(
const QVector< qreal >& pattern, qreal progress )
Expand Down
3 changes: 3 additions & 0 deletions src/controls/QskControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ QSK_SYSTEM_STATE( QskControl, Disabled, QskAspect::FirstSystemState )
QSK_SYSTEM_STATE( QskControl, Hovered, QskAspect::LastSystemState >> 1 )
QSK_SYSTEM_STATE( QskControl, Focused, QskAspect::LastSystemState )

#ifndef __qskSendEventTo
#define __qskSendEventTo
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
{
QEvent event( type );
QCoreApplication::sendEvent( object, &event );
}
#endif

static inline bool qskMaybeGesture( QQuickItem* item,
const QQuickItem* child, const QEvent* event )
Expand Down
3 changes: 3 additions & 0 deletions src/controls/QskControlPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#include "QskWindow.h"
#include "QskEvent.h"

#ifndef __qskSendEventTo
#define __qskSendEventTo
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
{
QEvent event( type );
QCoreApplication::sendEvent( object, &event );
}
#endif

extern bool qskInheritLocale( QskWindow*, const QLocale& );

Expand Down
3 changes: 3 additions & 0 deletions src/controls/QskItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ QSK_QT_PRIVATE_END

#include <unordered_set>

#ifndef __qskSendEventTo
#define __qskSendEventTo
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
{
QEvent event( type );
QCoreApplication::sendEvent( object, &event );
}
#endif

static inline void qskApplyUpdateFlags(
QskItem::UpdateFlags flags, QskItem* item )
Expand Down
3 changes: 3 additions & 0 deletions src/controls/QskItemPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
#include "QskTreeNode.h"
#include "QskSetup.h"

#ifndef __qskSendEventTo
#define __qskSendEventTo
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
{
QEvent event( type );
QCoreApplication::sendEvent( object, &event );
}
#endif

QskItemPrivate::QskItemPrivate()
: updateFlags( QskSetup::updateFlags() )
Expand Down
24 changes: 11 additions & 13 deletions src/controls/QskProgressBarSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <qeasingcurve.h>
#include <cmath>

using Q = QskProgressBar;

namespace
{
QskIntervalF qskFillInterval( const QskProgressIndicator* indicator )
Expand Down Expand Up @@ -66,11 +64,11 @@ QRectF QskProgressBarSkinlet::subControlRect(
const QskSkinnable* skinnable, const QRectF& contentsRect,
QskAspect::Subcontrol subControl ) const
{
const auto bar = static_cast< const Q* >( skinnable );
const auto bar = static_cast< const QskProgressBar* >( skinnable );

if( subControl == Q::Groove )
if( subControl == QskProgressBar::Groove )
{
const auto grooveSize = bar->metric( Q::Groove | QskAspect::Size );
const auto grooveSize = bar->metric( QskProgressBar::Groove | QskAspect::Size );

auto rect = contentsRect;
if ( bar->orientation() == Qt::Horizontal )
Expand All @@ -87,7 +85,7 @@ QRectF QskProgressBarSkinlet::subControlRect(
return rect;
}

if( subControl == Q::Fill )
if( subControl == QskProgressBar::Fill )
{
return barRect( bar );
}
Expand All @@ -98,15 +96,15 @@ QRectF QskProgressBarSkinlet::subControlRect(
QSGNode* QskProgressBarSkinlet::updateGrooveNode(
const QskProgressIndicator* indicator, QSGNode* node ) const
{
return updateBoxNode( indicator, node, Q::Groove );
return updateBoxNode( indicator, node, QskProgressBar::Groove );
}

QSGNode* QskProgressBarSkinlet::updateFillNode(
const QskProgressIndicator* indicator, QSGNode* node ) const
{
const auto bar = static_cast< const Q* >( indicator );
const auto bar = static_cast< const QskProgressBar* >( indicator );

const auto subControl = Q::Fill;
const auto subControl = QskProgressBar::Fill;

const auto rect = indicator->subControlRect( subControl );
if ( rect.isEmpty() )
Expand Down Expand Up @@ -146,11 +144,11 @@ QSGNode* QskProgressBarSkinlet::updateFillNode(
return updateBoxNode( indicator, node, rect, gradient, subControl );
}

QRectF QskProgressBarSkinlet::barRect( const Q* bar ) const
QRectF QskProgressBarSkinlet::barRect( const QskProgressBar* bar ) const
{
const auto subControl = Q::Groove;
const auto subControl = QskProgressBar::Groove;

const auto barSize = bar->metric( Q::Fill | QskAspect::Size );
const auto barSize = bar->metric( QskProgressBar::Fill | QskAspect::Size );
auto rect = bar->subControlRect( subControl );

if ( bar->orientation() == Qt::Horizontal )
Expand Down Expand Up @@ -197,7 +195,7 @@ QSizeF QskProgressBarSkinlet::sizeHint( const QskSkinnable* skinnable,
if ( which != Qt::PreferredSize )
return QSizeF();

const auto bar = static_cast< const Q* >( skinnable );
const auto bar = static_cast< const QskProgressBar* >( skinnable );

const auto extent = bar->extent();

Expand Down
16 changes: 7 additions & 9 deletions src/controls/QskProgressRingSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "QskProgressRing.h"
#include "QskIntervalF.h"

using Q = QskProgressRing;

QskProgressRingSkinlet::QskProgressRingSkinlet( QskSkin* skin )
: Inherited( skin )
{
Expand All @@ -23,7 +21,7 @@ QRectF QskProgressRingSkinlet::subControlRect(
const QskSkinnable* skinnable, const QRectF& contentsRect,
QskAspect::Subcontrol subControl ) const
{
if( subControl == Q::Groove || subControl == Q::Fill )
if( subControl == QskProgressRing::Groove || subControl == QskProgressRing::Fill )
return contentsRect;

return Inherited::subControlRect( skinnable, contentsRect, subControl );
Expand All @@ -32,15 +30,15 @@ QRectF QskProgressRingSkinlet::subControlRect(
QSGNode* QskProgressRingSkinlet::updateGrooveNode(
const QskProgressIndicator* indicator, QSGNode* node ) const
{
return updateArcNode( indicator, node, Q::Groove );
return updateArcNode( indicator, node, QskProgressRing::Groove );
}

QSGNode* QskProgressRingSkinlet::updateFillNode(
const QskProgressIndicator* indicator, QSGNode* node ) const
{
const auto ring = static_cast< const Q* >( indicator );
const auto ring = static_cast< const QskProgressRing* >( indicator );

const auto subControl = Q::Fill;
const auto subControl = QskProgressRing::Fill;

const auto rect = ring->subControlRect( subControl );
if ( rect.isEmpty() )
Expand Down Expand Up @@ -79,16 +77,16 @@ QSizeF QskProgressRingSkinlet::sizeHint( const QskSkinnable* skinnable,
if ( which != Qt::PreferredSize )
return QSizeF();

auto hint = skinnable->strutSizeHint( Q::Fill );
hint = hint.expandedTo( skinnable->strutSizeHint( Q::Groove ) );
auto hint = skinnable->strutSizeHint( QskProgressRing::Fill );
hint = hint.expandedTo( skinnable->strutSizeHint( QskProgressRing::Groove ) );

if ( !constraint.isEmpty() )
{
const qreal aspectRatio = hint.isEmpty() ? 1.0 : hint.width() / hint.height();

if ( constraint.width() >= 0.0 )
hint.setHeight( constraint.width() / aspectRatio );
else
else
hint.setWidth( constraint.height() * aspectRatio );
}

Expand Down
Loading