Skip to content

Commit 79e02b9

Browse files
committed
[Rust - agx] Drop prototyping scroll bar code
1 parent dbcffc7 commit 79e02b9

File tree

1 file changed

+1
-68
lines changed

1 file changed

+1
-68
lines changed

rust_programs/libgui/src/scroll_view.rs

+1-68
Original file line numberDiff line numberDiff line change
@@ -771,74 +771,6 @@ impl Bordered for ScrollView {
771771
StrokeThickness::Filled,
772772
);
773773

774-
// Draw the scroll bar indicator
775-
let scroll_offset_y = self.layer.scroll_offset().y;
776-
let total_scrollable_height = match self.layer.total_content_frame().size.height {
777-
0 => {
778-
// Provide a 'fake' scrollable height
779-
scroll_offset_y.abs()
780-
}
781-
height => height,
782-
};
783-
784-
// TODO(PT): Handle when the scroll offset is 'negative' i.e. when there's a bunch of content above the origin?
785-
786-
let top_of_visible_content = scroll_offset_y.abs();
787-
let bottom_of_visible_content =
788-
top_of_visible_content + self.layer.visible_frame.borrow().size.height;
789-
let percent_scrolled_through_content = {
790-
if total_scrollable_height == 0 {
791-
0.0
792-
} else {
793-
top_of_visible_content as f64 / total_scrollable_height as f64
794-
}
795-
};
796-
797-
/*
798-
println!(
799-
"total scrollable height {total_scrollable_height} scroll_offset_y {scroll_offset_y} percent {percent_scrolled_through_content}"
800-
);
801-
802-
*/
803-
assert!(
804-
percent_scrolled_through_content >= 0.0 && percent_scrolled_through_content <= 1.0,
805-
"Percent was {percent_scrolled_through_content}"
806-
);
807-
808-
let scroll_box_min_y = frame_of_scrollbar_content.min_y();
809-
let scroll_box_max_y = frame_of_scrollbar_content.max_y();
810-
let center_y_for_scroll_bar_within_scroll_box = scroll_box_min_y
811-
+ ((frame_of_scrollbar_content.height() as f64 * percent_scrolled_through_content)
812-
as isize);
813-
/*
814-
println!(
815-
"total scrollable height {total_scrollable_height} scroll_offset_y {scroll_offset_y} scroll_box_min_y {scroll_box_min_y} {percent_scrolled_through_content} center_y {center_y_for_scroll_bar_within_scroll_box}"
816-
);
817-
818-
*/
819-
// TODO(PT): The height of the scroll bar should be proportional to the content height
820-
let scroll_indicator_size = Size::new(
821-
(frame_of_scrollbar_content.width() as f64 * 0.6) as isize,
822-
200,
823-
);
824-
let mut y_origin_for_scroll_indicator = center_y_for_scroll_bar_within_scroll_box
825-
- ((scroll_indicator_size.height as f64 / 2.0) as isize);
826-
// Ensure the scroll indicator doesn't underflow the scroll box
827-
y_origin_for_scroll_indicator = max(y_origin_for_scroll_indicator, scroll_box_min_y);
828-
829-
/*
830-
scroll_bar_onto.fill_rect(
831-
Rect::from_parts(
832-
Point::new(
833-
frame_of_scrollbar_content.min_x(),
834-
y_origin_for_scroll_indicator,
835-
),
836-
scroll_indicator_size,
837-
),
838-
Color::green(),
839-
StrokeThickness::Filled,
840-
);
841-
*/
842774
let scrollbar_attrs = compute_scrollbar_attributes(
843775
scroll_bar_onto.frame().size,
844776
self.layer.frame().size,
@@ -1006,6 +938,7 @@ fn compute_scrollbar_attributes(
1006938
content_size: Size,
1007939
scroll_position: Point,
1008940
) -> ScrollbarAttributes {
941+
// TODO(PT): Handle when the scroll offset is 'negative' i.e. when there's a bunch of content above the origin?
1009942
let scrollbar_vertical_padding = 14;
1010943
let scrollbar_canvas_height = (viewport_size.height - (scrollbar_vertical_padding * 2)) as f64;
1011944
let min_scrollbar_height = (scrollbar_canvas_height * 0.1) as isize;

0 commit comments

Comments
 (0)