1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

Code cleanup: allow None mouse_pos + clippy fixes

This commit is contained in:
Emil Ernerfeldt
2019-02-10 15:30:48 +01:00
parent 1beed16053
commit f0c879b2f4
9 changed files with 81 additions and 67 deletions

View File

@@ -1,3 +1,5 @@
#![allow(clippy::new_without_default_derive)]
use crate::{
fonts::TextStyle,
layout::{make_id, Align, Direction, GuiResponse, Id, Region},
@@ -289,14 +291,16 @@ impl<'a> Widget for Slider<'a> {
id,
);
if interact.active {
*value = remap_clamp(
region.input().mouse_pos.x,
interact.rect.min().x,
interact.rect.max().x,
min,
max,
);
if let Some(mouse_pos) = region.input().mouse_pos {
if interact.active {
*value = remap_clamp(
mouse_pos.x,
interact.rect.min().x,
interact.rect.max().x,
min,
max,
);
}
}
region.add_graphic(GuiCmd::Slider {