QskFusionSkin focus settings + using Qt's metaobject system to avoid
some boilerplate code
This commit is contained in:
parent
7ab5c50b3d
commit
4a628bd72d
@ -60,8 +60,24 @@
|
|||||||
|
|
||||||
static const int qskDuration = 50;
|
static const int qskDuration = 50;
|
||||||
|
|
||||||
|
/*
|
||||||
|
QskFocusIndicator has this nice autohide concept, that supersedes
|
||||||
|
the Qt/Quick visualFocus. How to do the same with the built-in focus
|
||||||
|
indication of the skins. TODO ...
|
||||||
|
*/
|
||||||
|
// #define SHOW_FOCUS
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
class Combination : public QskStateCombination
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
constexpr Combination( const QskAspect::States states )
|
||||||
|
: QskStateCombination( CombinationNoState, states )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Q_DECL_UNUSED inline double operator ""_dp( long double value )
|
Q_DECL_UNUSED inline double operator ""_dp( long double value )
|
||||||
{
|
{
|
||||||
return qskDpToPixels( static_cast< qreal >( value ) );
|
return qskDpToPixels( static_cast< qreal >( value ) );
|
||||||
@ -74,54 +90,51 @@ namespace
|
|||||||
|
|
||||||
class Editor : private QskSkinHintTableEditor
|
class Editor : private QskSkinHintTableEditor
|
||||||
{
|
{
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Editor( const QskFusionPalette& palette, QskSkinHintTable* table )
|
Editor( const QskFusionPalette& palette, QskSkinHintTable* table )
|
||||||
: QskSkinHintTableEditor( table )
|
: QskSkinHintTableEditor( table )
|
||||||
, m_pal( palette )
|
, m_pal( palette )
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
for ( int i = 0; i < QPalette::NColorRoles; i++ )
|
|
||||||
{
|
|
||||||
const auto role = static_cast< QPalette::ColorRole >( i );
|
|
||||||
const auto rgb = m_pal.rgb( QPalette::Active, role );
|
|
||||||
|
|
||||||
qDebug() << role << qRed( rgb ) << qGreen( rgb ) << qBlue( rgb );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup();
|
void setup()
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < staticMetaObject.methodCount(); i++ )
|
||||||
|
staticMetaObject.method( i ).invokeOnGadget( this );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupBox();
|
Q_INVOKABLE void setupBox();
|
||||||
void setupCheckBox();
|
Q_INVOKABLE void setupCheckBox();
|
||||||
void setupComboBox();
|
Q_INVOKABLE void setupComboBox();
|
||||||
void setupDialogButtonBox();
|
Q_INVOKABLE void setupDialogButtonBox();
|
||||||
void setupDrawer();
|
Q_INVOKABLE void setupDrawer();
|
||||||
void setupFocusIndicator();
|
Q_INVOKABLE void setupFocusIndicator();
|
||||||
void setupGraphicLabel();
|
Q_INVOKABLE void setupGraphicLabel();
|
||||||
void setupInputPanel();
|
Q_INVOKABLE void setupInputPanel();
|
||||||
void setupVirtualKeyboard();
|
Q_INVOKABLE void setupVirtualKeyboard();
|
||||||
void setupListView();
|
Q_INVOKABLE void setupListView();
|
||||||
void setupMenu();
|
Q_INVOKABLE void setupMenu();
|
||||||
void setupPageIndicator();
|
Q_INVOKABLE void setupPageIndicator();
|
||||||
void setupPopup();
|
Q_INVOKABLE void setupPopup();
|
||||||
void setupProgressBar();
|
Q_INVOKABLE void setupProgressBar();
|
||||||
void setupProgressRing();
|
Q_INVOKABLE void setupProgressRing();
|
||||||
void setupRadioBox();
|
Q_INVOKABLE void setupRadioBox();
|
||||||
void setupPushButton();
|
Q_INVOKABLE void setupPushButton();
|
||||||
void setupScrollView();
|
Q_INVOKABLE void setupScrollView();
|
||||||
void setupSegmentedBar();
|
Q_INVOKABLE void setupSegmentedBar();
|
||||||
void setupSeparator();
|
Q_INVOKABLE void setupSeparator();
|
||||||
void setupSubWindow();
|
Q_INVOKABLE void setupSubWindow();
|
||||||
void setupSlider();
|
Q_INVOKABLE void setupSlider();
|
||||||
void setupSpinBox();
|
Q_INVOKABLE void setupSpinBox();
|
||||||
void setupSwitchButton();
|
Q_INVOKABLE void setupSwitchButton();
|
||||||
void setupTabButton();
|
Q_INVOKABLE void setupTabButton();
|
||||||
void setupTabBar();
|
Q_INVOKABLE void setupTabBar();
|
||||||
void setupTabView();
|
Q_INVOKABLE void setupTabView();
|
||||||
void setupTextInput();
|
Q_INVOKABLE void setupTextInput();
|
||||||
void setupTextLabel();
|
Q_INVOKABLE void setupTextLabel();
|
||||||
|
|
||||||
QskGraphic symbol( const char* name ) const
|
QskGraphic symbol( const char* name ) const
|
||||||
{
|
{
|
||||||
@ -147,39 +160,6 @@ namespace
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setup()
|
|
||||||
{
|
|
||||||
setupBox();
|
|
||||||
setupCheckBox();
|
|
||||||
setupComboBox();
|
|
||||||
setupDialogButtonBox();
|
|
||||||
setupDrawer();
|
|
||||||
setupFocusIndicator();
|
|
||||||
setupGraphicLabel();
|
|
||||||
setupInputPanel();
|
|
||||||
setupVirtualKeyboard();
|
|
||||||
setupListView();
|
|
||||||
setupMenu();
|
|
||||||
setupPageIndicator();
|
|
||||||
setupPopup();
|
|
||||||
setupProgressBar();
|
|
||||||
setupProgressRing();
|
|
||||||
setupPushButton();
|
|
||||||
setupRadioBox();
|
|
||||||
setupScrollView();
|
|
||||||
setupSegmentedBar();
|
|
||||||
setupSeparator();
|
|
||||||
setupSlider();
|
|
||||||
setupSpinBox();
|
|
||||||
setupSubWindow();
|
|
||||||
setupSwitchButton();
|
|
||||||
setupTabButton();
|
|
||||||
setupTabBar();
|
|
||||||
setupTabView();
|
|
||||||
setupTextLabel();
|
|
||||||
setupTextInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Editor::setupBox()
|
void Editor::setupBox()
|
||||||
{
|
{
|
||||||
using Q = QskBox;
|
using Q = QskBox;
|
||||||
@ -204,6 +184,11 @@ void Editor::setupCheckBox()
|
|||||||
setBoxBorderColors( Q::Box | Q::Error, m_pal.error );
|
setBoxBorderColors( Q::Box | Q::Error, m_pal.error );
|
||||||
setBoxBorderMetrics( Q::Box, 1_dp );
|
setBoxBorderMetrics( Q::Box, 1_dp );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Box | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Error, Q::Hovered, Q::Pressed, Q::Checked } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( auto state : { A::NoState, Q::Disabled } )
|
for ( auto state : { A::NoState, Q::Disabled } )
|
||||||
{
|
{
|
||||||
const auto colorGroup = ( state == A::NoState ) ? P::Active : P::Disabled;
|
const auto colorGroup = ( state == A::NoState ) ? P::Active : P::Disabled;
|
||||||
@ -268,6 +253,11 @@ void Editor::setupComboBox()
|
|||||||
setBoxBorderMetrics( Q::Panel, 1_dp );
|
setBoxBorderMetrics( Q::Panel, 1_dp );
|
||||||
setBoxBorderColors( Q::Panel, m_pal.outline );
|
setBoxBorderColors( Q::Panel, m_pal.outline );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
setPadding( Q::Panel, 8_dp, 4_dp, 8_dp, 4_dp );
|
setPadding( Q::Panel, 8_dp, 4_dp, 8_dp, 4_dp );
|
||||||
setSpacing( Q::Panel, 8_dp );
|
setSpacing( Q::Panel, 8_dp );
|
||||||
|
|
||||||
@ -404,7 +394,12 @@ void Editor::setupTextInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
setBoxBorderMetrics( Q::Panel, 1_dp );
|
setBoxBorderMetrics( Q::Panel, 1_dp );
|
||||||
|
|
||||||
setBoxBorderColors( Q::Panel, m_pal.outline );
|
setBoxBorderColors( Q::Panel, m_pal.outline );
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.highlightedOutline );
|
||||||
|
#endif
|
||||||
|
|
||||||
setBoxShape( Q::Panel, 2 );
|
setBoxShape( Q::Panel, 2 );
|
||||||
setPadding( Q::Panel, 4_dp );
|
setPadding( Q::Panel, 4_dp );
|
||||||
}
|
}
|
||||||
@ -516,6 +511,11 @@ void Editor::setupRadioBox()
|
|||||||
setBoxBorderColors( aspect, m_pal.darker( colorGroup, P::Window, 150 ) );
|
setBoxBorderColors( aspect, m_pal.darker( colorGroup, P::Window, 150 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::CheckIndicatorPanel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed, Q::Selected } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
setBoxBorderMetrics( Q::CheckIndicator, 1 );
|
setBoxBorderMetrics( Q::CheckIndicator, 1 );
|
||||||
setBoxBorderColors( Q::CheckIndicator, QskRgb::Transparent );
|
setBoxBorderColors( Q::CheckIndicator, QskRgb::Transparent );
|
||||||
setColor( Q::CheckIndicator, Qt::transparent);
|
setColor( Q::CheckIndicator, Qt::transparent);
|
||||||
@ -679,6 +679,10 @@ void Editor::setupPageIndicator()
|
|||||||
|
|
||||||
void Editor::setupPushButton()
|
void Editor::setupPushButton()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
QC2/Fusion offers flat/highlighted. We could the emphasis variations to
|
||||||
|
have the same: TODO ...
|
||||||
|
*/
|
||||||
using Q = QskPushButton;
|
using Q = QskPushButton;
|
||||||
using A = QskAspect;
|
using A = QskAspect;
|
||||||
using P = QPalette;
|
using P = QPalette;
|
||||||
@ -689,6 +693,12 @@ void Editor::setupPushButton()
|
|||||||
setMetric( Q::Panel | A::Spacing, 4 );
|
setMetric( Q::Panel | A::Spacing, 4 );
|
||||||
|
|
||||||
setBoxBorderColors( Q::Panel, m_pal.outline );
|
setBoxBorderColors( Q::Panel, m_pal.outline );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed, Q::Checked } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
setBoxBorderMetrics( Q::Panel, 1 );
|
setBoxBorderMetrics( Q::Panel, 1 );
|
||||||
setBoxShape( Q::Panel, 2 );
|
setBoxShape( Q::Panel, 2 );
|
||||||
|
|
||||||
@ -799,6 +809,11 @@ void Editor::setupSlider()
|
|||||||
setBoxBorderMetrics( Q::Handle, 1 );
|
setBoxBorderMetrics( Q::Handle, 1 );
|
||||||
setBoxBorderColors( Q::Handle, m_pal.outline );
|
setBoxBorderColors( Q::Handle, m_pal.outline );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Handle | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
setStrutSize( Q::Handle, 16_dp, 16_dp );
|
setStrutSize( Q::Handle, 16_dp, 16_dp );
|
||||||
|
|
||||||
for ( auto state : { A::NoState, Q::Pressed } )
|
for ( auto state : { A::NoState, Q::Pressed } )
|
||||||
@ -838,6 +853,12 @@ void Editor::setupSpinBox()
|
|||||||
setBoxBorderMetrics( Q::TextPanel, 1_dp );
|
setBoxBorderMetrics( Q::TextPanel, 1_dp );
|
||||||
setBoxBorderColors( Q::TextPanel, m_pal.outline );
|
setBoxBorderColors( Q::TextPanel, m_pal.outline );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
// not correct, we need the border around text and buttons. TODO ...
|
||||||
|
setBoxBorderColors( Q::TextPanel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Increasing, Q::Decreasing, Q::Hovered } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
setBoxShape( Q::UpPanel, 0, 2_dp, 0, 0 );
|
setBoxShape( Q::UpPanel, 0, 2_dp, 0, 0 );
|
||||||
setBoxBorderMetrics( Q::UpPanel, 0_dp, 1_dp, 1_dp, 0_dp );
|
setBoxBorderMetrics( Q::UpPanel, 0_dp, 1_dp, 1_dp, 0_dp );
|
||||||
|
|
||||||
@ -922,6 +943,11 @@ void Editor::setupSwitchButton()
|
|||||||
setGradient( Q::Handle, QskRgb::lighter( m_pal.button, 104 ) );
|
setGradient( Q::Handle, QskRgb::lighter( m_pal.button, 104 ) );
|
||||||
setGradient( Q::Handle | Q::Pressed, QskRgb::darker( m_pal.button, 110 ) );
|
setGradient( Q::Handle | Q::Pressed, QskRgb::darker( m_pal.button, 110 ) );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Handle | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed, Q::Checked } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
for( auto state : { A::NoState, Q::Disabled } )
|
for( auto state : { A::NoState, Q::Disabled } )
|
||||||
{
|
{
|
||||||
auto aspect = Q::Handle | state;
|
auto aspect = Q::Handle | state;
|
||||||
@ -967,6 +993,10 @@ void Editor::setupTabButton()
|
|||||||
QskRgb::lighter( m_pal.tabFrame, 104 ), m_pal.tabFrame );
|
QskRgb::lighter( m_pal.tabFrame, 104 ), m_pal.tabFrame );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, Q::Pressed, Q::Checked } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( auto variation : { A::Left, A::Right, A::Top, A::Bottom } )
|
for ( auto variation : { A::Left, A::Right, A::Top, A::Bottom } )
|
||||||
{
|
{
|
||||||
@ -1106,6 +1136,11 @@ void Editor::setupVirtualKeyboard()
|
|||||||
setBoxBorderMetrics( Q::ButtonPanel, 1 );
|
setBoxBorderMetrics( Q::ButtonPanel, 1 );
|
||||||
setBoxShape( Q::ButtonPanel, 2 );
|
setBoxShape( Q::ButtonPanel, 2 );
|
||||||
|
|
||||||
|
#ifdef SHOW_FOCUS
|
||||||
|
setBoxBorderColors( Q::ButtonPanel | Q::Focused, m_pal.highlightedOutline,
|
||||||
|
Combination( { Q::Hovered, QskPushButton::Pressed } ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( auto state : { A::NoState, Q::Disabled } )
|
for ( auto state : { A::NoState, Q::Disabled } )
|
||||||
{
|
{
|
||||||
const auto colorGroup = ( state == A::NoState ) ? P::Active : P::Disabled;
|
const auto colorGroup = ( state == A::NoState ) ? P::Active : P::Disabled;
|
||||||
@ -1294,5 +1329,5 @@ void QskFusionSkin::setGraphicColor( GraphicRole role, QRgb rgb )
|
|||||||
setGraphicFilter( role, colorFilter );
|
setGraphicFilter( role, colorFilter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "moc_QskFusionSkin.cpp"
|
#include "moc_QskFusionSkin.cpp"
|
||||||
|
#include "QskFusionSkin.moc"
|
||||||
|
@ -73,6 +73,8 @@ namespace
|
|||||||
|
|
||||||
class Editor : private QskSkinHintTableEditor
|
class Editor : private QskSkinHintTableEditor
|
||||||
{
|
{
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Editor( QskSkinHintTable* table, const QskMaterial3Theme& palette )
|
Editor( QskSkinHintTable* table, const QskMaterial3Theme& palette )
|
||||||
: QskSkinHintTableEditor( table )
|
: QskSkinHintTableEditor( table )
|
||||||
@ -80,37 +82,41 @@ namespace
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup();
|
void setup()
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < staticMetaObject.methodCount(); i++ )
|
||||||
|
staticMetaObject.method( i ).invokeOnGadget( this );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupBox();
|
Q_INVOKABLE void setupBox();
|
||||||
void setupCheckBox();
|
Q_INVOKABLE void setupCheckBox();
|
||||||
void setupComboBox();
|
Q_INVOKABLE void setupComboBox();
|
||||||
void setupDialogButtonBox();
|
Q_INVOKABLE void setupDialogButtonBox();
|
||||||
void setupDrawer();
|
Q_INVOKABLE void setupDrawer();
|
||||||
void setupFocusIndicator();
|
Q_INVOKABLE void setupFocusIndicator();
|
||||||
void setupInputPanel();
|
Q_INVOKABLE void setupInputPanel();
|
||||||
void setupVirtualKeyboard();
|
Q_INVOKABLE void setupVirtualKeyboard();
|
||||||
void setupListView();
|
Q_INVOKABLE void setupListView();
|
||||||
void setupMenu();
|
Q_INVOKABLE void setupMenu();
|
||||||
void setupPageIndicator();
|
Q_INVOKABLE void setupPageIndicator();
|
||||||
void setupPopup();
|
Q_INVOKABLE void setupPopup();
|
||||||
void setupProgressBar();
|
Q_INVOKABLE void setupProgressBar();
|
||||||
void setupProgressRing();
|
Q_INVOKABLE void setupProgressRing();
|
||||||
void setupRadioBox();
|
Q_INVOKABLE void setupRadioBox();
|
||||||
void setupPushButton();
|
Q_INVOKABLE void setupPushButton();
|
||||||
void setupScrollView();
|
Q_INVOKABLE void setupScrollView();
|
||||||
void setupSegmentedBar();
|
Q_INVOKABLE void setupSegmentedBar();
|
||||||
void setupSeparator();
|
Q_INVOKABLE void setupSeparator();
|
||||||
void setupSubWindow();
|
Q_INVOKABLE void setupSubWindow();
|
||||||
void setupSlider();
|
Q_INVOKABLE void setupSlider();
|
||||||
void setupSpinBox();
|
Q_INVOKABLE void setupSpinBox();
|
||||||
void setupSwitchButton();
|
Q_INVOKABLE void setupSwitchButton();
|
||||||
void setupTabButton();
|
Q_INVOKABLE void setupTabButton();
|
||||||
void setupTabBar();
|
Q_INVOKABLE void setupTabBar();
|
||||||
void setupTabView();
|
Q_INVOKABLE void setupTabView();
|
||||||
void setupTextInput();
|
Q_INVOKABLE void setupTextInput();
|
||||||
void setupTextLabel();
|
Q_INVOKABLE void setupTextLabel();
|
||||||
|
|
||||||
QskGraphic symbol( const char* name ) const
|
QskGraphic symbol( const char* name ) const
|
||||||
{
|
{
|
||||||
@ -149,38 +155,6 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setup()
|
|
||||||
{
|
|
||||||
setupBox();
|
|
||||||
setupCheckBox();
|
|
||||||
setupComboBox();
|
|
||||||
setupDialogButtonBox();
|
|
||||||
setupDrawer();
|
|
||||||
setupFocusIndicator();
|
|
||||||
setupInputPanel();
|
|
||||||
setupVirtualKeyboard();
|
|
||||||
setupListView();
|
|
||||||
setupMenu();
|
|
||||||
setupPageIndicator();
|
|
||||||
setupPopup();
|
|
||||||
setupProgressBar();
|
|
||||||
setupProgressRing();
|
|
||||||
setupPushButton();
|
|
||||||
setupRadioBox();
|
|
||||||
setupScrollView();
|
|
||||||
setupSegmentedBar();
|
|
||||||
setupSeparator();
|
|
||||||
setupSlider();
|
|
||||||
setupSpinBox();
|
|
||||||
setupSubWindow();
|
|
||||||
setupSwitchButton();
|
|
||||||
setupTabButton();
|
|
||||||
setupTabBar();
|
|
||||||
setupTabView();
|
|
||||||
setupTextLabel();
|
|
||||||
setupTextInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Editor::setupCheckBox()
|
void Editor::setupCheckBox()
|
||||||
{
|
{
|
||||||
// skin hints are ordered according to
|
// skin hints are ordered according to
|
||||||
@ -1468,3 +1442,4 @@ void QskMaterial3Skin::setupGraphicFilters( const QskMaterial3Theme& palette )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_QskMaterial3Skin.cpp"
|
#include "moc_QskMaterial3Skin.cpp"
|
||||||
|
#include "QskMaterial3Skin.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user