summaryrefslogtreecommitdiffstats
path: root/src/gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gui.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/gui.cpp b/src/gui.cpp
index eb53dff..ebc1f62 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -1672,10 +1672,11 @@ void gui_handle_input() {
1672// Draw 1672// Draw
1673// --------------------------------------------------------------------------- 1673// ---------------------------------------------------------------------------
1674 1674
1675static void draw_checkbox(int x, int y, bool on) { 1675static void draw_checkbox(int x, int y, bool on,
1676 const Rect *clip = nullptr) {
1676 Rect box{x, y, S(15.0f), S(15.0f)}; 1677 Rect box{x, y, S(15.0f), S(15.0f)};
1677 fill(box, on ? C_ACCENT : Col{30, 34, 42, 255}); 1678 fill(box, on ? C_ACCENT : Col{30, 34, 42, 255}, clip);
1678 outline(box, C_BORDER); 1679 outline(box, C_BORDER, clip);
1679 if (on) { 1680 if (on) {
1680 line(x + S(3.0f), y + S(8.0f), x + S(7.0f), y + S(12.0f), C_BG); 1681 line(x + S(3.0f), y + S(8.0f), x + S(7.0f), y + S(12.0f), C_BG);
1681 line(x + S(7.0f), y + S(12.0f), x + S(13.0f), y + S(4.0f), C_BG); 1682 line(x + S(7.0f), y + S(12.0f), x + S(13.0f), y + S(4.0f), C_BG);
@@ -1719,14 +1720,17 @@ static void draw_card(const Rect &clip, int index, int y) {
1719 Rect head{cr.x, cr.y, cr.w, hh}; 1720 Rect head{cr.x, cr.y, cr.w, hh};
1720 fill(head, C_HEADER, &clip); 1721 fill(head, C_HEADER, &clip);
1721 1722
1722 // expand arrow 1723 // expand arrow (clipped like the rest of the card; header rows of cards
1724 // scrolled out of view must not leak into the window chrome)
1723 int ax = cr.x + S(10.0f), ay = cr.y + (hh - S(8.0f)) / 2; 1725 int ax = cr.x + S(10.0f), ay = cr.y + (hh - S(8.0f)) / 2;
1724 if (c.expanded) { 1726 if (ay >= clip.y && ay + S(8.0f) <= clip.y + clip.h) {
1725 line(ax, ay, ax + S(4.0f), ay + S(5.0f), C_DIM); 1727 if (c.expanded) {
1726 line(ax + S(4.0f), ay + S(5.0f), ax + S(8.0f), ay, C_DIM); 1728 line(ax, ay, ax + S(4.0f), ay + S(5.0f), C_DIM);
1727 } else { 1729 line(ax + S(4.0f), ay + S(5.0f), ax + S(8.0f), ay, C_DIM);
1728 line(ax, ay, ax + S(5.0f), ay + S(4.0f), C_DIM); 1730 } else {
1729 line(ax + S(5.0f), ay + S(4.0f), ax, ay + S(8.0f), C_DIM); 1731 line(ax, ay, ax + S(5.0f), ay + S(4.0f), C_DIM);
1732 line(ax + S(5.0f), ay + S(4.0f), ax, ay + S(8.0f), C_DIM);
1733 }
1730 } 1734 }
1731 1735
1732 // title (wraps instead of truncating) 1736 // title (wraps instead of truncating)
@@ -1741,7 +1745,7 @@ static void draw_card(const Rect &clip, int index, int y) {
1741 if (c.feat) { 1745 if (c.feat) {
1742 bool active = c.feat->active; 1746 bool active = c.feat->active;
1743 int active_y = cr.y + (hh - S(18.0f)) / 2; 1747 int active_y = cr.y + (hh - S(18.0f)) / 2;
1744 draw_checkbox(cr.x + cr.w - S(170.0f), active_y, active); 1748 draw_checkbox(cr.x + cr.w - S(170.0f), active_y, active, &clip);
1745 text_in(clip, cr.x + cr.w - S(148.0f), 1749 text_in(clip, cr.x + cr.w - S(148.0f),
1746 active_y + (S(18.0f) - g_body_h) / 2, active ? "On" : "Off", 1750 active_y + (S(18.0f) - g_body_h) / 2, active ? "On" : "Off",
1747 g_font_body, g_body_h, 0, active ? C_GOOD : C_DIM); 1751 g_font_body, g_body_h, 0, active ? C_GOOD : C_DIM);
@@ -1798,7 +1802,8 @@ static void draw_card(const Rect &clip, int index, int y) {
1798 maxw, C_TEXT, S(2.0f)); 1802 maxw, C_TEXT, S(2.0f));
1799 if (ct.kind == CK_TOGGLE) { 1803 if (ct.kind == CK_TOGGLE) {
1800 bool on = ctrl_val(ct) != 0; 1804 bool on = ctrl_val(ct) != 0;
1801 draw_checkbox(cr.x + cr.w - S(31.0f), by + (rh - S(15.0f)) / 2, on); 1805 draw_checkbox(cr.x + cr.w - S(31.0f), by + (rh - S(15.0f)) / 2, on,
1806 &clip);
1802 text_in(clip, cr.x + cr.w - S(58.0f), by + (rh - g_body_h) / 2, 1807 text_in(clip, cr.x + cr.w - S(58.0f), by + (rh - g_body_h) / 2,
1803 on ? "On" : "Off", g_font_body, g_body_h, 0, 1808 on ? "On" : "Off", g_font_body, g_body_h, 0,
1804 on ? C_GOOD : C_DIM); 1809 on ? C_GOOD : C_DIM);