Split Shell::request_redraw into two different methods
This commit is contained in:
parent
7fbc195b11
commit
752403d70c
15 changed files with 89 additions and 114 deletions
|
|
@ -366,13 +366,8 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.status = Some(current_status);
|
||||
} else {
|
||||
match self.status {
|
||||
Some(status) if status != current_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self.status.is_some_and(|status| status != current_status) {
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
update_status
|
||||
|
|
|
|||
|
|
@ -345,13 +345,11 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.last_status = Some(current_status);
|
||||
} else {
|
||||
match self.last_status {
|
||||
Some(status) if status != current_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self
|
||||
.last_status
|
||||
.is_some_and(|status| status != current_status)
|
||||
{
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event::Status::Ignored
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use crate::core::overlay;
|
|||
use crate::core::renderer;
|
||||
use crate::core::widget;
|
||||
use crate::core::widget::tree::{self, Tree};
|
||||
use crate::core::window;
|
||||
use crate::core::{
|
||||
self, Clipboard, Element, Length, Point, Rectangle, Shell, Size, Vector,
|
||||
Widget,
|
||||
|
|
@ -342,7 +343,14 @@ where
|
|||
local_shell.revalidate_layout(|| shell.invalidate_layout());
|
||||
|
||||
if let Some(redraw_request) = local_shell.redraw_request() {
|
||||
shell.request_redraw(redraw_request);
|
||||
match redraw_request {
|
||||
window::RedrawRequest::NextFrame => {
|
||||
shell.request_redraw();
|
||||
}
|
||||
window::RedrawRequest::At(at) => {
|
||||
shell.request_redraw_at(at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !local_messages.is_empty() {
|
||||
|
|
@ -620,7 +628,14 @@ where
|
|||
local_shell.revalidate_layout(|| shell.invalidate_layout());
|
||||
|
||||
if let Some(redraw_request) = local_shell.redraw_request() {
|
||||
shell.request_redraw(redraw_request);
|
||||
match redraw_request {
|
||||
window::RedrawRequest::NextFrame => {
|
||||
shell.request_redraw();
|
||||
}
|
||||
window::RedrawRequest::At(at) => {
|
||||
shell.request_redraw_at(at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !local_messages.is_empty() {
|
||||
|
|
|
|||
|
|
@ -435,9 +435,7 @@ where
|
|||
.publish(on_option_hovered(option.clone()));
|
||||
}
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -472,14 +470,12 @@ where
|
|||
|
||||
let state = tree.state.downcast_mut::<ListState>();
|
||||
|
||||
if state.is_hovered.is_some_and(|is_hovered| {
|
||||
is_hovered != cursor.is_over(layout.bounds())
|
||||
}) {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
state.is_hovered = Some(cursor.is_over(layout.bounds()));
|
||||
} else if state.is_hovered.is_some_and(|is_hovered| {
|
||||
is_hovered != cursor.is_over(layout.bounds())
|
||||
}) {
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event::Status::Ignored
|
||||
|
|
|
|||
|
|
@ -535,13 +535,11 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.last_status = Some(status);
|
||||
} else {
|
||||
match self.last_status {
|
||||
Some(last_status) if last_status != status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self
|
||||
.last_status
|
||||
.is_some_and(|last_status| last_status != status)
|
||||
{
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event_status
|
||||
|
|
|
|||
|
|
@ -360,13 +360,11 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.last_status = Some(current_status);
|
||||
} else {
|
||||
match self.last_status {
|
||||
Some(status) if status != current_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self
|
||||
.last_status
|
||||
.is_some_and(|last_status| last_status != current_status)
|
||||
{
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event::Status::Ignored
|
||||
|
|
|
|||
|
|
@ -931,7 +931,7 @@ where
|
|||
.last_status
|
||||
.is_some_and(|last_status| last_status != status)
|
||||
{
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event_status
|
||||
|
|
|
|||
|
|
@ -432,13 +432,8 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.status = Some(current_status);
|
||||
} else {
|
||||
match self.status {
|
||||
Some(status) if status != current_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self.status.is_some_and(|status| status != current_status) {
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
update_status
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ where
|
|||
focus.is_window_focused = true;
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
shell.request_redraw();
|
||||
}
|
||||
}
|
||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
|
|
@ -637,11 +637,11 @@ where
|
|||
- (now - focus.updated_at).as_millis()
|
||||
% Focus::CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
|
||||
shell.request_redraw(window::RedrawRequest::At(
|
||||
shell.request_redraw_at(
|
||||
now + Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ where
|
|||
state.last_click = Some(click);
|
||||
|
||||
if cursor_before != state.cursor {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -806,7 +806,7 @@ where
|
|||
}
|
||||
|
||||
if selection_before != state.cursor.selection(&value) {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -914,9 +914,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1037,9 +1035,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1059,9 +1055,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1083,9 +1077,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1107,9 +1099,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1136,9 +1126,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1165,9 +1153,7 @@ where
|
|||
if cursor_before != state.cursor {
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(
|
||||
window::RedrawRequest::NextFrame,
|
||||
);
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
return event::Status::Captured;
|
||||
|
|
@ -1218,7 +1204,7 @@ where
|
|||
focus.is_window_focused = true;
|
||||
focus.updated_at = Instant::now();
|
||||
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
shell.request_redraw();
|
||||
}
|
||||
}
|
||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
|
|
@ -1237,11 +1223,11 @@ where
|
|||
- (*now - focus.updated_at).as_millis()
|
||||
% CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
|
||||
shell.request_redraw(window::RedrawRequest::At(
|
||||
shell.request_redraw_at(
|
||||
*now + Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1265,13 +1251,11 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.last_status = Some(status);
|
||||
} else {
|
||||
match self.last_status {
|
||||
Some(last_status) if status != last_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self
|
||||
.last_status
|
||||
.is_some_and(|last_status| status != last_status)
|
||||
{
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event::Status::Ignored
|
||||
|
|
|
|||
|
|
@ -352,13 +352,11 @@ where
|
|||
|
||||
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
||||
self.last_status = Some(current_status);
|
||||
} else {
|
||||
match self.last_status {
|
||||
Some(status) if status != current_status => {
|
||||
shell.request_redraw(window::RedrawRequest::NextFrame);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if self
|
||||
.last_status
|
||||
.is_some_and(|status| status != current_status)
|
||||
{
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
event_status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue