mirror of
https://github.com/danbulant/cushy
synced 2026-06-10 18:13:48 +00:00
WidgetRef::unmount_in
This should be all the locations that WidgetRef::unmount_in should be called.
This commit is contained in:
parent
9e4e079bf5
commit
32d6fffd3b
6 changed files with 32 additions and 18 deletions
|
|
@ -541,6 +541,10 @@ impl Widget for Button {
|
|||
fn deactivate(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
self.update_colors(context, false);
|
||||
}
|
||||
|
||||
fn unmounted(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
self.content.unmount_in(context);
|
||||
}
|
||||
}
|
||||
|
||||
define_components! {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,10 @@ impl Widget for Container {
|
|||
.finish()
|
||||
}
|
||||
|
||||
fn unmounted(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
self.child.unmount_in(context);
|
||||
}
|
||||
|
||||
fn full_control_redraw(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -527,6 +527,8 @@ impl WrapperWidget for Custom {
|
|||
fn unmounted(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
if let Some(unmounted) = &mut self.unmounted {
|
||||
unmounted.invoke(context);
|
||||
} else {
|
||||
self.child_mut().unmount_in(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use kludgine::{Color, DrawableExt};
|
|||
|
||||
use super::button::{ButtonActiveBackground, ButtonBackground, ButtonHoverBackground};
|
||||
use crate::animation::{AnimationHandle, AnimationTarget, Spawn};
|
||||
use crate::context::LayoutContext;
|
||||
use crate::context::{EventContext, LayoutContext};
|
||||
use crate::styles::components::{HighlightColor, IntrinsicPadding, LineHeight, OutlineColor};
|
||||
use crate::styles::Dimension;
|
||||
use crate::value::{Dynamic, IntoDynamic, IntoValue, Value};
|
||||
|
|
@ -161,6 +161,13 @@ impl DiscloseIndicator {
|
|||
}
|
||||
|
||||
impl Widget for DiscloseIndicator {
|
||||
fn unmounted(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
if let Some(label) = &mut self.label {
|
||||
label.unmount_in(context);
|
||||
}
|
||||
self.contents.unmount_in(context);
|
||||
}
|
||||
|
||||
fn redraw(&mut self, context: &mut crate::context::GraphicsContext<'_, '_, '_, '_, '_>) {
|
||||
let angle = self.angle.get_tracking_redraw(context);
|
||||
let (color, stroke_color) = self.effective_colors(context);
|
||||
|
|
@ -263,23 +270,19 @@ impl Widget for DiscloseIndicator {
|
|||
)
|
||||
}
|
||||
|
||||
fn accept_focus(&mut self, _context: &mut crate::context::EventContext<'_, '_>) -> bool {
|
||||
fn accept_focus(&mut self, _context: &mut EventContext<'_, '_>) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn focus(&mut self, context: &mut crate::context::EventContext<'_, '_>) {
|
||||
fn focus(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
context.set_needs_redraw();
|
||||
}
|
||||
|
||||
fn blur(&mut self, context: &mut crate::context::EventContext<'_, '_>) {
|
||||
fn blur(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
context.set_needs_redraw();
|
||||
}
|
||||
|
||||
fn hit_test(
|
||||
&mut self,
|
||||
location: Point<Px>,
|
||||
context: &mut crate::context::EventContext<'_, '_>,
|
||||
) -> bool {
|
||||
fn hit_test(&mut self, location: Point<Px>, context: &mut EventContext<'_, '_>) -> bool {
|
||||
let size = context
|
||||
.get(&IndicatorSize)
|
||||
.into_px(context.kludgine.scale())
|
||||
|
|
@ -296,7 +299,7 @@ impl Widget for DiscloseIndicator {
|
|||
fn hover(
|
||||
&mut self,
|
||||
location: Point<Px>,
|
||||
context: &mut crate::context::EventContext<'_, '_>,
|
||||
context: &mut EventContext<'_, '_>,
|
||||
) -> Option<CursorIcon> {
|
||||
let hovering = self.hit_test(location, context);
|
||||
if self.hovering_indicator != hovering {
|
||||
|
|
@ -307,7 +310,7 @@ impl Widget for DiscloseIndicator {
|
|||
hovering.then_some(CursorIcon::Pointer)
|
||||
}
|
||||
|
||||
fn unhover(&mut self, context: &mut crate::context::EventContext<'_, '_>) {
|
||||
fn unhover(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
if self.hovering_indicator {
|
||||
self.hovering_indicator = false;
|
||||
context.set_needs_redraw();
|
||||
|
|
@ -319,7 +322,7 @@ impl Widget for DiscloseIndicator {
|
|||
location: Point<Px>,
|
||||
_device_id: kludgine::app::winit::event::DeviceId,
|
||||
_button: kludgine::app::winit::event::MouseButton,
|
||||
context: &mut crate::context::EventContext<'_, '_>,
|
||||
context: &mut EventContext<'_, '_>,
|
||||
) -> EventHandling {
|
||||
if self.hit_test(location, context) {
|
||||
self.mouse_buttons_pressed += 1;
|
||||
|
|
@ -336,7 +339,7 @@ impl Widget for DiscloseIndicator {
|
|||
_location: Option<Point<Px>>,
|
||||
_device_id: kludgine::app::winit::event::DeviceId,
|
||||
_button: kludgine::app::winit::event::MouseButton,
|
||||
context: &mut crate::context::EventContext<'_, '_>,
|
||||
context: &mut EventContext<'_, '_>,
|
||||
) {
|
||||
self.mouse_buttons_pressed -= 1;
|
||||
if self.mouse_buttons_pressed == 0 {
|
||||
|
|
@ -345,7 +348,7 @@ impl Widget for DiscloseIndicator {
|
|||
}
|
||||
}
|
||||
|
||||
fn activate(&mut self, _context: &mut crate::context::EventContext<'_, '_>) {
|
||||
fn activate(&mut self, _context: &mut EventContext<'_, '_>) {
|
||||
if self.mouse_buttons_pressed == 0 {
|
||||
self.collapsed.toggle();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ impl Label {
|
|||
if prepared.can_render_to(&context.gfx)
|
||||
&& *prepared_generation == check_generation
|
||||
&& *prepared_color == color
|
||||
&& (*prepared_width == width
|
||||
|| (*prepared_width < width
|
||||
|| (prepared.size.width <= width
|
||||
&& prepared.line_height == prepared.size.height))) => {}
|
||||
&& *prepared_width == width => {}
|
||||
_ => {
|
||||
context.apply_current_font_settings();
|
||||
let measured = self.text.map(|text| {
|
||||
|
|
|
|||
|
|
@ -144,6 +144,10 @@ impl Scroll {
|
|||
}
|
||||
|
||||
impl Widget for Scroll {
|
||||
fn unmounted(&mut self, context: &mut EventContext<'_, '_>) {
|
||||
self.contents.unmount_in(context);
|
||||
}
|
||||
|
||||
fn hit_test(&mut self, _location: Point<Px>, _context: &mut EventContext<'_, '_>) -> bool {
|
||||
true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue