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

Add user defined style properties #125

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Add user defined style properties #125

merged 1 commit into from
Oct 30, 2023

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Oct 29, 2023

This adds user defined style properties and uses it for a couple of scroll properties as an example.

Properties are defined like:

prop!(pub scroll_bar_color: Color { inherited: true } = Color::rgba8(0, 0, 0, 120));
prop!(pub bg_active_color: Color { inherited: true } = Color::rgba8(0, 0, 0, 30));

They can be changed by Style::set:

view.style(|s| s.set(bg_active_color, Color::rgba8(166, 166, 166, 40)))

I've also added a macro to define an extractor which can be used in views to store relevant styles in an efficient way for later use. The scroll view makes use of it:

prop_extracter! {
    Extracter {
        scroll_bar_color,
        bg_active_color: OptionReader<bg_active_color>,
    }
}

@codecov
Copy link

codecov bot commented Oct 29, 2023

Codecov Report

Merging #125 (abd3ce4) into main (646a1fb) will decrease coverage by 0.03%.
The diff coverage is 2.11%.

@@           Coverage Diff            @@
##            main    #125      +/-   ##
========================================
- Coverage   3.11%   3.09%   -0.03%     
========================================
  Files         54      54              
  Lines       9888    9961      +73     
========================================
  Hits         308     308              
- Misses      9580    9653      +73     
Files Coverage Δ
src/window_handle.rs 0.00% <ø> (ø)
src/views/scroll.rs 0.00% <0.00%> (ø)
src/view.rs 0.00% <0.00%> (ø)
src/context.rs 0.00% <0.00%> (ø)
src/style.rs 18.04% <3.37%> (-2.25%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dzhou121 dzhou121 merged commit 9e69067 into lapce:main Oct 30, 2023
9 checks passed
@Zoxc Zoxc deleted the user-styles branch October 30, 2023 11:59
jrmoulton pushed a commit to jrmoulton/floem that referenced this pull request Nov 6, 2023
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