dash-frontend: Scrollable audio device list (Closes #353), wgui: fix scrollbar rendering

This commit is contained in:
Aleksander
2026-01-11 11:11:01 +01:00
parent 6b98d5f188
commit 37e3ab1bda
3 changed files with 28 additions and 26 deletions

View File

@@ -46,7 +46,8 @@
</template>
<elements>
<div id="devices" flex_direction="column" gap="4">
<div flex_direction="column" gap="4">
<div id="devices" flex_direction="column" gap="4" max_height="400" overflow_y="scroll">
</div>
@@ -64,5 +65,6 @@
<BottomButton id="btn_sources" src_builtin="dashboard/microphone.svg" translation="AUDIO.MICROPHONES" />
<BottomButton id="btn_cards" src_builtin="dashboard/cpu.svg" translation="AUDIO.CARDS" />
</div>
</div>
</elements>
</layout>

View File

@@ -19,8 +19,8 @@ use wlx_common::{audio, dash_interface::BoxDashInterface, timestep::Timestep};
use crate::{
assets,
tab::{
apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses, settings::TabSettings,
Tab, TabType,
Tab, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses,
settings::TabSettings,
},
util::{
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},

View File

@@ -226,8 +226,10 @@ pub struct ScrollbarInfo {
}
pub fn get_scrollbar_info(l: &taffy::Layout) -> Option<ScrollbarInfo> {
let overflow_start_threshold_units = 3.0; // don't show scrollbars for nearly non-scrollable lists
let overflow = Vec2::new(l.scroll_width(), l.scroll_height());
if overflow.x == 0.0 && overflow.y == 0.0 {
if overflow.x < overflow_start_threshold_units && overflow.y < overflow_start_threshold_units {
return None; // not overflowing
}
@@ -360,13 +362,11 @@ impl WidgetState {
let transform = state.transform_stack.get();
let thickness = 6.0;
let margin = 4.0;
let margin = 6.0;
let rect_params = drawing::Rectangle {
color: drawing::Color::new(1.0, 1.0, 1.0, 0.0),
border: 2.0,
border_color: drawing::Color::new(1.0, 1.0, 1.0, 1.0),
round_units: 2,
color: drawing::Color::new(1.0, 1.0, 1.0, 0.5),
round_units: 4,
..Default::default()
};
@@ -376,8 +376,8 @@ impl WidgetState {
PrimitiveExtent {
boundary: drawing::Boundary::from_pos_size(
Vec2::new(
transform.abs_pos.x + transform.raw_dim.x * (1.0 - info.handle_size.x) * self.data.scrolling_cur.x,
transform.abs_pos.y + transform.raw_dim.y - thickness - margin,
transform.rel_pos.x + transform.raw_dim.x * (1.0 - info.handle_size.x) * self.data.scrolling_cur.x,
transform.rel_pos.y + transform.raw_dim.y - thickness - margin,
),
Vec2::new(transform.raw_dim.x * info.handle_size.x, thickness),
),
@@ -393,8 +393,8 @@ impl WidgetState {
PrimitiveExtent {
boundary: drawing::Boundary::from_pos_size(
Vec2::new(
transform.abs_pos.x + transform.raw_dim.x - thickness - margin,
transform.abs_pos.y + transform.raw_dim.y * (1.0 - info.handle_size.y) * self.data.scrolling_cur.y,
transform.rel_pos.x + transform.raw_dim.x - thickness - margin,
transform.rel_pos.y + transform.raw_dim.y * (1.0 - info.handle_size.y) * self.data.scrolling_cur.y,
),
Vec2::new(thickness, transform.raw_dim.y * info.handle_size.y),
),