summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 22:27:02 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 22:27:02 +0200
commit9cdf86dc8dda0ebf777dfdec5c1eeef53371a1ee (patch)
tree340b4bac4c96c9711e4845ff994701176a3dd267 /src/ui/util.c
parent3e56e0f1ca20d7d0489036ce0f0bca97d596f0d5 (diff)
Cut/copy/paste paste via menus
IssueID #175
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 04dbe190..adb3c4b4 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -517,14 +517,21 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
517} 517}
518 518
519void openMenu_Widget(iWidget *d, iInt2 coord) { 519void openMenu_Widget(iWidget *d, iInt2 coord) {
520 openMenuFlags_Widget(d, coord, iTrue);
521}
522
523void openMenuFlags_Widget(iWidget *d, iInt2 coord, iBool postCommands) {
520 const iInt2 rootSize = rootSize_Window(get_Window()); 524 const iInt2 rootSize = rootSize_Window(get_Window());
521 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 525 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App());
522 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0; 526 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0;
527 if (postCommands) {
528 postCommand_App("cancel"); /* dismiss any other menus */
529 }
523 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */ 530 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */
524 postCommand_App("cancel"); /* dismiss any other menus */
525 processEvents_App(postedEventsOnly_AppEventMode); 531 processEvents_App(postedEventsOnly_AppEventMode);
526 setFlags_Widget(d, hidden_WidgetFlag | disabled_WidgetFlag, iFalse); 532 setFlags_Widget(d, hidden_WidgetFlag | disabled_WidgetFlag, iFalse);
527 setFlags_Widget(d, commandOnMouseMiss_WidgetFlag, iTrue); 533 setFlags_Widget(d, commandOnMouseMiss_WidgetFlag, iTrue);
534 raise_Widget(d);
528 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse); 535 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse);
529 if (isPortraitPhone) { 536 if (isPortraitPhone) {
530 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, iFalse); 537 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, iFalse);
@@ -576,7 +583,7 @@ void openMenu_Widget(iWidget *d, iInt2 coord) {
576 float l, t, r, b; 583 float l, t, r, b;
577 safeAreaInsets_iOS(&l, &t, &r, &b); 584 safeAreaInsets_iOS(&l, &t, &r, &b);
578 topExcess += t; 585 topExcess += t;
579 bottomExcess += b; 586 bottomExcess += iMax(b, get_Window()->keyboardHeight);
580 leftExcess += l; 587 leftExcess += l;
581 rightExcess += r; 588 rightExcess += r;
582 } 589 }
@@ -594,7 +601,9 @@ void openMenu_Widget(iWidget *d, iInt2 coord) {
594 d->rect.pos.x += leftExcess; 601 d->rect.pos.x += leftExcess;
595 } 602 }
596 postRefresh_App(); 603 postRefresh_App();
597 postCommand_Widget(d, "menu.opened"); 604 if (postCommands) {
605 postCommand_Widget(d, "menu.opened");
606 }
598 if (isPortraitPhone) { 607 if (isPortraitPhone) {
599 setVisualOffset_Widget(d, isSlidePanel ? width_Widget(d) : height_Widget(d), 0, 0); 608 setVisualOffset_Widget(d, isSlidePanel ? width_Widget(d) : height_Widget(d), 0, 0);
600 setVisualOffset_Widget(d, 0, 330, easeOut_AnimFlag | softer_AnimFlag); 609 setVisualOffset_Widget(d, 0, 330, easeOut_AnimFlag | softer_AnimFlag);