(&mut self, id: Id, position: Vector2)
| 6965 | } |
| 6966 | |
| 6967 | pub fn set_scroll_position(&mut self, id: Id, position: Vector2) { |
| 6968 | for scd in &mut self.scroll_container_datas { |
| 6969 | if scd.element_id == id.id { |
| 6970 | let max_scroll_x = (scd.content_size.width - scd.bounding_box.width).max(0.0); |
| 6971 | let max_scroll_y = (scd.content_size.height - scd.bounding_box.height).max(0.0); |
| 6972 | |
| 6973 | let clamped_x = position.x.clamp(0.0, max_scroll_x); |
| 6974 | let clamped_y = position.y.clamp(0.0, max_scroll_y); |
| 6975 | scd.scroll_position.x = -clamped_x; |
| 6976 | scd.scroll_position.y = -clamped_y; |
| 6977 | if scd.scrollbar.is_some() { |
| 6978 | scd.scrollbar_idle_frames = 0; |
| 6979 | } |
| 6980 | return; |
| 6981 | } |
| 6982 | } |
| 6983 | |
| 6984 | if let Some(ti_idx) = self.text_input_element_ids.iter().position(|&elem_id| elem_id == id.id) { |
| 6985 | let Some(config) = self.text_input_configs.get(ti_idx).cloned() else { |
| 6986 | return; |
| 6987 | }; |
| 6988 | |
| 6989 | let Some(state_snapshot) = self.text_edit_states.get(&id.id).cloned() else { |
| 6990 | return; |
| 6991 | }; |
| 6992 | |
| 6993 | let (visible_width, visible_height) = self |
| 6994 | .layout_element_map |
| 6995 | .get(&id.id) |
| 6996 | .map(|item| (item.bounding_box.width, item.bounding_box.height)) |
| 6997 | .unwrap_or((0.0, 0.0)); |
| 6998 | |
| 6999 | let (content_width, content_height) = |
| 7000 | self.text_input_content_size(&state_snapshot, &config, visible_width); |
| 7001 | |
| 7002 | let max_scroll_x = (content_width - visible_width).max(0.0); |
| 7003 | let max_scroll_y = (content_height - visible_height).max(0.0); |
| 7004 | |
| 7005 | if let Some(state) = self.text_edit_states.get_mut(&id.id) { |
| 7006 | state.scroll_offset = position.x.clamp(0.0, max_scroll_x); |
| 7007 | state.scroll_offset_y = position.y.clamp(0.0, max_scroll_y); |
| 7008 | } |
| 7009 | |
| 7010 | self.text_input_scrollbar_idle_frames.insert(id.id, 0); |
| 7011 | } |
| 7012 | } |
| 7013 | |
| 7014 | fn render_scrollbar_geometry( |
| 7015 | &mut self, |
nothing calls this directly
no test coverage detected