shithub: orca

Download patch

ref: 721e9b2311e75fcdff329b6e1b026509ce7c0986
parent: fc2d1d3e3e231ca86d3cb8277856436ff034acfb
author: cancel <cancel@cancel.fm>
date: Wed Jan 1 21:28:04 EST 2020

Add dimming of inactive/non-foreground menu contents

--- a/term_util.c
+++ b/term_util.c
@@ -255,6 +255,12 @@
   ++qm->items_count;
   qm->ncurses_items[qm->items_count] = NULL;
 }
+void qmenu_set_displayed_active(Qmenu* qm, bool active) {
+  // Could add a flag in the Qmenu to avoid redundantly changing this stuff.
+  set_menu_fore(qm->ncurses_menu, active ? A_BOLD : A_DIM);
+  set_menu_back(qm->ncurses_menu, active ? A_NORMAL : A_DIM);
+  set_menu_grey(qm->ncurses_menu, active ? A_DIM : A_DIM);
+}
 void qmenu_push_to_nav(Qmenu* qm) {
   qm->ncurses_menu = new_menu(qm->ncurses_items);
   set_menu_mark(qm->ncurses_menu, " > ");
--- a/term_util.h
+++ b/term_util.h
@@ -127,6 +127,7 @@
 void qmenu_set_title(Qmenu* qm, char const* title);
 void qmenu_add_choice(Qmenu* qm, char const* text, int id);
 void qmenu_add_spacer(Qmenu* qm);
+void qmenu_set_displayed_active(Qmenu* qm, bool active);
 void qmenu_push_to_nav(Qmenu* qm);
 bool qmenu_drive(Qmenu* qm, int key, Qmenu_action* out_action);
 Qmenu* qmenu_of(Qblock* qb);
--- a/tui_main.c
+++ b/tui_main.c
@@ -2287,7 +2287,18 @@
       for (Usz i = 0; i < qnav_stack.count; ++i) {
         Qblock* qb = qnav_stack.blocks[i];
         if (qnav_stack.stack_changed) {
-          qblock_print_frame(qb, i == qnav_stack.count - 1);
+          bool is_frontmost = i == qnav_stack.count - 1;
+          qblock_print_frame(qb, is_frontmost);
+          switch (qb->tag) {
+          case Qblock_type_qmsg:
+            break;
+          case Qblock_type_qmenu: {
+            Qmenu* qm = qmenu_of(qb);
+            qmenu_set_displayed_active(qm, is_frontmost);
+          } break;
+          case Qblock_type_qform:
+            break;
+          }
         }
         touchwin(qb->outer_window);
         wnoutrefresh(qb->outer_window);