Added ability to set minimal height for slide wrap.
This commit is contained in:
		
							parent
							
								
									3f28dfa821
								
							
						
					
					
						commit
						1ee4b34bf6
					
				
					 2 changed files with 12 additions and 3 deletions
				
			
		|  | @ -96,6 +96,10 @@ SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn( | ||||||
| 	return this; | 	return this; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void SlideWrap<RpWidget>::setMinimalHeight(int height) { | ||||||
|  | 	_minimalHeight = height; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void SlideWrap<RpWidget>::animationStep() { | void SlideWrap<RpWidget>::animationStep() { | ||||||
| 	const auto weak = wrapped(); | 	const auto weak = wrapped(); | ||||||
| 	if (weak && !_up) { | 	if (weak && !_up) { | ||||||
|  | @ -106,8 +110,11 @@ void SlideWrap<RpWidget>::animationStep() { | ||||||
| 	const auto current = _animation.value(_toggled ? 1. : 0.); | 	const auto current = _animation.value(_toggled ? 1. : 0.); | ||||||
| 	const auto newHeight = weak | 	const auto newHeight = weak | ||||||
| 		? (_animation.animating() | 		? (_animation.animating() | ||||||
| 			? anim::interpolate(0, weak->heightNoMargins(), current) | 			? anim::interpolate( | ||||||
| 			: (_toggled ? weak->height() : 0)) | 				_minimalHeight, | ||||||
|  | 				weak->heightNoMargins(), | ||||||
|  | 				current) | ||||||
|  | 			: (_toggled ? weak->height() : _minimalHeight)) | ||||||
| 		: 0; | 		: 0; | ||||||
| 	if (weak && _up) { | 	if (weak && _up) { | ||||||
| 		const auto margins = getMargins(); | 		const auto margins = getMargins(); | ||||||
|  | @ -121,7 +128,7 @@ void SlideWrap<RpWidget>::animationStep() { | ||||||
| 	const auto shouldBeHidden = !_toggled && !_animation.animating(); | 	const auto shouldBeHidden = !_toggled && !_animation.animating(); | ||||||
| 	if (shouldBeHidden != isHidden()) { | 	if (shouldBeHidden != isHidden()) { | ||||||
| 		const auto guard = MakeWeak(this); | 		const auto guard = MakeWeak(this); | ||||||
| 		setVisible(!shouldBeHidden); | 		setVisible(!shouldBeHidden || _minimalHeight); | ||||||
| 		if (shouldBeHidden && guard) { | 		if (shouldBeHidden && guard) { | ||||||
| 			SendPendingMoveResizeEvents(this); | 			SendPendingMoveResizeEvents(this); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -53,6 +53,7 @@ public: | ||||||
| 	auto toggledValue() const { | 	auto toggledValue() const { | ||||||
| 		return _toggledChanged.events_starting_with_copy(_toggled); | 		return _toggledChanged.events_starting_with_copy(_toggled); | ||||||
| 	} | 	} | ||||||
|  | 	void setMinimalHeight(int height); | ||||||
| 
 | 
 | ||||||
| 	QMargins getMargins() const override; | 	QMargins getMargins() const override; | ||||||
| 
 | 
 | ||||||
|  | @ -68,6 +69,7 @@ private: | ||||||
| 	int _duration = 0; | 	int _duration = 0; | ||||||
| 	bool _toggled = true; | 	bool _toggled = true; | ||||||
| 	bool _up = false; | 	bool _up = false; | ||||||
|  | 	int _minimalHeight = 0; | ||||||
| 
 | 
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 23rd
						23rd