Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [Feature request] Relative positioning
Re: [Feature request] Relative positioning [message #48771 is a reply to message #48673] Wed, 13 September 2017 15:49 Go to previous messageGo to previous message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
I finished my work on my AutoResizer. So if anyone wants to use it simply include and inherit from AutoResizeTopWindow instead of TopWindow.
So here is the solution I came up with:
#ifndef _AutoResizeTopWindow_h_
#define _AutoResizeTopWindow_h_

#include <CtrlLib/CtrlLib.h>
using namespace Upp;

class AutoResizeTopWindow : public TopWindow
{
public:
	virtual void Layout()
	{
		Size currentSize = GetSize();
		if(firstSizing)
			startSize = currentSize;
		
		float sizeXChange = (float)currentSize.cx / (float)startSize.cx;
		float sizeYChange = (float)currentSize.cy / (float)startSize.cy;
		
		Ctrl* pChild = GetFirstChild();
		for(int i = 0; pChild != NULL; i++)
		{
			if(firstSizing)
				startRects.Add(pChild->GetRect());
			
			float rectLeft	= startRects[i].left * sizeXChange;
			float rectTop	= startRects[i].top * sizeYChange;
			float rectSizeX	= startRects[i].Width() * sizeXChange;
			float rectSizeY	= startRects[i].Height() * sizeYChange;
			
			pChild->SetRect(rectLeft, rectTop,
							rectSizeX, rectSizeY);
			
			pChild = pChild->GetNext();
		}
		firstSizing = false;
	}

private:
	bool firstSizing = true;
	Size startSize;
	Vector<Rect> startRects;
};

#endif



Greetings
Daniel

[Updated on: Thu, 14 September 2017 08:45]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Bug (minor)]: CenterScreen not working
Next Topic: reference/OpenGL crashes
Goto Forum:
  


Current Time: Thu Dec 12 00:02:45 CET 2019

Total time taken to generate the page: 0.01082 seconds