The equalizer card scrolls instead of running off the column
Browse files at this commite7de125b8c84228c1f665f503dca369b5a50592aParent: 2ed6fe7- fix
- the equalizer card scrolls instead of running off the column
2 changed files +163 -105
- crates/app/src/main.rs +6 -0
- crates/app/src/ui/cards.rs +157 -105
crates/app/src/main.rsmodified+6 -0
| @@ -1357,6 +1357,11 @@ struct Player { | |||
| 1357 | /// follow. | 1357 | /// follow. |
| 1358 | lanes_scroll: ScrollHandle, | 1358 | lanes_scroll: ScrollHandle, |
| 1359 | inspector_scroll: ScrollHandle, | 1359 | inspector_scroll: ScrollHandle, |
| 1360 | + /// And where the equalizer card's own body has been taken to. It is the | ||
| 1361 | + /// tallest card in the column -- a graph with a row of numbers and a row of | ||
| 1362 | + /// buttons under it -- and at the 360 px floor its title and its buttons | ||
| 1363 | + /// were off both ends of the column with no way to reach them. | ||
| 1364 | + eq_scroll: ScrollHandle, | ||
| 1360 | /// The export options card is up: what the export action opens now, so | 1365 | /// The export options card is up: what the export action opens now, so |
| 1361 | /// nothing is written until the card's own button says so. One card at a | 1366 | /// nothing is written until the card's own button says so. One card at a |
| 1362 | /// time -- opening either closes the other, since both are the whole window | 1367 | /// time -- opening either closes the other, since both are the whole window |
| @@ -15767,6 +15772,7 @@ fn main() { | |||
| 15767 | keys_scroll: ScrollHandle::new(), | 15772 | keys_scroll: ScrollHandle::new(), |
| 15768 | lanes_scroll: ScrollHandle::new(), | 15773 | lanes_scroll: ScrollHandle::new(), |
| 15769 | inspector_scroll: ScrollHandle::new(), | 15774 | inspector_scroll: ScrollHandle::new(), |
| 15775 | + eq_scroll: ScrollHandle::new(), | ||
| 15770 | export_open: false, | 15776 | export_open: false, |
| 15771 | export_grouped: true, | 15777 | export_grouped: true, |
| 15772 | export_refusals_inline: false, | 15778 | export_refusals_inline: false, |
crates/app/src/ui/cards.rsmodified+157 -105
| @@ -746,6 +746,16 @@ impl Player { | |||
| 746 | // The bottom of the axis is not named: -12 dB would land in the same | 746 | // The bottom of the axis is not named: -12 dB would land in the same |
| 747 | // corner as the 20 Hz tick, and the two lines above it (+6 and -6) | 747 | // corner as the 20 Hz tick, and the two lines above it (+6 and -6) |
| 748 | // already say what the box is worth per pixel. | 748 | // already say what the box is worth per pixel. |
| 749 | + // | ||
| 750 | + // The same affordance the column itself carries, read back off the | ||
| 751 | + // card's own handle: this is the tallest card in the inspector -- a | ||
| 752 | + // 132 px graph with a row of numbers and a row of buttons under it -- | ||
| 753 | + // and at the 360 px floor it is taller than the column it is docked in. | ||
| 754 | + let can_scroll = f32::from(self.eq_scroll.max_offset().height) > 1.; | ||
| 755 | + let below = px_below( | ||
| 756 | + f32::from(self.eq_scroll.max_offset().height), | ||
| 757 | + f32::from(self.eq_scroll.offset().y), | ||
| 758 | + ); | ||
| 749 | Some( | 759 | Some( |
| 750 | drag_scrim(cx) | 760 | drag_scrim(cx) |
| 751 | .flex() | 761 | .flex() |
| @@ -771,6 +781,12 @@ impl Player { | |||
| 771 | // way for the same reason. | 781 | // way for the same reason. |
| 772 | .w_full() | 782 | .w_full() |
| 773 | .max_w(px(eq_card_w(f32::from(viewport.width)))) | 783 | .max_w(px(eq_card_w(f32::from(viewport.width)))) |
| 784 | + // And a cap the other way, for the same reason the width | ||
| 785 | + // has one: the card is docked in a column now, and at the | ||
| 786 | + // 360 px floor it is taller than that column -- its title | ||
| 787 | + // ran off the top and its buttons off the bottom, with | ||
| 788 | + // neither reachable. Capped here, scrolled below. | ||
| 789 | + .max_h(relative(1.)) | ||
| 774 | .on_mouse_down(MouseButton::Left, swallow) | 790 | .on_mouse_down(MouseButton::Left, swallow) |
| 775 | .flex() | 791 | .flex() |
| 776 | .flex_col() | 792 | .flex_col() |
| @@ -778,121 +794,157 @@ impl Player { | |||
| 778 | .p(px(12.)) | 794 | .p(px(12.)) |
| 779 | .rounded(px(6.)) | 795 | .rounded(px(6.)) |
| 780 | .bg(rgb(BG_RAISED)) | 796 | .bg(rgb(BG_RAISED)) |
| 781 | - // Which clip, because the card is modal and the lane it | ||
| 782 | - // was opened from is behind a scrim by the time it is up. | ||
| 783 | - .child(div().flex_none().px(px(6.)).child(format!( | ||
| 784 | - "Equalizer — {} clip {}", | ||
| 785 | - lane.label(), | ||
| 786 | - idx + 1 | ||
| 787 | - ))) | ||
| 788 | - .child( | ||
| 789 | - div() | ||
| 790 | - .flex_none() | ||
| 791 | - .px(px(6.)) | ||
| 792 | - .text_size(px(11.)) | ||
| 793 | - .text_color(rgb(FG_SECONDARY)) | ||
| 794 | - .child(self.notices.front().cloned().unwrap_or_else(|| { | ||
| 795 | - "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into() | ||
| 796 | - })), | ||
| 797 | - ) | ||
| 798 | - .child(graph) | ||
| 799 | - // Which band the keyboard is holding and every number it | ||
| 800 | - // is set to, each with the pair of buttons that moves it: | ||
| 801 | - // the curve shows the sum, and a band pushed against one | ||
| 802 | - // pulling the other way is not readable off it. | ||
| 803 | - .child(self.eq_numbers(picked, cx)) | ||
| 804 | .child( | 797 | .child( |
| 805 | div() | 798 | div() |
| 806 | - .mt(px(4.)) | 799 | + .id("eq-card-rows") |
| 800 | + // Shrinkable below its content, which is what | ||
| 801 | + // makes the cap above a scroll rather than a | ||
| 802 | + // clip; the rows themselves keep their heights. | ||
| 803 | + .min_h(px(0.)) | ||
| 804 | + .overflow_y_scroll() | ||
| 805 | + .track_scroll(&self.eq_scroll) | ||
| 807 | .flex() | 806 | .flex() |
| 808 | - .gap(px(4.)) | 807 | + .flex_col() |
| 809 | - .child( | 808 | + .gap(px(2.)) |
| 810 | - div() | 809 | + // Which clip, because the card is modal and the lane it |
| 811 | - .id("eq-reset") | 810 | + // was opened from is behind a scrim by the time it is up. |
| 812 | - .flex() | 811 | + .child(div().flex_none().px(px(6.)).child(format!( |
| 813 | - .flex_1() | 812 | + "Equalizer — {} clip {}", |
| 814 | - .h(px(CONTROL_H)) | 813 | + lane.label(), |
| 815 | - .items_center() | 814 | + idx + 1 |
| 816 | - .justify_center() | 815 | + ))) |
| 817 | - .rounded(px(3.)) | ||
| 818 | - .bg(rgb(BG_SELECTED)) | ||
| 819 | - .cursor_pointer() | ||
| 820 | - .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 821 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 822 | - for band in &mut this.eq_params.bands { | ||
| 823 | - band.gain_db = 0.; | ||
| 824 | - } | ||
| 825 | - this.commit_eq(cx); | ||
| 826 | - })) | ||
| 827 | - .child("Flatten all"), | ||
| 828 | - ) | ||
| 829 | - // The two that change how many bands there are. | ||
| 830 | - // The engine takes any cascade -- the count was | ||
| 831 | - // only ever fixed because this card had no way | ||
| 832 | - // to say otherwise. | ||
| 833 | - .child( | ||
| 834 | - div() | ||
| 835 | - .id("eq-add") | ||
| 836 | - .flex() | ||
| 837 | - .flex_1() | ||
| 838 | - .h(px(CONTROL_H)) | ||
| 839 | - .items_center() | ||
| 840 | - .justify_center() | ||
| 841 | - .rounded(px(3.)) | ||
| 842 | - .bg(rgb(BG_PANEL)) | ||
| 843 | - .cursor_pointer() | ||
| 844 | - .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 845 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 846 | - this.add_band(cx) | ||
| 847 | - })) | ||
| 848 | - .child("Add band"), | ||
| 849 | - ) | ||
| 850 | .child( | 816 | .child( |
| 851 | div() | 817 | div() |
| 852 | - .id("eq-remove") | 818 | + .flex_none() |
| 853 | - .flex() | 819 | + .px(px(6.)) |
| 854 | - .flex_1() | 820 | + .text_size(px(11.)) |
| 855 | - .h(px(CONTROL_H)) | 821 | + .text_color(rgb(FG_SECONDARY)) |
| 856 | - .items_center() | 822 | + .child(self.notices.front().cloned().unwrap_or_else(|| { |
| 857 | - .justify_center() | 823 | + "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into() |
| 858 | - .rounded(px(3.)) | 824 | + })), |
| 859 | - .bg(rgb(BG_PANEL)) | ||
| 860 | - .cursor_pointer() | ||
| 861 | - .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 862 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 863 | - this.remove_band(cx) | ||
| 864 | - })) | ||
| 865 | - .child("Remove band"), | ||
| 866 | ) | 825 | ) |
| 867 | - // The analyser's switch, next to the one other | 826 | + .child(graph) |
| 868 | - // button the card has: `s` does the same, and a | 827 | + // Which band the keyboard is holding and every number it |
| 869 | - // toggle only a keystroke can reach is one most | 828 | + // is set to, each with the pair of buttons that moves it: |
| 870 | - // people never find. | 829 | + // the curve shows the sum, and a band pushed against one |
| 830 | + // pulling the other way is not readable off it. | ||
| 831 | + .child(self.eq_numbers(picked, cx)) | ||
| 871 | .child( | 832 | .child( |
| 872 | div() | 833 | div() |
| 873 | - .id("eq-spectrum") | 834 | + .mt(px(4.)) |
| 874 | .flex() | 835 | .flex() |
| 875 | - .flex_1() | 836 | + .gap(px(4.)) |
| 876 | - .h(px(CONTROL_H)) | 837 | + .child( |
| 877 | - .items_center() | 838 | + div() |
| 878 | - .justify_center() | 839 | + .id("eq-reset") |
| 879 | - .rounded(px(3.)) | 840 | + .flex() |
| 880 | - .bg(rgb(match self.eq_spectrum { | 841 | + .flex_1() |
| 881 | - true => BG_SELECTED, | 842 | + .h(px(CONTROL_H)) |
| 882 | - false => BG_HOVER_DIM, | 843 | + .items_center() |
| 883 | - })) | 844 | + .justify_center() |
| 884 | - .cursor_pointer() | 845 | + .rounded(px(3.)) |
| 885 | - .hover(|s| s.bg(rgb(BG_HOVER))) | 846 | + .bg(rgb(BG_SELECTED)) |
| 886 | - .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | 847 | + .cursor_pointer() |
| 887 | - this.eq_spectrum = !this.eq_spectrum; | 848 | + .hover(|s| s.bg(rgb(BG_HOVER))) |
| 888 | - cx.notify(); | 849 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { |
| 889 | - })) | 850 | + for band in &mut this.eq_params.bands { |
| 890 | - .child(match self.eq_spectrum { | 851 | + band.gain_db = 0.; |
| 891 | - true => "Spectrum on", | 852 | + } |
| 892 | - false => "Spectrum off", | 853 | + this.commit_eq(cx); |
| 893 | - }), | 854 | + })) |
| 855 | + .child("Flatten all"), | ||
| 856 | + ) | ||
| 857 | + // The two that change how many bands there are. | ||
| 858 | + // The engine takes any cascade -- the count was | ||
| 859 | + // only ever fixed because this card had no way | ||
| 860 | + // to say otherwise. | ||
| 861 | + .child( | ||
| 862 | + div() | ||
| 863 | + .id("eq-add") | ||
| 864 | + .flex() | ||
| 865 | + .flex_1() | ||
| 866 | + .h(px(CONTROL_H)) | ||
| 867 | + .items_center() | ||
| 868 | + .justify_center() | ||
| 869 | + .rounded(px(3.)) | ||
| 870 | + .bg(rgb(BG_PANEL)) | ||
| 871 | + .cursor_pointer() | ||
| 872 | + .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 873 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 874 | + this.add_band(cx) | ||
| 875 | + })) | ||
| 876 | + .child("Add band"), | ||
| 877 | + ) | ||
| 878 | + .child( | ||
| 879 | + div() | ||
| 880 | + .id("eq-remove") | ||
| 881 | + .flex() | ||
| 882 | + .flex_1() | ||
| 883 | + .h(px(CONTROL_H)) | ||
| 884 | + .items_center() | ||
| 885 | + .justify_center() | ||
| 886 | + .rounded(px(3.)) | ||
| 887 | + .bg(rgb(BG_PANEL)) | ||
| 888 | + .cursor_pointer() | ||
| 889 | + .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 890 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 891 | + this.remove_band(cx) | ||
| 892 | + })) | ||
| 893 | + .child("Remove band"), | ||
| 894 | + ) | ||
| 895 | + // The analyser's switch, next to the one other | ||
| 896 | + // button the card has: `s` does the same, and a | ||
| 897 | + // toggle only a keystroke can reach is one most | ||
| 898 | + // people never find. | ||
| 899 | + .child( | ||
| 900 | + div() | ||
| 901 | + .id("eq-spectrum") | ||
| 902 | + .flex() | ||
| 903 | + .flex_1() | ||
| 904 | + .h(px(CONTROL_H)) | ||
| 905 | + .items_center() | ||
| 906 | + .justify_center() | ||
| 907 | + .rounded(px(3.)) | ||
| 908 | + .bg(rgb(match self.eq_spectrum { | ||
| 909 | + true => BG_SELECTED, | ||
| 910 | + false => BG_HOVER_DIM, | ||
| 911 | + })) | ||
| 912 | + .cursor_pointer() | ||
| 913 | + .hover(|s| s.bg(rgb(BG_HOVER))) | ||
| 914 | + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { | ||
| 915 | + this.eq_spectrum = !this.eq_spectrum; | ||
| 916 | + cx.notify(); | ||
| 917 | + })) | ||
| 918 | + .child(match self.eq_spectrum { | ||
| 919 | + true => "Spectrum on", | ||
| 920 | + false => "Spectrum off", | ||
| 921 | + }), | ||
| 922 | + ), | ||
| 894 | ), | 923 | ), |
| 895 | - ), | 924 | + ) |
| 925 | + // The column's own line, on the card that needs it for | ||
| 926 | + // the column's reason: a row nobody knows is under the | ||
| 927 | + // fold is a row that is not there. | ||
| 928 | + .when(can_scroll, |d| { | ||
| 929 | + d.child( | ||
| 930 | + div() | ||
| 931 | + .flex_none() | ||
| 932 | + .h(px(LABEL_H)) | ||
| 933 | + .flex() | ||
| 934 | + .items_center() | ||
| 935 | + .justify_end() | ||
| 936 | + .px(px(6.)) | ||
| 937 | + .text_size(px(10.)) | ||
| 938 | + .text_color(rgb(match below > 1. { | ||
| 939 | + true => ACCENT_PRIMARY, | ||
| 940 | + false => FG_SECONDARY, | ||
| 941 | + })) | ||
| 942 | + .child(match below > 1. { | ||
| 943 | + true => "more below — scroll the card", | ||
| 944 | + false => "the end — scroll up for the rest", | ||
| 945 | + }), | ||
| 946 | + ) | ||
| 947 | + }), | ||
| 896 | ), | 948 | ), |
| 897 | ) | 949 | ) |
| 898 | } | 950 | } |