mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Added functions to set the layout margin and paddings in pixels.
Fixed small pixel accuracy issue with row headers.
This commit is contained in:
@@ -710,11 +710,11 @@ void UIAbstractTableView::buildRowHeader() {
|
||||
mRowHeader->setParent( this )->setVisible( true )->setEnabled( true );
|
||||
}
|
||||
|
||||
mRowHeader->setPaddingTop( mHeader->getSize().getHeight() );
|
||||
mRowHeader->setPaddingPixelsTop( mHeader->getPixelsSize().getHeight() );
|
||||
mRowHeader->setPixelsSize( { mRowHeaderWidth, getPixelsSize().getHeight() } );
|
||||
mRowHeader->setClipType( ClipType::PaddingBox );
|
||||
|
||||
int rowsCount = Math::roundUp( mSize.getHeight() / getRowHeight() ) + 1;
|
||||
Uint32 rowsCount = Math::roundUp( mSize.getHeight() / getRowHeight() ) + 1;
|
||||
|
||||
if ( mRowHeader->getChildCount() < rowsCount ) {
|
||||
int createCount = rowsCount - mRowHeader->getChildCount();
|
||||
@@ -737,7 +737,7 @@ void UIAbstractTableView::updateRowHeader( int realRowIndex, const ModelIndex& i
|
||||
UIPushButton* row = child->asType<UIPushButton>();
|
||||
|
||||
row->setPixelsSize( mRowHeaderWidth, getRowHeight() );
|
||||
row->setLayoutMarginTop( PixelDensity::pxToDp( yOffset ) );
|
||||
row->setLayoutPixelsMarginTop( eefloor( yOffset ) );
|
||||
|
||||
if ( getModel() )
|
||||
row->setText( getModel()->rowName( index.row() ) );
|
||||
|
||||
@@ -93,4 +93,11 @@ int UIApplication::run() {
|
||||
return mDidRun ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
UIApplication::Settings::Settings( std::optional<Float> pixelDensity, bool loadBaseResources,
|
||||
Font* baseFont, std::optional<std::string> baseStyleSheetPath ) :
|
||||
pixelDensity( pixelDensity ),
|
||||
loadBaseResources( loadBaseResources ),
|
||||
baseFont( baseFont ),
|
||||
baseStyleSheetPath( baseStyleSheetPath ) {}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -149,6 +149,61 @@ UIWidget* UIWidget::setLayoutMarginBottom( const Float& marginBottom ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setLayoutPixelsMargin( const Rectf& margin ) {
|
||||
if ( mLayoutMargin != margin ) {
|
||||
mLayoutMarginPx = margin;
|
||||
mLayoutMargin = PixelDensity::pxToDp( mLayoutMarginPx ).ceil();
|
||||
onMarginChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setLayoutPixelsMarginLeft( const Float& marginLeft ) {
|
||||
if ( mLayoutMargin.Left != marginLeft ) {
|
||||
mLayoutMarginPx.Left = marginLeft;
|
||||
mLayoutMargin.Left = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Left ) );
|
||||
onMarginChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setLayoutPixelsMarginRight( const Float& marginRight ) {
|
||||
if ( mLayoutMargin.Right != marginRight ) {
|
||||
mLayoutMarginPx.Right = marginRight;
|
||||
mLayoutMargin.Right = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Right ) );
|
||||
onMarginChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setLayoutPixelsMarginTop( const Float& marginTop ) {
|
||||
if ( mLayoutMargin.Top != marginTop ) {
|
||||
mLayoutMarginPx.Top = marginTop;
|
||||
mLayoutMargin.Top = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Top ) );
|
||||
onMarginChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setLayoutPixelsMarginBottom( const Float& marginBottom ) {
|
||||
if ( mLayoutMargin.Bottom != marginBottom ) {
|
||||
mLayoutMarginPx.Bottom = marginBottom;
|
||||
mLayoutMargin.Bottom = eeceil( PixelDensity::pxToDp( mLayoutMarginPx.Bottom ) );
|
||||
onMarginChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Float UIWidget::getLayoutWeight() const {
|
||||
return mLayoutWeight;
|
||||
}
|
||||
@@ -663,6 +718,66 @@ UIWidget* UIWidget::setPaddingBottom( const Float& paddingBottom ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setPaddingPixels( const Rectf& padding ) {
|
||||
if ( padding != mPadding ) {
|
||||
mPaddingPx = padding;
|
||||
mPadding = PixelDensity::pxToDp( mPadding ).ceil();
|
||||
onAutoSize();
|
||||
onPaddingChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setPaddingPixelsLeft( const Float& paddingLeft ) {
|
||||
if ( paddingLeft != mPadding.Left ) {
|
||||
mPaddingPx.Left = paddingLeft;
|
||||
mPadding.Left = eeceil( PixelDensity::pxToDp( mPadding.Left ) );
|
||||
onAutoSize();
|
||||
onPaddingChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setPaddingPixelsRight( const Float& paddingRight ) {
|
||||
if ( paddingRight != mPadding.Right ) {
|
||||
mPaddingPx.Right = paddingRight;
|
||||
mPadding.Right = eeceil( PixelDensity::pxToDp( mPadding.Right ) );
|
||||
onAutoSize();
|
||||
onPaddingChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setPaddingPixelsTop( const Float& paddingTop ) {
|
||||
if ( paddingTop != mPadding.Top ) {
|
||||
mPaddingPx.Top = paddingTop;
|
||||
mPadding.Top = eeceil( PixelDensity::pxToDp( mPadding.Top ) );
|
||||
onAutoSize();
|
||||
onPaddingChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UIWidget* UIWidget::setPaddingPixelsBottom( const Float& paddingBottom ) {
|
||||
if ( paddingBottom != mPadding.Bottom ) {
|
||||
mPaddingPx.Bottom = paddingBottom;
|
||||
mPadding.Bottom = eeceil( PixelDensity::pxToDp( mPadding.Bottom ) );
|
||||
onAutoSize();
|
||||
onPaddingChange();
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const std::string& UIWidget::getStyleSheetId() const {
|
||||
return mId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user