summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c16
-rw-r--r--src/ui/sidebarwidget.c4
-rw-r--r--src/ui/widget.c1
-rw-r--r--src/ui/window.c13
-rw-r--r--src/ui/window.h2
5 files changed, 22 insertions, 14 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 449f2f4e..020d624f 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -173,9 +173,6 @@ struct Impl_DocumentWidget {
173 int scrollY; 173 int scrollY;
174 iScrollWidget *scroll; 174 iScrollWidget *scroll;
175 iWidget * menu; 175 iWidget * menu;
176 SDL_Cursor * arrowCursor; /* TODO: cursors belong in Window */
177 SDL_Cursor * beamCursor;
178 SDL_Cursor * handCursor;
179 iVisBuffer * visBuffer; 176 iVisBuffer * visBuffer;
180}; 177};
181 178
@@ -207,9 +204,6 @@ void init_DocumentWidget(iDocumentWidget *d) {
207 d->noHoverWhileScrolling = iFalse; 204 d->noHoverWhileScrolling = iFalse;
208 d->showLinkNumbers = iFalse; 205 d->showLinkNumbers = iFalse;
209 d->visBuffer = new_VisBuffer(); 206 d->visBuffer = new_VisBuffer();
210 d->arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
211 d->beamCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
212 d->handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
213 init_PtrArray(&d->visibleLinks); 207 init_PtrArray(&d->visibleLinks);
214 init_Click(&d->click, d, SDL_BUTTON_LEFT); 208 init_Click(&d->click, d, SDL_BUTTON_LEFT);
215 addChild_Widget(w, iClob(d->scroll = new_ScrollWidget())); 209 addChild_Widget(w, iClob(d->scroll = new_ScrollWidget()));
@@ -235,9 +229,6 @@ void deinit_DocumentWidget(iDocumentWidget *d) {
235 deinit_PtrArray(&d->visibleLinks); 229 deinit_PtrArray(&d->visibleLinks);
236 delete_String(d->certSubject); 230 delete_String(d->certSubject);
237 delete_String(d->titleUser); 231 delete_String(d->titleUser);
238 SDL_FreeCursor(d->arrowCursor);
239 SDL_FreeCursor(d->beamCursor);
240 SDL_FreeCursor(d->handCursor);
241 deinit_Model(&d->mod); 232 deinit_Model(&d->mod);
242} 233}
243 234
@@ -346,10 +337,11 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) {
346 } 337 }
347 if (!contains_Widget(constAs_Widget(d), mouse) || 338 if (!contains_Widget(constAs_Widget(d), mouse) ||
348 contains_Widget(constAs_Widget(d->scroll), mouse)) { 339 contains_Widget(constAs_Widget(d->scroll), mouse)) {
349 SDL_SetCursor(d->arrowCursor); 340// setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
350 } 341 }
351 else { 342 else {
352 SDL_SetCursor(d->hoverLink ? d->handCursor : d->beamCursor); 343 setCursor_Window(get_Window(),
344 d->hoverLink ? SDL_SYSTEM_CURSOR_HAND : SDL_SYSTEM_CURSOR_IBEAM);
353 } 345 }
354} 346}
355 347
@@ -1294,7 +1286,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1294 else if (ev->type == SDL_MOUSEMOTION) { 1286 else if (ev->type == SDL_MOUSEMOTION) {
1295 d->noHoverWhileScrolling = iFalse; 1287 d->noHoverWhileScrolling = iFalse;
1296 if (isVisible_Widget(d->menu)) { 1288 if (isVisible_Widget(d->menu)) {
1297 SDL_SetCursor(d->arrowCursor); 1289 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
1298 } 1290 }
1299 else { 1291 else {
1300 updateHover_DocumentWidget_(d, init_I2(ev->motion.x, ev->motion.y)); 1292 updateHover_DocumentWidget_(d, init_I2(ev->motion.x, ev->motion.y));
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 98570471..04023ebc 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -465,11 +465,11 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
465 const iInt2 mouse = init_I2(ev->motion.x, ev->motion.y); 465 const iInt2 mouse = init_I2(ev->motion.x, ev->motion.y);
466 size_t hover = iInvalidPos; 466 size_t hover = iInvalidPos;
467 if (contains_Widget(d->resizer, mouse)) { 467 if (contains_Widget(d->resizer, mouse)) {
468 SDL_SetCursor(d->resizeCursor); 468 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_SIZEWE);
469 } 469 }
470 else { 470 else {
471 SDL_SetCursor(NULL);
472 if (contains_Widget(w, mouse)) { 471 if (contains_Widget(w, mouse)) {
472 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
473 hover = itemIndex_SidebarWidget_(d, mouse); 473 hover = itemIndex_SidebarWidget_(d, mouse);
474 } 474 }
475 } 475 }
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 1c19b70f..135eb267 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -454,6 +454,7 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
454 } 454 }
455 } 455 }
456 if (d->flags & mouseModal_WidgetFlag && isMouseEvent_(ev)) { 456 if (d->flags & mouseModal_WidgetFlag && isMouseEvent_(ev)) {
457 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
457 return iTrue; 458 return iTrue;
458 } 459 }
459 return iFalse; 460 return iFalse;
diff --git a/src/ui/window.c b/src/ui/window.c
index 3d9d98d1..a687350c 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -380,6 +380,7 @@ static void drawBlank_Window_(iWindow *d) {
380 380
381void init_Window(iWindow *d, iRect rect) { 381void init_Window(iWindow *d, iRect rect) {
382 theWindow_ = d; 382 theWindow_ = d;
383 iZap(d->cursors);
383 d->isDrawFrozen = iTrue; 384 d->isDrawFrozen = iTrue;
384 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; 385 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
385#if defined (iPlatformApple) 386#if defined (iPlatformApple)
@@ -442,6 +443,11 @@ void deinit_Window(iWindow *d) {
442 if (theWindow_ == d) { 443 if (theWindow_ == d) {
443 theWindow_ = NULL; 444 theWindow_ = NULL;
444 } 445 }
446 iForIndices(i, d->cursors) {
447 if (d->cursors[i]) {
448 SDL_FreeCursor(d->cursors[i]);
449 }
450 }
445 iReleasePtr(&d->root); 451 iReleasePtr(&d->root);
446 deinit_Text(); 452 deinit_Text();
447 SDL_DestroyRenderer(d->render); 453 SDL_DestroyRenderer(d->render);
@@ -564,6 +570,13 @@ void setFreezeDraw_Window(iWindow *d, iBool freezeDraw) {
564 d->isDrawFrozen = freezeDraw; 570 d->isDrawFrozen = freezeDraw;
565} 571}
566 572
573void setCursor_Window(iWindow *d, int cursor) {
574 if (!d->cursors[cursor]) {
575 d->cursors[cursor] = SDL_CreateSystemCursor(cursor);
576 }
577 SDL_SetCursor(d->cursors[cursor]);
578}
579
567iInt2 rootSize_Window(const iWindow *d) { 580iInt2 rootSize_Window(const iWindow *d) {
568 return d->root->rect.size; 581 return d->root->rect.size;
569} 582}
diff --git a/src/ui/window.h b/src/ui/window.h
index d6eed841..98c8b590 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -19,6 +19,7 @@ struct Impl_Window {
19 float uiScale; 19 float uiScale;
20 uint32_t frameTime; 20 uint32_t frameTime;
21 double presentTime; 21 double presentTime;
22 SDL_Cursor * cursors[SDL_NUM_SYSTEM_CURSORS];
22}; 23};
23 24
24iBool processEvent_Window (iWindow *, const SDL_Event *); 25iBool processEvent_Window (iWindow *, const SDL_Event *);
@@ -27,6 +28,7 @@ void resize_Window (iWindow *, int w, int h);
27void setTitle_Window (iWindow *, const iString *title); 28void setTitle_Window (iWindow *, const iString *title);
28void setUiScale_Window (iWindow *, float uiScale); 29void setUiScale_Window (iWindow *, float uiScale);
29void setFreezeDraw_Window (iWindow *, iBool freezeDraw); 30void setFreezeDraw_Window (iWindow *, iBool freezeDraw);
31void setCursor_Window (iWindow *, int cursor);
30 32
31iInt2 rootSize_Window (const iWindow *); 33iInt2 rootSize_Window (const iWindow *);
32float uiScale_Window (const iWindow *); 34float uiScale_Window (const iWindow *);