forge
Explore
Log in

Don't you dare go Hollow

Sliders as a thin line with a paper dot (one part, every slider)

Browse files at this commit

e65f020fd5bb884f8032ea0582f30d4936922614Ahmet Kaan GümüşParent: 654d396
  • feat
    • sliders as a thin line with a paper dot (one part, every slider)
    • 'Esc to leave fullscreen' over the picture
Show full message
✨ feat: sliders as a thin line with a paper dot (one part, every slider); 'Esc to leave fullscreen' over the picture
crates/client/src/gui/media_view.rsmodified+8 -2
@@ -17,7 +17,7 @@ use gpui_kit::{
17 component::{17 component::{
18 Icon, WindowExt,18 Icon, WindowExt,
19 notification::Notification,19 notification::Notification,
20- slider::{Slider, SliderEvent, SliderState},20+ slider::{SliderEvent, SliderState},
21 },21 },
22 div, img,22 div, img,
23 prelude::FluentBuilder as _,23 prelude::FluentBuilder as _,
@@ -731,7 +731,13 @@ fn player_view(
731 Some(PlayState::Ready { seek, .. }) if !voice => Some(seek),731 Some(PlayState::Ready { seek, .. }) if !voice => Some(seek),
732 _ => None,732 _ => None,
733 },733 },
734- |this, seek| this.child(div().w(px(size::THUMB)).child(Slider::new(seek))),734+ |this, seek| {
735+ this.child(
736+ div()
737+ .w(px(size::THUMB))
738+ .child(super::parts::slider(seek, palette.tokens)),
739+ )
740+ },
735 );741 );
736 742
737 let video = match state {743 let video = match state {
crates/client/src/gui/parts.rsmodified+64 -0
@@ -424,3 +424,67 @@ pub fn spark(values: Vec<f32>, slots: usize, color: Hsla) -> AnyElement {
424 pub fn motion() -> gpui_kit::Animation {424 pub fn motion() -> gpui_kit::Animation {
425 gpui_kit::Animation::new(Duration::from_millis(160)).with_easing(gpui_kit::ease_out_quint())425 gpui_kit::Animation::new(Duration::from_millis(160)).with_easing(gpui_kit::ease_out_quint())
426 }426 }
427+
428+const SLIDER_DOT: f32 = 10.;
429+
430+#[derive(gpui_kit::IntoElement)]
431+pub struct Slider {
432+ state: gpui_kit::Entity<gpui_kit::component::slider::SliderState>,
433+ t: Tokens,
434+}
435+
436+pub fn slider(
437+ state: &gpui_kit::Entity<gpui_kit::component::slider::SliderState>,
438+ t: Tokens,
439+) -> Slider {
440+ Slider {
441+ state: state.clone(),
442+ t,
443+ }
444+}
445+
446+impl gpui_kit::RenderOnce for Slider {
447+ fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
448+ use gpui_kit::base::{Slider as Base, SliderIndicator, SliderThumb, SliderTrack};
449+ let at = self.state.read(cx).percentage().end;
450+ let t = self.t;
451+ Base::new(&self.state)
452+ .flex()
453+ .flex_1()
454+ .items_center()
455+ .w_full()
456+ .child(
457+ SliderTrack::new(&self.state)
458+ .flex()
459+ .items_center()
460+ .w_full()
461+ .h(px(size::CONTROL_SM))
462+ .cursor_pointer()
463+ .child(
464+ SliderIndicator::new(&self.state)
465+ .relative()
466+ .w_full()
467+ .h(px(stroke::LINE))
468+ .bg(t.thread())
469+ .child(
470+ div()
471+ .absolute()
472+ .left_0()
473+ .h_full()
474+ .w(gpui_kit::relative(at))
475+ .bg(t.paper()),
476+ )
477+ .child(
478+ SliderThumb::new(&self.state)
479+ .absolute()
480+ .top(px((stroke::LINE - SLIDER_DOT) / 2.))
481+ .left(gpui_kit::relative(at))
482+ .ml(px(-SLIDER_DOT / 2.))
483+ .size(px(SLIDER_DOT))
484+ .rounded(px(radius::FULL))
485+ .bg(t.paper()),
486+ ),
487+ ),
488+ )
489+ }
490+}
crates/client/src/gui/profile.rsmodified+2 -2
@@ -16,7 +16,7 @@ use gpui_kit::{
16 Icon, WindowExt,16 Icon, WindowExt,
17 input::InputState,17 input::InputState,
18 popover::{Popover, PopoverState},18 popover::{Popover, PopoverState},
19- slider::{Slider, SliderState},19+ slider::SliderState,
20 },20 },
21 div, px,21 div, px,
22 };22 };
@@ -311,7 +311,7 @@ impl Card {
311 .children(self.volume.map(|(slider, volume)| {311 .children(self.volume.map(|(slider, volume)| {
312 band(space::MD)312 band(space::MD)
313 .child(words("Volume", Text::Label, Ink::Paper, t).flex_none())313 .child(words("Volume", Text::Label, Ink::Paper, t).flex_none())
314- .child(Slider::new(&slider).flex_1())314+ .child(super::parts::slider(&slider, t))
315 .child(315 .child(
316 words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t)316 words(format!("{volume:.0}%"), Text::Caption, Ink::Dim, t)
317 .w(px(size::CONTROL))317 .w(px(size::CONTROL))
crates/client/src/gui/share_view.rsmodified+20 -3
@@ -22,7 +22,7 @@ use gpui_kit::{
22 component::{22 component::{
23 Icon,23 Icon,
24 popover::Popover,24 popover::Popover,
25- slider::{Slider, SliderEvent, SliderState},25+ slider::{SliderEvent, SliderState},
26 },26 },
27 div,27 div,
28 prelude::FluentBuilder as _,28 prelude::FluentBuilder as _,
@@ -556,7 +556,22 @@ impl Yumush {
556 .flex_col()556 .flex_col()
557 .bg(palette.window)557 .bg(palette.window)
558 .child(self.viewer_pane(viewer, entity, palette))558 .child(self.viewer_pane(viewer, entity, palette))
559- .child(self.voice_band(palette)),559+ .child(self.voice_band(palette))
560+ .child(
561+ div()
562+ .absolute()
563+ .top(px(space::LG))
564+ .left_0()
565+ .right_0()
566+ .flex()
567+ .justify_center()
568+ .child(scrim(palette.tokens).child(parts::words(
569+ "Esc to leave fullscreen",
570+ parts::Text::Label,
571+ parts::Ink::Dim,
572+ palette.tokens,
573+ ))),
574+ ),
560 )575 )
561 }576 }
562 577
@@ -676,7 +691,9 @@ impl Yumush {
676 )691 )
677 }))692 }))
678 .children(audio.then(|| {693 .children(audio.then(|| {
679- div().w(px(VOLUME_WIDTH)).child(Slider::new(&viewer.volume))694+ div()
695+ .w(px(VOLUME_WIDTH))
696+ .child(parts::slider(&viewer.volume, t))
680 }))697 }))
681 .child(icon_button(698 .child(icon_button(
682 format!("share_fullscreen_{}", viewer.fullscreen),699 format!("share_fullscreen_{}", viewer.fullscreen),
crates/client/src/gui/voice_settings.rsmodified+10 -3
@@ -10,7 +10,7 @@ use gpui_kit::{
10 kbd::Kbd,10 kbd::Kbd,
11 searchable_list::{SearchableListItem, SearchableVec},11 searchable_list::{SearchableListItem, SearchableVec},
12 select::{Select, SelectEvent, SelectState},12 select::{Select, SelectEvent, SelectState},
13- slider::{Slider, SliderEvent, SliderState},13+ slider::{SliderEvent, SliderState},
14 },14 },
15 div, px, relative,15 div, px, relative,
16 };16 };
@@ -177,7 +177,11 @@ fn volume_control(state: &Entity<SliderState>, value: f32, palette: Palette) ->
177 .flex()177 .flex()
178 .items_center()178 .items_center()
179 .gap(px(space::SM))179 .gap(px(space::SM))
180- .child(Slider::new(state).w(px(size::THUMB)))180+ .child(
181+ div()
182+ .w(px(size::THUMB))
183+ .child(super::parts::slider(state, palette.tokens)),
184+ )
181 .child(185 .child(
182 div()186 div()
183 .w(px(size::ROW))187 .w(px(size::ROW))
@@ -316,7 +320,10 @@ impl Yumush {
316 .flex()320 .flex()
317 .flex_col()321 .flex_col()
318 .gap(px(space::SM))322 .gap(px(space::SM))
319- .child(Slider::new(&self.voice.sensitivity))323+ .child(super::parts::slider(
324+ &self.voice.sensitivity,
325+ palette.tokens,
326+ ))
320 .child(level_bar(327 .child(level_bar(
321 level,328 level,
322 self.settings.voice.sensitivity_db,329 self.settings.voice.sensitivity_db,