dash-frontend: Scrollable audio device list (Closes #353), wgui: fix scrollbar rendering
This commit is contained in:
@@ -46,7 +46,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<elements>
|
<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>
|
</div>
|
||||||
|
|
||||||
@@ -64,5 +65,6 @@
|
|||||||
<BottomButton id="btn_sources" src_builtin="dashboard/microphone.svg" translation="AUDIO.MICROPHONES" />
|
<BottomButton id="btn_sources" src_builtin="dashboard/microphone.svg" translation="AUDIO.MICROPHONES" />
|
||||||
<BottomButton id="btn_cards" src_builtin="dashboard/cpu.svg" translation="AUDIO.CARDS" />
|
<BottomButton id="btn_cards" src_builtin="dashboard/cpu.svg" translation="AUDIO.CARDS" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</elements>
|
</elements>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -19,8 +19,8 @@ use wlx_common::{audio, dash_interface::BoxDashInterface, timestep::Timestep};
|
|||||||
use crate::{
|
use crate::{
|
||||||
assets,
|
assets,
|
||||||
tab::{
|
tab::{
|
||||||
apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses, settings::TabSettings,
|
Tab, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses,
|
||||||
Tab, TabType,
|
settings::TabSettings,
|
||||||
},
|
},
|
||||||
util::{
|
util::{
|
||||||
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},
|
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},
|
||||||
|
|||||||
@@ -226,8 +226,10 @@ pub struct ScrollbarInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_scrollbar_info(l: &taffy::Layout) -> Option<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());
|
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
|
return None; // not overflowing
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,13 +362,11 @@ impl WidgetState {
|
|||||||
let transform = state.transform_stack.get();
|
let transform = state.transform_stack.get();
|
||||||
|
|
||||||
let thickness = 6.0;
|
let thickness = 6.0;
|
||||||
let margin = 4.0;
|
let margin = 6.0;
|
||||||
|
|
||||||
let rect_params = drawing::Rectangle {
|
let rect_params = drawing::Rectangle {
|
||||||
color: drawing::Color::new(1.0, 1.0, 1.0, 0.0),
|
color: drawing::Color::new(1.0, 1.0, 1.0, 0.5),
|
||||||
border: 2.0,
|
round_units: 4,
|
||||||
border_color: drawing::Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
round_units: 2,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -376,8 +376,8 @@ impl WidgetState {
|
|||||||
PrimitiveExtent {
|
PrimitiveExtent {
|
||||||
boundary: drawing::Boundary::from_pos_size(
|
boundary: drawing::Boundary::from_pos_size(
|
||||||
Vec2::new(
|
Vec2::new(
|
||||||
transform.abs_pos.x + transform.raw_dim.x * (1.0 - info.handle_size.x) * self.data.scrolling_cur.x,
|
transform.rel_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.y + transform.raw_dim.y - thickness - margin,
|
||||||
),
|
),
|
||||||
Vec2::new(transform.raw_dim.x * info.handle_size.x, thickness),
|
Vec2::new(transform.raw_dim.x * info.handle_size.x, thickness),
|
||||||
),
|
),
|
||||||
@@ -393,8 +393,8 @@ impl WidgetState {
|
|||||||
PrimitiveExtent {
|
PrimitiveExtent {
|
||||||
boundary: drawing::Boundary::from_pos_size(
|
boundary: drawing::Boundary::from_pos_size(
|
||||||
Vec2::new(
|
Vec2::new(
|
||||||
transform.abs_pos.x + transform.raw_dim.x - thickness - margin,
|
transform.rel_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.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),
|
Vec2::new(thickness, transform.raw_dim.y * info.handle_size.y),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user