ui: fix min/max width detection

This commit is contained in:
ardocrat 2023-08-01 02:19:09 +03:00
parent b827c717db
commit a57b7e7aec
2 changed files with 5 additions and 8 deletions

View file

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::cmp::min;
use std::sync::RwLock;
use std::sync::atomic::{AtomicBool, Ordering};
@ -194,8 +193,8 @@ impl Modal {
// Setup width of modal content.
let side_insets = View::get_left_inset() + View::get_right_inset();
let available_width = (ui.available_width() - (side_insets + Self::DEFAULT_MARGIN)) as i64;
let width = min(available_width, Self::DEFAULT_WIDTH as i64) as f32;
let available_width = ui.available_width() - (side_insets + Self::DEFAULT_MARGIN);
let width = f32::min(available_width, Self::DEFAULT_WIDTH);
// Show main content Window at given position.
let (content_align, content_offset) = self.modal_position();

View file

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::cmp::{max, min};
use egui::{Align, Align2, Layout, Margin, RichText, Rounding, ScrollArea, TextStyle, Widget};
use egui_extras::{Size, StripBuilder};
@ -244,7 +242,7 @@ impl WalletsContent {
let mut rect = ui.available_rect_before_wrap();
let mut width = ui.available_width();
if !dual_panel {
width = min(width as i64, (Root::SIDE_PANEL_WIDTH * 1.3) as i64) as f32
width = f32::min(width, (Root::SIDE_PANEL_WIDTH * 1.3))
}
if width == 0.0 {
return;
@ -505,8 +503,8 @@ impl WalletsContent {
ui.available_width() - Root::SIDE_PANEL_WIDTH
};
if dual_panel {
let min_width = (Root::SIDE_PANEL_WIDTH + View::get_right_inset()) as i64;
max(min_width, available_width as i64) as f32
let min_width = Root::SIDE_PANEL_WIDTH + View::get_right_inset();
f32::max(min_width, available_width)
} else {
if is_wallet_showing {
ui.available_width()