forked from uwerat/qskinny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
input text: Add skinlets for different design systems
- Loading branch information
Showing
15 changed files
with
522 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/****************************************************************************** | ||
* QSkinny - Copyright (C) The authors | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*****************************************************************************/ | ||
|
||
#include "QskFluent2TextInputSkinlet.h" | ||
#include "QskTextInput.h" | ||
|
||
using Q = QskTextInput; | ||
|
||
QskFluent2TextInputSkinlet::QskFluent2TextInputSkinlet( QskSkin* skin ) | ||
: Inherited( skin ) | ||
{ | ||
} | ||
|
||
QskFluent2TextInputSkinlet::~QskFluent2TextInputSkinlet() | ||
{ | ||
} | ||
|
||
QRectF QskFluent2TextInputSkinlet::subControlRect( const QskSkinnable* skinnable, | ||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const | ||
{ | ||
const auto input = static_cast< const Q* >( skinnable ); | ||
|
||
if ( subControl == Q::Panel ) | ||
{ | ||
auto rect = contentsRect; | ||
|
||
const auto h = input->strutSizeHint( subControl ).height(); | ||
rect.setY( rect.bottom() - h ); | ||
|
||
return rect; | ||
} | ||
else if ( subControl == Q::LabelText ) | ||
{ | ||
auto rect = contentsRect; | ||
|
||
const auto h = input->strutSizeHint( subControl ).height(); | ||
rect.setHeight( h ); | ||
|
||
return rect; | ||
} | ||
else if ( subControl == Q::HintText ) | ||
{ | ||
if( input->hasSkinState( Q::TextPopulated ) ) | ||
{ | ||
return {}; | ||
} | ||
else | ||
{ | ||
return input->subControlRect( Q::InputText ); | ||
} | ||
} | ||
|
||
return Inherited::subControlRect( skinnable, contentsRect, subControl ); | ||
} | ||
|
||
QSizeF QskFluent2TextInputSkinlet::adjustSizeHint( const QskSkinnable* skinnable, Qt::SizeHint which, const QSizeF& oldHint ) const | ||
{ | ||
if ( which != Qt::PreferredSize ) | ||
return QSizeF(); | ||
|
||
const auto input = static_cast< const Q* >( skinnable ); | ||
|
||
const auto labelHeight = input->labelText().isEmpty() ? 0 : input->strutSizeHint( Q::LabelText ).height(); | ||
const auto panelHeight = input->strutSizeHint( Q::Panel ).height(); | ||
|
||
const auto h = labelHeight + panelHeight; | ||
|
||
QSizeF hint( oldHint.width(), h ); | ||
|
||
return hint; | ||
} | ||
|
||
#include "moc_QskFluent2TextInputSkinlet.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/****************************************************************************** | ||
* QSkinny - Copyright (C) The authors | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*****************************************************************************/ | ||
|
||
#ifndef QSK_MATERIAL3_INPUT_SKINLET_H | ||
#define QSK_MATERIAL3_INPUT_SKINLET_H | ||
|
||
#include "QskTextInputSkinlet.h" | ||
|
||
class QSK_EXPORT QskFluent2TextInputSkinlet : public QskTextInputSkinlet | ||
{ | ||
Q_GADGET | ||
|
||
using Inherited = QskTextInputSkinlet; | ||
|
||
public: | ||
Q_INVOKABLE QskFluent2TextInputSkinlet( QskSkin* = nullptr ); | ||
~QskFluent2TextInputSkinlet() override; | ||
|
||
QRectF subControlRect( const QskSkinnable*, | ||
const QRectF& rect, QskAspect::Subcontrol ) const override; | ||
|
||
QSizeF adjustSizeHint( const QskSkinnable*, | ||
Qt::SizeHint, const QSizeF& ) const override; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.