diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/documentwidget.c | 12 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 5 | ||||
-rw-r--r-- | src/ui/inputwidget.h | 1 | ||||
-rw-r--r-- | src/ui/touch.c | 16 | ||||
-rw-r--r-- | src/ui/util.c | 32 |
5 files changed, 62 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 0fa9b3f7..9b412783 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2495,11 +2495,17 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2495 | (iMenuItem[]){ { "Copy", 0, 0, "copy" }, { "---", 0, 0, NULL } }, | 2495 | (iMenuItem[]){ { "Copy", 0, 0, "copy" }, { "---", 0, 0, NULL } }, |
2496 | 2); | 2496 | 2); |
2497 | } | 2497 | } |
2498 | if (deviceType_App() == desktop_AppDeviceType) { | ||
2499 | pushBackN_Array( | ||
2500 | &items, | ||
2501 | (iMenuItem[]){ | ||
2502 | { "Go Back", navigateBack_KeyShortcut, "navigate.back" }, | ||
2503 | { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" } }, | ||
2504 | 2); | ||
2505 | } | ||
2498 | pushBackN_Array( | 2506 | pushBackN_Array( |
2499 | &items, | 2507 | &items, |
2500 | (iMenuItem[]){ | 2508 | (iMenuItem[]){ |
2501 | { "Go Back", navigateBack_KeyShortcut, "navigate.back" }, | ||
2502 | { "Go Forward", navigateForward_KeyShortcut, "navigate.forward" }, | ||
2503 | { upArrow_Icon " Go to Parent", navigateParent_KeyShortcut, "navigate.parent" }, | 2509 | { upArrow_Icon " Go to Parent", navigateParent_KeyShortcut, "navigate.parent" }, |
2504 | { upArrowBar_Icon " Go to Root", navigateRoot_KeyShortcut, "navigate.root" }, | 2510 | { upArrowBar_Icon " Go to Root", navigateRoot_KeyShortcut, "navigate.root" }, |
2505 | { "---", 0, 0, NULL }, | 2511 | { "---", 0, 0, NULL }, |
@@ -2512,7 +2518,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2512 | { book_Icon " Import Links as Bookmarks...", 0, 0, "bookmark.links confirm:1" }, | 2518 | { book_Icon " Import Links as Bookmarks...", 0, 0, "bookmark.links confirm:1" }, |
2513 | { "---", 0, 0, NULL }, | 2519 | { "---", 0, 0, NULL }, |
2514 | { "Copy Page URL", 0, 0, "document.copylink" } }, | 2520 | { "Copy Page URL", 0, 0, "document.copylink" } }, |
2515 | 13); | 2521 | 11); |
2516 | if (isEmpty_Range(&d->selectMark)) { | 2522 | if (isEmpty_Range(&d->selectMark)) { |
2517 | pushBackN_Array( | 2523 | pushBackN_Array( |
2518 | &items, | 2524 | &items, |
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 11ea0674..267ccdf7 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -165,6 +165,11 @@ void deinit_InputWidget(iInputWidget *d) { | |||
165 | deinit_Array(&d->text); | 165 | deinit_Array(&d->text); |
166 | } | 166 | } |
167 | 167 | ||
168 | void setFont_InputWidget(iInputWidget *d, int fontId) { | ||
169 | d->font = fontId; | ||
170 | updateMetrics_InputWidget_(d); | ||
171 | } | ||
172 | |||
168 | static void pushUndo_InputWidget_(iInputWidget *d) { | 173 | static void pushUndo_InputWidget_(iInputWidget *d) { |
169 | iInputUndo undo; | 174 | iInputUndo undo; |
170 | init_InputUndo_(&undo, &d->text, d->cursor); | 175 | init_InputUndo_(&undo, &d->text, d->cursor); |
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h index 3c7b2ffb..fc768e05 100644 --- a/src/ui/inputwidget.h +++ b/src/ui/inputwidget.h | |||
@@ -37,6 +37,7 @@ void setMode_InputWidget (iInputWidget *, enum iInputMode mode); | |||
37 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); | 37 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); |
38 | void setText_InputWidget (iInputWidget *, const iString *text); | 38 | void setText_InputWidget (iInputWidget *, const iString *text); |
39 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); | 39 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); |
40 | void setFont_InputWidget (iInputWidget *, int fontId); | ||
40 | void setCursor_InputWidget (iInputWidget *, size_t pos); | 41 | void setCursor_InputWidget (iInputWidget *, size_t pos); |
41 | void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ | 42 | void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ |
42 | void begin_InputWidget (iInputWidget *); | 43 | void begin_InputWidget (iInputWidget *); |
diff --git a/src/ui/touch.c b/src/ui/touch.c index e3c7b9a1..27db0073 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -245,6 +245,16 @@ static void dispatchButtonUp_Touch_(iFloat3 pos) { | |||
245 | }); | 245 | }); |
246 | } | 246 | } |
247 | 247 | ||
248 | static iWidget *findOverflowScrollable_Widget_(iWidget *d) { | ||
249 | const iInt2 rootSize = rootSize_Window(get_Window()); | ||
250 | for (iWidget *w = d; w; w = parent_Widget(w)) { | ||
251 | if (flags_Widget(w) & overflowScrollable_WidgetFlag && height_Widget(w) > rootSize.y) { | ||
252 | return w; | ||
253 | } | ||
254 | } | ||
255 | return NULL; | ||
256 | } | ||
257 | |||
248 | iBool processEvent_Touch(const SDL_Event *ev) { | 258 | iBool processEvent_Touch(const SDL_Event *ev) { |
249 | /* We only handle finger events here. */ | 259 | /* We only handle finger events here. */ |
250 | if (ev->type != SDL_FINGERDOWN && ev->type != SDL_FINGERMOTION && ev->type != SDL_FINGERUP) { | 260 | if (ev->type != SDL_FINGERDOWN && ev->type != SDL_FINGERMOTION && ev->type != SDL_FINGERUP) { |
@@ -329,6 +339,11 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
329 | the first one. */ | 339 | the first one. */ |
330 | divvf_F3(&touch->accum, 6); | 340 | divvf_F3(&touch->accum, 6); |
331 | divfv_I2(&pixels, 6); | 341 | divfv_I2(&pixels, 6); |
342 | /* Allow scrolling a scrollable widget. */ | ||
343 | iWidget *flow = findOverflowScrollable_Widget_(touch->affinity); | ||
344 | if (flow) { | ||
345 | touch->affinity = flow; | ||
346 | } | ||
332 | } | 347 | } |
333 | else { | 348 | else { |
334 | touch->accum = zero_F3(); | 349 | touch->accum = zero_F3(); |
@@ -367,6 +382,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
367 | // class_Widget(touch->affinity)->name, | 382 | // class_Widget(touch->affinity)->name, |
368 | // pixels.y, y_F3(amount), y_F3(touch->accum)); | 383 | // pixels.y, y_F3(amount), y_F3(touch->accum)); |
369 | if (pixels.x || pixels.y) { | 384 | if (pixels.x || pixels.y) { |
385 | setFocus_Widget(NULL); | ||
370 | dispatchMotion_Touch_(pos, 0); | 386 | dispatchMotion_Touch_(pos, 0); |
371 | dispatchEvent_Widget(touch->affinity, (SDL_Event *) &(SDL_MouseWheelEvent){ | 387 | dispatchEvent_Widget(touch->affinity, (SDL_Event *) &(SDL_MouseWheelEvent){ |
372 | .type = SDL_MOUSEWHEEL, | 388 | .type = SDL_MOUSEWHEEL, |
diff --git a/src/ui/util.c b/src/ui/util.c index df44cc80..29ac04a3 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -359,7 +359,7 @@ iWidget *makePadding_Widget(int size) { | |||
359 | 359 | ||
360 | iLabelWidget *makeHeading_Widget(const char *text) { | 360 | iLabelWidget *makeHeading_Widget(const char *text) { |
361 | iLabelWidget *heading = new_LabelWidget(text, NULL); | 361 | iLabelWidget *heading = new_LabelWidget(text, NULL); |
362 | setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue); | 362 | setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | alignLeft_WidgetFlag /*| fixedSize_WidgetFlag*/, iTrue); |
363 | setBackgroundColor_Widget(as_Widget(heading), none_ColorId); | 363 | setBackgroundColor_Widget(as_Widget(heading), none_ColorId); |
364 | return heading; | 364 | return heading; |
365 | } | 365 | } |
@@ -931,14 +931,32 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
931 | iWidget *value = child_Widget(values, 0); | 931 | iWidget *value = child_Widget(values, 0); |
932 | removeChild_Widget(headings, heading); | 932 | removeChild_Widget(headings, heading); |
933 | removeChild_Widget(values, value); | 933 | removeChild_Widget(values, value); |
934 | iLabelWidget *headingLabel = NULL; | ||
934 | iLabelWidget *valueLabel = NULL; | 935 | iLabelWidget *valueLabel = NULL; |
936 | iInputWidget *valueInput = NULL; | ||
937 | if (isInstance_Object(heading, &Class_LabelWidget)) { | ||
938 | headingLabel = (iLabelWidget *) heading; | ||
939 | } | ||
935 | if (isInstance_Object(value, &Class_LabelWidget)) { | 940 | if (isInstance_Object(value, &Class_LabelWidget)) { |
936 | valueLabel = (iLabelWidget *) value; | 941 | valueLabel = (iLabelWidget *) value; |
937 | } | 942 | } |
943 | if (isInstance_Object(value, &Class_InputWidget)) { | ||
944 | valueInput = (iInputWidget *) value; | ||
945 | } | ||
946 | if (valueLabel) { | ||
947 | setFont_LabelWidget(valueLabel, defaultBig_FontId); | ||
948 | } | ||
949 | if (valueInput) { | ||
950 | setFont_InputWidget(valueInput, defaultBig_FontId); | ||
951 | setContentPadding_InputWidget(valueInput, 3 * gap_UI, 3 * gap_UI); | ||
952 | } | ||
938 | /* Toggles have the button on the right. */ | 953 | /* Toggles have the button on the right. */ |
939 | if (valueLabel && cmp_String(command_LabelWidget(valueLabel), "toggle") == 0) { | 954 | if (valueLabel && cmp_String(command_LabelWidget(valueLabel), "toggle") == 0) { |
940 | iWidget *div = new_Widget(); | 955 | iWidget *div = new_Widget(); |
956 | setFrameColor_Widget(div, uiSeparator_ColorId); | ||
957 | setPadding_Widget(div, gap_UI, gap_UI, 4 * gap_UI, gap_UI); | ||
941 | addChildFlags_Widget(div, iClob(heading), 0); | 958 | addChildFlags_Widget(div, iClob(heading), 0); |
959 | setFont_LabelWidget((iLabelWidget *) heading, defaultBig_FontId); | ||
942 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); | 960 | addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); |
943 | addChild_Widget(div, iClob(value)); | 961 | addChild_Widget(div, iClob(value)); |
944 | addChildFlags_Widget(sheet, | 962 | addChildFlags_Widget(sheet, |
@@ -952,9 +970,15 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
952 | /* Subheading padding goes above. */ | 970 | /* Subheading padding goes above. */ |
953 | addChild_Widget(sheet, iClob(value)); | 971 | addChild_Widget(sheet, iClob(value)); |
954 | addChild_Widget(sheet, iClob(heading)); | 972 | addChild_Widget(sheet, iClob(heading)); |
973 | setFont_LabelWidget(headingLabel, uiLabelBold_FontId); | ||
955 | } | 974 | } |
956 | else { | 975 | else { |
957 | addChild_Widget(sheet, iClob(heading)); | 976 | addChild_Widget(sheet, iClob(heading)); |
977 | if (headingLabel) { | ||
978 | setTextColor_LabelWidget(headingLabel, uiSubheading_ColorId); | ||
979 | setText_LabelWidget(headingLabel, | ||
980 | collect_String(upper_String(text_LabelWidget(headingLabel)))); | ||
981 | } | ||
958 | addChild_Widget(sheet, iClob(value)); | 982 | addChild_Widget(sheet, iClob(value)); |
959 | /* Align radio buttons to the right. */ | 983 | /* Align radio buttons to the right. */ |
960 | if (childCount_Widget(value)) { | 984 | if (childCount_Widget(value)) { |
@@ -962,6 +986,12 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
962 | resizeToParentWidth_WidgetFlag | | 986 | resizeToParentWidth_WidgetFlag | |
963 | resizeWidthOfChildren_WidgetFlag, | 987 | resizeWidthOfChildren_WidgetFlag, |
964 | iTrue); | 988 | iTrue); |
989 | iForEach(ObjectList, sub, children_Widget(value)) { | ||
990 | if (isInstance_Object(sub.object, &Class_LabelWidget)) { | ||
991 | iLabelWidget *opt = sub.object; | ||
992 | setFont_LabelWidget(opt, defaultBig_FontId); | ||
993 | } | ||
994 | } | ||
965 | } | 995 | } |
966 | } | 996 | } |
967 | } | 997 | } |