-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWidgetContext.cpp
More file actions
46 lines (39 loc) · 998 Bytes
/
WidgetContext.cpp
File metadata and controls
46 lines (39 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Arc.cpp
*
* Copyright (c) 2005-2015 Ludovic Aubert. ALL RIGHTS RESERVED.
* ludo.aubert@gmail.com
* This file should not be transmitted nor published.
*
*/
#include "WidgetContext.h"
#include "MyRect.h"
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std ;
WidgetContext::WidgetContext()
{
}
WidgetContext::WidgetContext(const MyRect &rec):
type(WidgetType::RECTANGLE),
r(rec)
{}
vector<WidgetContext> collapse_composite(const vector<WidgetContext>& widgets, const MyPoint& translation)
{
vector<WidgetContext> result, sub ;
for (WidgetContext widget : widgets)
{
switch (widget.type)
{
case COMPOSITE_WIDGET:
sub = collapse_composite(widget.widgets, translation + MyPoint{widget.r.m_left, widget.r.m_top}) ;
copy(sub.begin(), sub.end(), back_inserter(result));
break ;
case RECTANGLE:
translate(widget.r, translation) ;
result.push_back(widget) ;
break ;
}
}
return result ;
}