forked from quickshell/quickshell
		
	widgets/wrapper: fix margin wrapper reactvity and margins
Fixed reactivity of the paren't actual size not working before child had been assigned. Fixed incorrect margins when actual size is less than implicit size.
This commit is contained in:
		
							parent
							
								
									033e810871
								
							
						
					
					
						commit
						ee93306312
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -20,6 +20,8 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MarginWrapperManager::componentComplete() {
 | 
					void MarginWrapperManager::componentComplete() {
 | 
				
			||||||
 | 
						this->WrapperManager::componentComplete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->mWrapper) {
 | 
						if (this->mWrapper) {
 | 
				
			||||||
		QObject::connect(
 | 
							QObject::connect(
 | 
				
			||||||
		    this->mWrapper,
 | 
							    this->mWrapper,
 | 
				
			||||||
| 
						 | 
					@ -36,8 +38,6 @@ void MarginWrapperManager::componentComplete() {
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->WrapperManager::componentComplete();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!this->mChild) this->updateGeometry();
 | 
						if (!this->mChild) this->updateGeometry();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,12 +97,19 @@ qreal MarginWrapperManager::targetChildHeight() const {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qreal MarginWrapperManager::targetChildX() const {
 | 
					qreal MarginWrapperManager::targetChildX() const {
 | 
				
			||||||
	if (this->mResizeChild) return this->mMargin;
 | 
						if (this->mResizeChild) return this->mMargin;
 | 
				
			||||||
	else return this->mWrapper->width() / 2 - this->mChild->implicitWidth() / 2;
 | 
						else {
 | 
				
			||||||
 | 
							return std::max(this->mMargin, this->mWrapper->width() / 2 - this->mChild->implicitWidth() / 2);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qreal MarginWrapperManager::targetChildY() const {
 | 
					qreal MarginWrapperManager::targetChildY() const {
 | 
				
			||||||
	if (this->mResizeChild) return this->mMargin;
 | 
						if (this->mResizeChild) return this->mMargin;
 | 
				
			||||||
	else return this->mWrapper->height() / 2 - this->mChild->implicitHeight() / 2;
 | 
						else {
 | 
				
			||||||
 | 
							return std::max(
 | 
				
			||||||
 | 
							    this->mMargin,
 | 
				
			||||||
 | 
							    this->mWrapper->height() / 2 - this->mChild->implicitHeight() / 2
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MarginWrapperManager::onWrapperWidthChanged() {
 | 
					void MarginWrapperManager::onWrapperWidthChanged() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue