Rename Sense::nothing()
to Sense::hover()
This commit is contained in:
parent
b65e6327ab
commit
a2ab35bab8
12 changed files with 23 additions and 17 deletions
|
@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
* Combo boxes has scroll bars when needed.
|
||||
* Expand `Window` + `Resize` containers to be large enough for last frames content
|
||||
* `ui.columns`: Columns now defaults to justified top-to-down layouts.
|
||||
* Rename `Sense::nothing()` to `Sense::hover()`.
|
||||
|
||||
### Fixed 🐛
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ impl CtxRef {
|
|||
.map(|id| self.memory().lost_kb_focus(id))
|
||||
.unwrap_or(false);
|
||||
|
||||
if id.is_none() || sense == Sense::nothing() || !layer_id.allow_interaction() {
|
||||
if id.is_none() || sense == Sense::hover() || !layer_id.allow_interaction() {
|
||||
// Not interested or allowed input:
|
||||
return Response {
|
||||
ctx: self.clone(),
|
||||
|
|
|
@ -110,7 +110,7 @@ impl FrameHistory {
|
|||
// TODO: we should not use `slider_width` as default graph width.
|
||||
let height = ui.style().spacing.slider_width;
|
||||
let (id, rect) = ui.allocate_space(vec2(ui.available_size_before_wrap_finite().x, height));
|
||||
let response = ui.interact(rect, id, Sense::nothing());
|
||||
let response = ui.interact(rect, id, Sense::hover());
|
||||
let style = ui.style().noninteractive();
|
||||
|
||||
let mut cmds = vec![PaintCmd::Rect {
|
||||
|
|
|
@ -268,7 +268,7 @@ impl ColorTest {
|
|||
fn vertex_gradient(ui: &mut Ui, bg_fill: Srgba, gradient: &Gradient) -> Response {
|
||||
use crate::paint::*;
|
||||
let (id, rect) = ui.allocate_space(GRADIENT_SIZE);
|
||||
let response = ui.interact(rect, id, Sense::nothing());
|
||||
let response = ui.interact(rect, id, Sense::hover());
|
||||
if bg_fill != Default::default() {
|
||||
let mut triangles = Triangles::default();
|
||||
triangles.add_colored_rect(rect, bg_fill);
|
||||
|
|
|
@ -19,7 +19,7 @@ impl Texture {
|
|||
size *= ui.available_width() / size.x;
|
||||
}
|
||||
let (id, rect) = ui.allocate_space(size);
|
||||
let response = ui.interact(rect, id, Sense::nothing());
|
||||
let response = ui.interact(rect, id, Sense::hover());
|
||||
let mut triangles = Triangles::default();
|
||||
triangles.add_rect_with_uv(rect, [pos2(0.0, 0.0), pos2(1.0, 1.0)].into(), WHITE);
|
||||
ui.painter().add(PaintCmd::triangles(triangles));
|
||||
|
|
|
@ -188,7 +188,7 @@ impl Widgets {
|
|||
pub fn style(&self, response: &Response) -> &WidgetVisuals {
|
||||
if response.active || response.has_kb_focus {
|
||||
&self.active
|
||||
} else if response.sense == Sense::nothing() {
|
||||
} else if response.sense == Sense::hover() {
|
||||
&self.disabled
|
||||
} else if response.hovered {
|
||||
&self.hovered
|
||||
|
|
|
@ -203,14 +203,19 @@ pub struct Sense {
|
|||
}
|
||||
|
||||
impl Sense {
|
||||
/// Senses no clicks or drags (but everything senses mouse hover).
|
||||
pub fn nothing() -> Self {
|
||||
/// Senses no clicks or drags. Only senses mouse hover.
|
||||
pub fn hover() -> Self {
|
||||
Self {
|
||||
click: false,
|
||||
drag: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated = "Use hover()"]
|
||||
pub fn nothing() -> Self {
|
||||
Sense::hover()
|
||||
}
|
||||
|
||||
pub fn click() -> Self {
|
||||
Self {
|
||||
click: true,
|
||||
|
|
|
@ -398,7 +398,7 @@ impl Ui {
|
|||
self.style().spacing.item_spacing,
|
||||
rect,
|
||||
None,
|
||||
Sense::nothing(),
|
||||
Sense::hover(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -787,7 +787,7 @@ impl Ui {
|
|||
let ret = add_contents(&mut child_ui);
|
||||
let size = child_ui.min_size();
|
||||
let (id, rect) = self.allocate_space(size);
|
||||
(ret, self.interact(rect, id, Sense::nothing()))
|
||||
(ret, self.interact(rect, id, Sense::hover()))
|
||||
}
|
||||
|
||||
/// Redirect paint commands to another paint layer.
|
||||
|
@ -851,7 +851,7 @@ impl Ui {
|
|||
);
|
||||
|
||||
let (id, rect) = self.allocate_space(indent + size);
|
||||
(ret, self.interact(rect, id, Sense::nothing()))
|
||||
(ret, self.interact(rect, id, Sense::hover()))
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
|
|
|
@ -44,7 +44,7 @@ pub fn show_color(ui: &mut Ui, color: impl Into<Srgba>, desired_size: Vec2) -> R
|
|||
|
||||
fn show_srgba(ui: &mut Ui, srgba: Srgba, desired_size: Vec2) -> Response {
|
||||
let (id, rect) = ui.allocate_space(desired_size);
|
||||
let response = ui.interact(rect, id, Sense::nothing());
|
||||
let response = ui.interact(rect, id, Sense::hover());
|
||||
background_checkers(ui.painter(), rect);
|
||||
ui.painter().add(PaintCmd::Rect {
|
||||
rect,
|
||||
|
|
|
@ -74,6 +74,6 @@ impl Widget for Image {
|
|||
fn ui(self, ui: &mut Ui) -> Response {
|
||||
let (id, rect) = ui.allocate_space(self.desired_size);
|
||||
self.paint_at(ui, rect);
|
||||
ui.interact(rect, id, Sense::nothing())
|
||||
ui.interact(rect, id, Sense::hover())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ impl Widget for Label {
|
|||
} else {
|
||||
let galley = self.layout(ui);
|
||||
let (id, rect) = ui.allocate_space(galley.size);
|
||||
let response = ui.interact(rect, id, Sense::nothing());
|
||||
let response = ui.interact(rect, id, Sense::hover());
|
||||
let rect = ui.layout().align_size_within_rect(galley.size, rect);
|
||||
self.paint_galley(ui, rect.min, galley);
|
||||
response
|
||||
|
@ -365,10 +365,10 @@ impl Button {
|
|||
}
|
||||
|
||||
/// If you set this to `false`, the button will be grayed out and un-clickable.
|
||||
/// `enabled(false)` has the same effect as calling `sense(Sense::nothing())`.
|
||||
/// `enabled(false)` has the same effect as calling `sense(Sense::hover())`.
|
||||
pub fn enabled(mut self, enabled: bool) -> Self {
|
||||
if !enabled {
|
||||
self.sense = Sense::nothing();
|
||||
self.sense = Sense::hover();
|
||||
}
|
||||
self
|
||||
}
|
||||
|
@ -737,6 +737,6 @@ impl Widget for Separator {
|
|||
};
|
||||
let stroke = ui.style().visuals.widgets.noninteractive.bg_stroke;
|
||||
ui.painter().line_segment(points, stroke);
|
||||
ui.interact(rect, id, Sense::nothing())
|
||||
ui.interact(rect, id, Sense::hover())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
let sense = if enabled {
|
||||
Sense::click_and_drag()
|
||||
} else {
|
||||
Sense::nothing()
|
||||
Sense::hover()
|
||||
};
|
||||
let response = ui.interact(rect, id, sense);
|
||||
|
||||
|
|
Loading…
Reference in a new issue