Files
Aerofoil/PortabilityLayer/PLControlDefinitions.cpp

29 lines
706 B
C++
Raw Normal View History

2019-12-21 18:40:17 -05:00
#include "PLControlDefinitions.h"
2020-02-18 20:53:54 -05:00
#include "PLArrayView.h"
#include "PLArrayViewIterator.h"
#include "PLWidgets.h"
2019-11-11 00:11:59 -05:00
2020-01-05 02:33:03 -05:00
int FindControl(Point point, WindowPtr window, PortabilityLayer::Widget **outControl)
{
2020-02-18 20:53:54 -05:00
// Returns clicked part
ArrayView<PortabilityLayer::Widget*> widgets = window->GetWidgets();
for (ArrayViewIterator<PortabilityLayer::Widget*const> it = widgets.begin(), itEnd = widgets.end(); it != itEnd; ++it)
{
PortabilityLayer::Widget *widget = *it;
const Rect widgetRect = widget->GetRect();
if (widgetRect.Contains(point))
{
2020-03-10 01:35:42 -04:00
int part = widget->ResolvePart(point);
if (part != 0)
{
*outControl = widget;
return part;
}
2020-02-18 20:53:54 -05:00
}
}
*outControl = nullptr;
2020-01-05 02:33:03 -05:00
return 0;
}