summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c17
-rw-r--r--src/ui/inputwidget.c6
-rw-r--r--src/ui/inputwidget.h1
-rw-r--r--src/ui/scrollwidget.c2
-rw-r--r--src/ui/window.c24
5 files changed, 40 insertions, 10 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 38c19fdd..9d95957a 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -353,12 +353,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
353 } 353 }
354 else if (ev->type == SDL_MOUSEMOTION) { 354 else if (ev->type == SDL_MOUSEMOTION) {
355 const iGmRun *oldHoverLink = d->hoverLink; 355 const iGmRun *oldHoverLink = d->hoverLink;
356 d->hoverLink = NULL; 356 d->hoverLink = NULL;
357 const iRect docBounds = documentBounds_DocumentWidget_(d); 357 const iRect docBounds = documentBounds_DocumentWidget_(d);
358 const iInt2 hoverPos = 358 const iInt2 hoverPos = addY_I2(
359 addY_I2(sub_I2(localCoord_Widget(w, init_I2(ev->motion.x, ev->motion.y)), 359 sub_I2(init_I2(ev->motion.x, ev->motion.y), topLeft_Rect(docBounds)), d->scrollY);
360 topLeft_Rect(docBounds)),
361 d->scrollY);
362 iConstForEach(PtrArray, i, &d->visibleLinks) { 360 iConstForEach(PtrArray, i, &d->visibleLinks) {
363 const iGmRun *run = i.ptr; 361 const iGmRun *run = i.ptr;
364 if (contains_Rect(run->bounds, hoverPos)) { 362 if (contains_Rect(run->bounds, hoverPos)) {
@@ -425,15 +423,18 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
425 m->state = ready_DocumentState; 423 m->state = ready_DocumentState;
426 updateVisible_DocumentWidget_(m); 424 updateVisible_DocumentWidget_(m);
427 } 425 }
428 if (d->state != ready_DocumentState) return; 426 if (d->state != ready_DocumentState) return;
429 iDrawContext ctx = { .widget = d, .bounds = documentBounds_DocumentWidget_(d) }; 427 iDrawContext ctx = { .widget = d, .bounds = documentBounds_DocumentWidget_(d) };
430 init_Paint(&ctx.paint); 428 const iRect bounds = bounds_Widget(w);
431 fillRect_Paint(&ctx.paint, bounds_Widget(w), gray25_ColorId); 429 init_Paint(&ctx.paint);
430 fillRect_Paint(&ctx.paint, bounds, gray25_ColorId);
431 setClip_Paint(&ctx.paint, bounds);
432 render_GmDocument( 432 render_GmDocument(
433 d->doc, 433 d->doc,
434 visibleRange_DocumentWidget_(d), 434 visibleRange_DocumentWidget_(d),
435 drawRun_DrawContext_, 435 drawRun_DrawContext_,
436 &ctx); 436 &ctx);
437 clearClip_Paint(&ctx.paint);
437 draw_Widget(w); 438 draw_Widget(w);
438} 439}
439 440
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 7a2b7d1c..1a692907 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -70,6 +70,12 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
70 } 70 }
71} 71}
72 72
73void setTextCStr_InputWidget(iInputWidget *d, const char *cstr) {
74 iString *str = newCStr_String(cstr);
75 setText_InputWidget(d, str);
76 delete_String(str);
77}
78
73void setCursor_InputWidget(iInputWidget *d, size_t pos) { 79void setCursor_InputWidget(iInputWidget *d, size_t pos) {
74 d->cursor = iMin(pos, size_Array(&d->text)); 80 d->cursor = iMin(pos, size_Array(&d->text));
75} 81}
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h
index b606f974..6ee2760d 100644
--- a/src/ui/inputwidget.h
+++ b/src/ui/inputwidget.h
@@ -13,6 +13,7 @@ enum iInputMode {
13void setMode_InputWidget (iInputWidget *, enum iInputMode mode); 13void setMode_InputWidget (iInputWidget *, enum iInputMode mode);
14void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); 14void setMaxLen_InputWidget (iInputWidget *, size_t maxLen);
15void setText_InputWidget (iInputWidget *, const iString *text); 15void setText_InputWidget (iInputWidget *, const iString *text);
16void setTextCStr_InputWidget (iInputWidget *, const char *cstr);
16void setCursor_InputWidget (iInputWidget *, size_t pos); 17void setCursor_InputWidget (iInputWidget *, size_t pos);
17void begin_InputWidget (iInputWidget *); 18void begin_InputWidget (iInputWidget *);
18void end_InputWidget (iInputWidget *, iBool accept); 19void end_InputWidget (iInputWidget *, iBool accept);
diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c
index 1be62bb8..1961677b 100644
--- a/src/ui/scrollwidget.c
+++ b/src/ui/scrollwidget.c
@@ -41,7 +41,7 @@ static iRect thumbRect_ScrollWidget_(const iScrollWidget *d) {
41 const int tsize = thumbSize_ScrollWidget_(d); 41 const int tsize = thumbSize_ScrollWidget_(d);
42 const int tpos = 42 const int tpos =
43 iClamp((float) d->thumb / (float) total, 0, 1) * (height_Rect(bounds) - tsize); 43 iClamp((float) d->thumb / (float) total, 0, 1) * (height_Rect(bounds) - tsize);
44 rect.pos.y = tpos; 44 rect.pos.y = bounds.pos.y + tpos;
45 rect.size.y = tsize; 45 rect.size.y = tsize;
46 } 46 }
47 return rect; 47 return rect;
diff --git a/src/ui/window.c b/src/ui/window.c
index 2bfecd8c..dbbd04b7 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -75,7 +75,29 @@ static void setupUserInterface_Window(iWindow *d) {
75 setFlags_Widget(d->root, resizeChildren_WidgetFlag, iTrue); 75 setFlags_Widget(d->root, resizeChildren_WidgetFlag, iTrue);
76 setCommandHandler_Widget(d->root, handleRootCommands_); 76 setCommandHandler_Widget(d->root, handleRootCommands_);
77 77
78 addChild_Widget(d->root, iClob(new_DocumentWidget())); 78 iWidget *div = makeVDiv_Widget();
79 setId_Widget(div, "navdiv");
80 addChild_Widget(d->root, iClob(div));
81
82 /* Navigation bar. */ {
83 iWidget *navBar = new_Widget();
84 setId_Widget(navBar, "navbar");
85 setFlags_Widget(navBar,
86 arrangeHeight_WidgetFlag | resizeChildren_WidgetFlag |
87 arrangeHorizontal_WidgetFlag,
88 iTrue);
89 addChild_Widget(div, iClob(navBar));
90 setBackgroundColor_Widget(div, gray25_ColorId);
91
92 addChild_Widget(navBar, iClob(new_LabelWidget("Back", 0, 0, "navigate.back")));
93 addChild_Widget(navBar, iClob(new_LabelWidget("Fwd", 0, 0, "navigate.forward")));
94 addChild_Widget(navBar, iClob(new_LabelWidget("Home", 0, 0, "navigate.home")));
95 iInputWidget *url = new_InputWidget(0);
96 setTextCStr_InputWidget(url, "gemini://");
97 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag);
98 }
99
100 addChildFlags_Widget(div, iClob(new_DocumentWidget()), expand_WidgetFlag);
79 101
80#if 0 102#if 0
81 iWidget *mainDiv = makeHDiv_Widget(); 103 iWidget *mainDiv = makeHDiv_Widget();