summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c70
1 files changed, 3 insertions, 67 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9f6cdc45..f4e56d63 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -561,14 +561,6 @@ static int pageHeight_DocumentWidget_(const iDocumentWidget *d) {
561 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) + size_GmDocument(d->doc).y; 561 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) + size_GmDocument(d->doc).y;
562} 562}
563 563
564//static int footerButtonsHeight_DocumentWidget_(const iDocumentWidget *d) {
565// int height = height_Widget(d->footerButtons);
566//// if (height) {
567//// height += 3 * gap_UI; /* padding */
568//// }
569// return height;
570//}
571
572static int phoneToolbarHeight_DocumentWidget_(const iDocumentWidget *d) { 564static int phoneToolbarHeight_DocumentWidget_(const iDocumentWidget *d) {
573 if (!d->phoneToolbar) { 565 if (!d->phoneToolbar) {
574 return 0; 566 return 0;
@@ -631,18 +623,6 @@ static int viewPos_DocumentWidget_(const iDocumentWidget *d) {
631 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) - pos_SmoothScroll(&d->scrollY); 623 return height_Banner(d->banner) + documentTopPad_DocumentWidget_(d) - pos_SmoothScroll(&d->scrollY);
632} 624}
633 625
634#if 0
635static iRect siteBannerRect_DocumentWidget_(const iDocumentWidget *d) {
636 const iGmRun *banner = siteBanner_GmDocument(d->doc);
637 if (!banner) {
638 return zero_Rect();
639 }
640 const iRect docBounds = documentBounds_DocumentWidget_(d);
641 const iInt2 origin = addY_I2(topLeft_Rect(docBounds), -pos_SmoothScroll(&d->scrollY));
642 return moved_Rect(banner->visBounds, origin);
643}
644#endif
645
646static iInt2 documentPos_DocumentWidget_(const iDocumentWidget *d, iInt2 pos) { 626static iInt2 documentPos_DocumentWidget_(const iDocumentWidget *d, iInt2 pos) {
647 return addY_I2(sub_I2(pos, topLeft_Rect(documentBounds_DocumentWidget_(d))), 627 return addY_I2(sub_I2(pos, topLeft_Rect(documentBounds_DocumentWidget_(d))),
648 -viewPos_DocumentWidget_(d)); 628 -viewPos_DocumentWidget_(d));
@@ -3893,18 +3873,14 @@ static void interactingWithLink_DocumentWidget_(iDocumentWidget *d, iGmLinkId id
3893iLocalDef int wheelSwipeSide_DocumentWidget_(const iDocumentWidget *d) { 3873iLocalDef int wheelSwipeSide_DocumentWidget_(const iDocumentWidget *d) {
3894 return (d->flags & rightWheelSwipe_DocumentWidgetFlag ? 2 3874 return (d->flags & rightWheelSwipe_DocumentWidgetFlag ? 2
3895 : d->flags & leftWheelSwipe_DocumentWidgetFlag ? 1 3875 : d->flags & leftWheelSwipe_DocumentWidgetFlag ? 1
3896 : 0); 3876 : 0);
3897} 3877}
3898 3878
3899static void finishWheelSwipe_DocumentWidget_(iDocumentWidget *d) { 3879static void finishWheelSwipe_DocumentWidget_(iDocumentWidget *d) {
3900 if (d->flags & eitherWheelSwipe_DocumentWidgetFlag && 3880 if (d->flags & eitherWheelSwipe_DocumentWidgetFlag &&
3901 d->wheelSwipeState == direct_WheelSwipeState) { 3881 d->wheelSwipeState == direct_WheelSwipeState) {
3902// ~d->flags & wheelSwipeFinished_DocumentWidgetFlag) {
3903// d->wheelSwipeState = inertia_WheelSwipeState;
3904 const int side = wheelSwipeSide_DocumentWidget_(d); 3882 const int side = wheelSwipeSide_DocumentWidget_(d);
3905// d->flags |= wheelSwipeFinished_DocumentWidgetFlag;
3906 int abort = (side == 1 && d->swipeSpeed < 0 || side == 2 && d->swipeSpeed > 0); 3883 int abort = (side == 1 && d->swipeSpeed < 0 || side == 2 && d->swipeSpeed > 0);
3907 printf("speed:%f\n", d->swipeSpeed / gap_UI);
3908 if (iAbs(d->wheelSwipeDistance) < width_Widget(d) / 4 && iAbs(d->swipeSpeed) < 4 * gap_UI) { 3884 if (iAbs(d->wheelSwipeDistance) < width_Widget(d) / 4 && iAbs(d->swipeSpeed) < 4 * gap_UI) {
3909 abort = 1; 3885 abort = 1;
3910 } 3886 }
@@ -3944,10 +3920,6 @@ static iBool handleWheelSwipe_DocumentWidget_(iDocumentWidget *d, const SDL_Mous
3944 finishWheelSwipe_DocumentWidget_(d); 3920 finishWheelSwipe_DocumentWidget_(d);
3945 d->wheelSwipeState = none_WheelSwipeState; 3921 d->wheelSwipeState = none_WheelSwipeState;
3946 } 3922 }
3947// else if (isInertia_MouseWheelEvent(ev)) {
3948// finishWheelSwipe_DocumentWidget_(d);
3949// d->wheelSwipeState = inertia_WheelSwipeState;
3950// }
3951 else { 3923 else {
3952 int step = -ev->x * 2; 3924 int step = -ev->x * 2;
3953 d->wheelSwipeDistance += step; 3925 d->wheelSwipeDistance += step;
@@ -3977,14 +3949,6 @@ static iBool handleWheelSwipe_DocumentWidget_(iDocumentWidget *d, const SDL_Mous
3977 wheelSwipeSide_DocumentWidget_(d)); 3949 wheelSwipeSide_DocumentWidget_(d));
3978 } 3950 }
3979 return iTrue; 3951 return iTrue;
3980// case inertia_WheelSwipeState:
3981// if (isScrollFinished_MouseWheelEvent(ev)) {
3982// d->wheelSwipeState = none_WheelSwipeState;
3983// }
3984// else if (!isInertia_MouseWheelEvent(ev)) {
3985// d->wheelSwipeState = none_WheelSwipeState;
3986// }
3987// return iTrue;
3988 } 3952 }
3989 return iFalse; 3953 return iFalse;
3990} 3954}
@@ -4627,6 +4591,8 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
4627 return processEvent_Widget(w, ev); 4591 return processEvent_Widget(w, ev);
4628} 4592}
4629 4593
4594/*----------------------------------------------------------------------------------------------*/
4595
4630iDeclareType(DrawContext) 4596iDeclareType(DrawContext)
4631 4597
4632struct Impl_DrawContext { 4598struct Impl_DrawContext {
@@ -4753,15 +4719,6 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4753 /* Preformatted runs can be scrolled. */ 4719 /* Preformatted runs can be scrolled. */
4754 runOffset_DocumentWidget_(d->widget, run)); 4720 runOffset_DocumentWidget_(d->widget, run));
4755 const iRect visRect = { visPos, run->visBounds.size }; 4721 const iRect visRect = { visPos, run->visBounds.size };
4756#if 0
4757 if (run->flags & footer_GmRunFlag) {
4758 iRect footerBack =
4759 (iRect){ visPos, init_I2(width_Rect(d->widgetBounds), run->visBounds.size.y) };
4760 footerBack.pos.x = left_Rect(d->widgetBounds);
4761 fillRect_Paint(&d->paint, footerBack, tmBackground_ColorId);
4762 return;
4763 }
4764#endif
4765 /* Fill the background. */ { 4722 /* Fill the background. */ {
4766 if (run->linkId && linkFlags & isOpen_GmLinkFlag && ~linkFlags & content_GmLinkFlag) { 4723 if (run->linkId && linkFlags & isOpen_GmLinkFlag && ~linkFlags & content_GmLinkFlag) {
4767 /* Open links get a highlighted background. */ 4724 /* Open links get a highlighted background. */
@@ -4814,16 +4771,6 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4814 run->color, 4771 run->color,
4815 run->text); 4772 run->text);
4816 } 4773 }
4817#if 0
4818 else if (run->flags & siteBanner_GmRunFlag) {
4819 /* Banner background. */
4820 iRect bannerBack = initCorners_Rect(topLeft_Rect(d->widgetBounds),
4821 init_I2(right_Rect(bounds_Widget(constAs_Widget(d->widget))),
4822 visPos.y + height_Rect(run->visBounds)));
4823 fillRect_Paint(&d->paint, bannerBack, tmBannerBackground_ColorId);
4824 drawBannerRun_DrawContext_(d, run, visPos);
4825 }
4826#endif
4827 else { 4774 else {
4828 if (d->showLinkNumbers && run->linkId && run->flags & decoration_GmRunFlag) { 4775 if (d->showLinkNumbers && run->linkId && run->flags & decoration_GmRunFlag) {
4829 const size_t ord = visibleLinkOrdinal_DocumentWidget_(d->widget, run->linkId); 4776 const size_t ord = visibleLinkOrdinal_DocumentWidget_(d->widget, run->linkId);
@@ -5722,18 +5669,7 @@ void updateSize_DocumentWidget(iDocumentWidget *d) {
5722 arrange_Widget(d->footerButtons); 5669 arrange_Widget(d->footerButtons);
5723} 5670}
5724 5671
5725#if 0
5726static void sizeChanged_DocumentWidget_(iDocumentWidget *d) {
5727 if (current_Root()) {
5728 /* TODO: This gets called more than once during a single arrange.
5729 It could be done via some sort of callback instead. */
5730 updateVisible_DocumentWidget_(d);
5731 }
5732}
5733#endif
5734
5735iBeginDefineSubclass(DocumentWidget, Widget) 5672iBeginDefineSubclass(DocumentWidget, Widget)
5736 .processEvent = (iAny *) processEvent_DocumentWidget_, 5673 .processEvent = (iAny *) processEvent_DocumentWidget_,
5737 .draw = (iAny *) draw_DocumentWidget_, 5674 .draw = (iAny *) draw_DocumentWidget_,
5738// .sizeChanged = (iAny *) sizeChanged_DocumentWidget_,
5739iEndDefineSubclass(DocumentWidget) 5675iEndDefineSubclass(DocumentWidget)