2222#include < cairo/cairo.h>
2323#include < stdlib.h>
2424
25+ using namespace fenster ;
26+
2527background_t * background_t::create ()
2628{
2729 auto instance = createCanvasComponent<background_t >();
@@ -38,40 +40,40 @@ void background_t::init()
3840 paint ();
3941 });
4042
41- this ->addMouseListener ([this ](g_ui_component_mouse_event * e)
43+ this ->addMouseListener ([this ](ComponentMouseEvent * e)
4244 {
4345 auto position = e->position ;
44- if (e->type == G_MOUSE_EVENT_MOVE )
46+ if (e->type == FENSTER_MOUSE_EVENT_MOVE )
4547 {
4648 onMouseMove (position);
4749 }
48- else if (e->type == G_MOUSE_EVENT_PRESS && e->buttons & G_MOUSE_BUTTON_1 )
50+ else if (e->type == FENSTER_MOUSE_EVENT_PRESS && e->buttons & FENSTER_MOUSE_BUTTON_1 )
4951 {
5052 onMouseLeftPress (position, e->clickCount );
5153 }
52- else if (e->type == G_MOUSE_EVENT_DRAG && e->buttons & G_MOUSE_BUTTON_1 )
54+ else if (e->type == FENSTER_MOUSE_EVENT_DRAG && e->buttons & FENSTER_MOUSE_BUTTON_1 )
5355 {
5456 onMouseDrag (position);
5557 }
56- else if (e->type == G_MOUSE_EVENT_RELEASE )
58+ else if (e->type == FENSTER_MOUSE_EVENT_RELEASE )
5759 {
5860 onMouseRelease (position);
5961 }
60- else if (e->type == G_MOUSE_EVENT_LEAVE )
62+ else if (e->type == FENSTER_MOUSE_EVENT_LEAVE )
6163 {
6264 onMouseRelease (position);
6365 }
6466 });
6567
66- selection = g_selection ::create ();
68+ selection = Selection ::create ();
6769 selection->setBounds (this ->getBounds ());
6870 selection->setVisible (false );
6971 this ->addChild (selection);
7072
7173 this ->organize ();
7274}
7375
74- void background_t::onMouseMove (const g_point & position)
76+ void background_t::onMouseMove (const Point & position)
7577{
7678 for (auto item: items)
7779 {
@@ -84,10 +86,10 @@ void background_t::onMouseMove(const g_point& position)
8486 }
8587}
8688
87- void background_t::onMouseLeftPress (const g_point & position, int clickCount)
89+ void background_t::onMouseLeftPress (const Point & position, int clickCount)
8890{
8991 item_t * pressedItem = nullptr ;
90- std::vector<g_rectangle > itemsBounds;
92+ std::vector<Rectangle > itemsBounds;
9193 for (auto & item: items)
9294 {
9395 auto itemBounds = item->getBounds ();
@@ -148,7 +150,7 @@ void background_t::onMouseLeftPress(const g_point& position, int clickCount)
148150 }
149151}
150152
151- void background_t::onMouseDrag (const g_point & position)
153+ void background_t::onMouseDrag (const Point & position)
152154{
153155 if (dragItems)
154156 {
@@ -157,21 +159,21 @@ void background_t::onMouseDrag(const g_point& position)
157159 if (item->selected )
158160 {
159161 auto point = position - item->dragOffset ;
160- item->setBounds (g_rectangle (point.x , point.y , 100 , 100 ));
162+ item->setBounds (Rectangle (point.x , point.y , 100 , 100 ));
161163 }
162164 }
163165 }
164166 else
165167 {
166- g_rectangle bounds (selectionStart.x , selectionStart.y , position.x - selectionStart.x ,
168+ Rectangle bounds (selectionStart.x , selectionStart.y , position.x - selectionStart.x ,
167169 position.y - selectionStart.y );
168170 auto boundsNorm = bounds.asNormalized ();
169171 selection->setBounds (boundsNorm);
170172 selection->setVisible (true );
171173
172174 for (auto item: items)
173175 {
174- g_rectangle rect = item->getBounds ();
176+ Rectangle rect = item->getBounds ();
175177 if (boundsNorm.intersects (rect))
176178 {
177179 auto wasSelected = item->selected ;
@@ -190,7 +192,7 @@ void background_t::onMouseDrag(const g_point& position)
190192 }
191193}
192194
193- void background_t::onMouseRelease (const g_point & position)
195+ void background_t::onMouseRelease (const Point & position)
194196{
195197 if (dragItems)
196198 dragItems = false ;
@@ -240,7 +242,7 @@ void background_t::paint()
240242 cairo_rectangle (cr, bgX, bgY, bounds.width , bounds.height );
241243 cairo_fill (cr);
242244
243- this ->blit (g_rectangle (0 , 0 , bounds.width , bounds.height ));
245+ this ->blit (Rectangle (0 , 0 , bounds.width , bounds.height ));
244246
245247 this ->releaseGraphics ();
246248}
0 commit comments