Files
Work/common/RUBBER.CPP
2024-08-07 09:09:36 -04:00

34 lines
1.1 KiB
C++

#include <common/rubber.hpp>
#include <common/window.hpp>
#include <common/rect.hpp>
#include <common/point.hpp>
RubberControl::~RubberControl()
{
}
void RubberControl::calcRatios(GUIWindow &parentWindow)
{
Rect clientRect;
Rect controlRect;
Point screenPoint;
if(!controlWindow().isValid()||!parentWindow.isValid())return;
parentWindow.clientRect(clientRect);
controlWindow().clientRect(controlRect);
parentWindow.clientToScreen(clientRect);
controlWindow().clientToScreen(controlRect);
mRatios[Left]=((float)(controlRect.left()-clientRect.left())/(float)parentWindow.width());
mRatios[Top]=((float)(controlRect.top()-clientRect.top())/(float)parentWindow.height());
mRatios[Right]=((float)(clientRect.right()-controlRect.right())/(float)parentWindow.width());
mRatios[Bottom]=((float)(clientRect.bottom()-controlRect.bottom())/(float)parentWindow.height());
return;
}
void RubberControl::moveControl(GUIWindow &/*parentWindow*/,int width,int height)
{
Rect controlRect(mRatios[Left]*width,mRatios[Top]*height,width-(mRatios[Right]*width),height-(mRatios[Bottom]*height));
controlWindow().moveWindow(controlRect);
}