Skip to content

Commit 7eccf66

Browse files
committed
[Rust - agx] Work on scrollbar presentation
1 parent 79e02b9 commit 7eccf66

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

rust_programs/libgui/src/bordered.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ fn draw_inner_margin(
3939
) {
4040
onto.fill_rect(
4141
frame_of_inner_margin,
42-
//Color::dark_gray(),
43-
Color::yellow(),
42+
Color::dark_gray(),
4443
StrokeThickness::Width(inner_border_insets.bottom),
4544
);
4645

4746
// TODO(PT): Hack that assumes the insets are even along all edges
4847
let inner_margin_size = inner_border_insets.bottom;
4948

5049
// Draw diagonal lines indicating an inset
51-
//let inset_color = Color::new(50, 50, 50);
52-
let inset_color = Color::blue();
50+
let inset_color = Color::new(50, 50, 50);
5351
let inner_margin_as_point = Point::new(inner_margin_size, inner_margin_size);
5452

5553
// Account for our line thickness algo
@@ -211,6 +209,6 @@ pub trait Bordered: Drawable + UIElement {
211209
true,
212210
self.currently_contains_mouse(),
213211
)
214-
.1
212+
.1
215213
}
216214
}

rust_programs/libgui/src/scroll_view.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ impl LikeLayerSlice for ExpandingLayerSlice {
8282

8383
slice.expand_to_contain_rect(Rect::from(bounding_box));
8484

85-
/*
86-
slice.fill_rect(
87-
Rect::from(bounding_box),
88-
Color::red(),
89-
StrokeThickness::Filled,
90-
);
91-
*/
92-
9385
match fill_mode {
9486
FillMode::Filled => {
9587
for line in
@@ -699,7 +691,7 @@ impl ScrollView {
699691
}
700692

701693
fn scroll_bar_width() -> isize {
702-
50
694+
42
703695
}
704696
}
705697

@@ -717,7 +709,6 @@ impl Bordered for ScrollView {
717709
}
718710

719711
fn draw_border_with_insets(&self, onto: &mut Box<dyn LikeLayerSlice>) -> Rect {
720-
//let rect = Bordered::draw_border_with_insets(self, onto, insets);
721712
let (frame_of_inner_margin, frame_of_content) = draw_border_with_insets(
722713
onto,
723714
self.outer_border_insets(),
@@ -759,7 +750,6 @@ impl Bordered for ScrollView {
759750
RectInsets::new(5, 5, 5, 5),
760751
RectInsets::new(5, 5, 5, 5),
761752
scroll_bar_content_frame.size,
762-
//self.currently_contains_mouse(),
763753
false,
764754
false,
765755
);
@@ -779,10 +769,17 @@ impl Bordered for ScrollView {
779769
);
780770
scroll_bar_onto.fill_rect(
781771
Rect::from_parts(scrollbar_attrs.origin, scrollbar_attrs.size),
782-
Color::green(),
772+
Color::new(180, 180, 180),
783773
StrokeThickness::Filled,
784774
);
785775

776+
// Mouse interaction highlight on top of the scroll bar
777+
scroll_bar_onto.fill_rect(
778+
Rect::from_parts(scrollbar_attrs.origin, scrollbar_attrs.size),
779+
Color::new(160, 160, 160),
780+
StrokeThickness::Width(1),
781+
);
782+
786783
// PT: Horrible hack to make the highlight border show perfectly on top of the scroll bar
787784
draw_outer_mouse_highlight(onto, self.frame().size, self.currently_contains_mouse());
788785

@@ -939,10 +936,10 @@ fn compute_scrollbar_attributes(
939936
scroll_position: Point,
940937
) -> ScrollbarAttributes {
941938
// TODO(PT): Handle when the scroll offset is 'negative' i.e. when there's a bunch of content above the origin?
942-
let scrollbar_vertical_padding = 14;
939+
let scrollbar_vertical_padding = 12;
943940
let scrollbar_canvas_height = (viewport_size.height - (scrollbar_vertical_padding * 2)) as f64;
944-
let min_scrollbar_height = (scrollbar_canvas_height * 0.1) as isize;
945-
let max_scrollbar_height = (scrollbar_canvas_height * 0.4) as isize;
941+
let min_scrollbar_height = (scrollbar_canvas_height * 0.08) as isize;
942+
let max_scrollbar_height = (scrollbar_canvas_height * 0.35) as isize;
946943

947944
// If the viewport is larger than the current content size, cap out at 100%
948945
let nominal_scrollbar_height = if viewport_size.height >= content_size.height {

0 commit comments

Comments
 (0)