MCPcopy Create free account
hub / github.com/emilk/egui_plot / calculate_widget_complete_rect

Method calculate_widget_complete_rect

egui_plot/src/plot.rs:814–853  ·  view source on GitHub ↗

Calculate the rect inside which everything will be drawn.

(&self, ui: &Ui)

Source from the content-addressed store, hash-verified

812
813 /// Calculate the rect inside which everything will be drawn.
814 fn calculate_widget_complete_rect(&self, ui: &Ui) -> Rect {
815 // Determine position of widget.
816 let pos = ui.available_rect_before_wrap().min;
817 // Minimum values for screen protection
818 let mut min_size = self.min_size;
819 min_size.x = min_size.x.at_least(1.0);
820 min_size.y = min_size.y.at_least(1.0);
821
822 // Determine size of widget.
823 let size = {
824 let width = self
825 .width
826 .unwrap_or_else(|| {
827 if let (Some(height), Some(aspect)) = (self.height, self.view_aspect) {
828 height * aspect
829 } else {
830 ui.available_size_before_wrap().x
831 }
832 })
833 .at_least(min_size.x);
834
835 let height = self
836 .height
837 .unwrap_or_else(|| {
838 if let Some(aspect) = self.view_aspect {
839 width / aspect
840 } else {
841 ui.available_size_before_wrap().y
842 }
843 })
844 .at_least(min_size.y);
845 vec2(width, height)
846 };
847
848 // Determine complete rect of widget.
849 Rect {
850 min: pos,
851 max: pos + size,
852 }
853 }
854
855 fn allocate_axis_responses(&self, ui: &mut Ui, axis_widgets: &AxisWidgets<'_>) -> AxisResponses {
856 let x_axis_responses = axis_widgets[0]

Callers 1

show_dynMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected