Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ChangeFlags and requests #151

Merged
merged 4 commits into from
Nov 6, 2023
Merged

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Nov 6, 2023

This refactors the use of ChangeFlags. ViewState has a new requested_changes: ChangeFlags field which replaces request_layout and request_style. View::update on longer returns ChangeFlags as view implementation are expected to call request_* functions.

}

self.set_cursor();

if !flags.is_empty() {
if paint {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a view just wanted to request_paint without style or layout change, e.g. a canvas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can just call request_paint to do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see it request_style now. But is it efficient enough when the canvas wants some animation frames.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only requests style on one view, but I'm going to replace it to just requesting painting.

@Zoxc
Copy link
Contributor Author

Zoxc commented Nov 6, 2023

I've added some further changes here. schedule_style, schedule_layout and schedule_paint are new functions which request a pass on the next frame. These are now used to drive animations.

Timers are no longer used for animations, which makes the themes example have smooth animations.

The animation example now works again.

Paint requests no longer invokes the style pass.

I've made ChangeFlags private for consistency as painting needs damage tracking which doesn't have a tree structure.

@Zoxc Zoxc changed the title Refactor ChangeFlags Refactor ChangeFlags and requests Nov 6, 2023
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #151 (4b9d85a) into main (b187eec) will increase coverage by 0.04%.
The diff coverage is 0.00%.

@@           Coverage Diff            @@
##            main    #151      +/-   ##
========================================
+ Coverage   5.17%   5.21%   +0.04%     
========================================
  Files         56      56              
  Lines      10942   10850      -92     
========================================
  Hits         566     566              
+ Misses     10376   10284      -92     
Files Coverage Δ
src/update.rs 0.00% <ø> (ø)
src/views/dyn_container.rs 0.00% <ø> (ø)
src/views/img.rs 0.00% <ø> (ø)
src/views/label.rs 0.00% <ø> (ø)
src/views/list.rs 0.00% <ø> (ø)
src/views/rich_text.rs 0.00% <ø> (ø)
src/views/scroll.rs 0.00% <ø> (ø)
src/views/stack.rs 0.00% <ø> (ø)
src/views/svg.rs 0.00% <ø> (ø)
src/views/tab.rs 0.00% <ø> (ø)
... and 8 more

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@dzhou121 dzhou121 merged commit bd34253 into lapce:main Nov 6, 2023
9 checks passed
@Zoxc Zoxc deleted the updateflags-refactor branch November 6, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants