summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-07-23 19:30:17 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-07-23 19:30:17 +0300
commitdd73346aad190239ed133d0c4835dbaa05d1b0cd (patch)
tree5946174857fce2b5fcf14d0a662e4ce26745e6ca /src/ui/documentwidget.c
parent4b81b3bc704ec8a7041559b4f9a141e96189a7c7 (diff)
Entering URLs and updating the navbar
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9d95957a..71399d3b 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -301,6 +301,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
301 if (isResize_UserEvent(ev)) { 301 if (isResize_UserEvent(ev)) {
302 setWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d)); 302 setWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d));
303 updateVisible_DocumentWidget_(d); 303 updateVisible_DocumentWidget_(d);
304 refresh_Widget(w);
304 } 305 }
305 else if (isCommand_Widget(w, ev, "scroll.moved")) { 306 else if (isCommand_Widget(w, ev, "scroll.moved")) {
306 d->scrollY = arg_Command(command_UserEvent(ev)); 307 d->scrollY = arg_Command(command_UserEvent(ev));
@@ -410,30 +411,27 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
410} 411}
411 412
412static void draw_DocumentWidget_(const iDocumentWidget *d) { 413static void draw_DocumentWidget_(const iDocumentWidget *d) {
413 const iWidget *w = constAs_Widget(d); 414 const iWidget *w = constAs_Widget(d);
415 const iRect bounds = bounds_Widget(w);
414 draw_Widget(w); 416 draw_Widget(w);
417 iDrawContext ctx = { .widget = d, .bounds = documentBounds_DocumentWidget_(d) };
418 init_Paint(&ctx.paint);
419 fillRect_Paint(&ctx.paint, bounds, gray25_ColorId);
415 /* Update the document? */ 420 /* Update the document? */
416 if (!isEmpty_String(d->newSource)) { 421 if (!isEmpty_String(d->newSource)) {
417 iDocumentWidget *m = iConstCast(iDocumentWidget *, d); 422 iDocumentWidget *m = iConstCast(iDocumentWidget *, d);
418 /* TODO: Do this in the background. However, that requires a text metrics calculator 423 /* TODO: Do this in the background. However, that requires a text metrics calculator
419 that does not try to cache the glyph bitmaps. */ 424 that does not try to cache the glyph bitmaps. */
420 setSource_GmDocument(m->doc, m->newSource, documentWidth_DocumentWidget_(m)); 425 setSource_GmDocument(m->doc, m->newSource, width_Rect(ctx.bounds));
426 postCommandf_App("document.changed url:%s", cstr_String(d->url));
421 clear_String(m->newSource); 427 clear_String(m->newSource);
422 m->scrollY = 0; 428 m->scrollY = 0;
423 m->state = ready_DocumentState; 429 m->state = ready_DocumentState;
424 updateVisible_DocumentWidget_(m); 430 updateVisible_DocumentWidget_(m);
425 } 431 }
426 if (d->state != ready_DocumentState) return; 432 if (d->state != ready_DocumentState) return;
427 iDrawContext ctx = { .widget = d, .bounds = documentBounds_DocumentWidget_(d) };
428 const iRect bounds = bounds_Widget(w);
429 init_Paint(&ctx.paint);
430 fillRect_Paint(&ctx.paint, bounds, gray25_ColorId);
431 setClip_Paint(&ctx.paint, bounds); 433 setClip_Paint(&ctx.paint, bounds);
432 render_GmDocument( 434 render_GmDocument(d->doc, visibleRange_DocumentWidget_(d), drawRun_DrawContext_, &ctx);
433 d->doc,
434 visibleRange_DocumentWidget_(d),
435 drawRun_DrawContext_,
436 &ctx);
437 clearClip_Paint(&ctx.paint); 435 clearClip_Paint(&ctx.paint);
438 draw_Widget(w); 436 draw_Widget(w);
439} 437}