Comments (6)
You mean this?
egui/crates/egui/src/text_selection/visuals.rs
Lines 19 to 20 in 814ad07
I think this affects the text selection, but not the SelectableLabel
. What color did you use for the background and stroke? Maybe the default colors are a little too close to each other and end up the same after rounding to 1 bit.
And for the text selection, I guess it would be a matter of making the text even darker and the selection lighter to begin with? So they don't end up the same color after blending and rounding.
from egui.
What you need to understand with these screens is that there are really only 8 colors and that if you are outside of them, the code in the screen will "try" (by doing a sort of average with the colors of the surrounding pixels?) to give it a close value but it is not reliable. It is therefore absolutely necessary to be precise and choose only from these 8 colors.
I was planning to submit an eink pull request, but in the meantime, here is my test:
fn selection_eink() -> Selection {
Selection {
bg_fill: Color32::from_rgb(128, 255, 255),
stroke: Stroke::new(1.0, Color32::BLUE),
}
}
pub fn widgets_eink() -> Widgets {
Widgets {
noninteractive: WidgetVisuals {
weak_bg_fill: Color32::WHITE,
bg_fill: Color32::WHITE,
bg_stroke: Stroke::new(1.0, Color32::BLACK),
fg_stroke: Stroke::new(1.0, Color32::BLACK),
rounding: Rounding::same(2.0),
expansion: 0.0,
},
inactive: WidgetVisuals {
weak_bg_fill: Color32::WHITE,
bg_fill: Color32::from_rgb(0, 255, 255),
bg_stroke: Stroke::new(1.0, Color32::BLACK),
fg_stroke: Stroke::new(2.0, Color32::BLACK),
rounding: Rounding::same(2.0),
expansion: 1.0,
},
hovered: WidgetVisuals {
weak_bg_fill: Color32::WHITE,
bg_fill: Color32::WHITE,
bg_stroke: Stroke::new(1.0, Color32::from_rgb(0, 255, 255)),
fg_stroke: Stroke::new(1.5, Color32::BLUE),
rounding: Rounding::same(3.0),
expansion: 1.0,
},
active: WidgetVisuals {
weak_bg_fill: Color32::WHITE,
bg_fill: Color32::WHITE,
bg_stroke: Stroke::new(1.0, Color32::from_rgb(0, 255, 255)),
fg_stroke: Stroke::new(1.0, Color32::BLUE),
rounding: Rounding::same(2.0),
expansion: 0.0,
},
open: WidgetVisuals {
weak_bg_fill: Color32::WHITE,
bg_fill: Color32::WHITE,
bg_stroke: Stroke::new(1.0, Color32::from_rgb(0, 255, 255)),
fg_stroke: Stroke::new(1.0, Color32::BLUE),
rounding: Rounding::same(2.0),
expansion: 0.0,
},
}
}
pub fn visuals_eink() -> Visuals {
Visuals {
dark_mode: false,
override_text_color: None,
widgets: widgets_eink(),
selection: selection_eink(),
hyperlink_color: Color32::from_rgb(0, 255, 255), // cyan
faint_bg_color: Color32::WHITE,
extreme_bg_color: Color32::WHITE,
code_bg_color: Color32::WHITE,
warn_fg_color: Color32::from_rgb(255, 0, 255),
error_fg_color: Color32::RED,
window_rounding: Rounding::same(6.0),
window_shadow: Shadow {
offset: vec2(0.0, 0.0),
blur: 0.0,
spread: 0.0,
color: Color32::BLACK,
},
window_fill: Color32::WHITE,
window_stroke: Stroke::new(1.0, Color32::BLACK),
window_highlight_topmost: true,
menu_rounding: Rounding::same(6.0),
panel_fill: Color32::WHITE,
popup_shadow: Shadow {
offset: vec2(0.0, 0.0),
blur: 0.0,
spread: 0.0,
color: Color32::BLACK,
},
resize_corner_size: 12.0,
text_cursor: Default::default(),
text_cursor_preview: true,
clip_rect_margin: 3.0,
button_frame: false,
collapsing_header_frame: false,
indent_has_left_vline: true,
striped: false,
slider_trailing_fill: false,
handle_shape: HandleShape::Circle,
interact_cursor: None,
image_loading_spinners: false,
numeric_color_space: NumericColorSpace::GammaByte,
}
}
from egui.
Colors are:
Color32 | hex |
---|---|
Color32::BLACK | #000000 |
Color32::BLUE | #0000FF |
Color32::GREEN | #00FF00 |
"Color32::CYAN" | #00FFFF |
Color32::RED | #FF0000 |
"Color32::MAGENTA" | #FF00FF |
Color32::YELLOW | #FFFF00 |
Color32::WHITE | #FFFFFF |
As you can see binary a simple binary increment.
from egui.
bg_fill: Color32::from_rgb(128, 255, 255),
That's not one of the allowed colors. Are you sure it doesn't work for the SelectableLabel? It seems to respect the colors you set.
As for the text selection, the problem is that egui paints the selection after the text as mentioned in the code comment above, so the colors blend. The logic would have to be changed so the selection is painted first without changing the color of the text. There are other UIs that work like this, such as this GitHub page (and web pages in general), so maybe there is an argument to be made that egui should work like that as well, if it is possible.
from egui.
bg_fill: Color32::from_rgb(128, 255, 255),
Yes, I have done further testing, this color "seems" good for my own testing but is not "safe" as a long term solution as it is a color generated by the firmware of the screen.
the problem is that egui paints the selection after the text
I think the problem is here: we can't choose the reverse color.
from egui.
There could be an option to override the text color when it is highlighted. Here on GitHub we have both possibilities:
But before that can solve your problem, egui would have to paint the selection behind the text, instead of a transparent overlay on top of it, so the colors don't blend. Technically you could do that yourself, by making the default selection bg invisible and painting it manually using a LayoutJob
to add a background to the part of the text that is selected. Maybe custom Label
and TextEdit
widgets that work like that. But it sounds inconvenient, and I don't know if egui even provides all the necessary public API to do that. Then again, if this can be done, it could be added as a option to egui itself, like a highlight_behind_text
in the Visuals
struct.
from egui.
Related Issues (20)
- `UiBuilder`
- ![Screen Shot 2022-02-21 at 22 16 04](https://user-images.githubusercontent.com/1148717/155027189-5b9787dd-fca1-4d71-9850-fb90d7ab40c3.png)
- Custom default replacement glyphs for font HOT 1
- Add a built-in egui debugger
- ComboBox dropdown(pop-up?) position with Pan & Zoom
- scrollwheel acceleration carries into ScrollArea when pointer is outside during scrolling HOT 3
- Drag and Drop: read incrementally
- Register file hover and drop events for areas
- eframe/ egui-wgpu incompatibility with newer wgpu versions HOT 3
- Nitpick: give at least two decimals of information for a pos2 in the Debug trait HOT 1
- Trouchscreen pointer doesn't release HOT 1
- 200 MB/s wgpu memory leak (DPI scaling/multiple monitors/resizing) HOT 10
- Example hello_world_par does not compile on Ubuntu
- Table columns should retain their width when reordering
- Tooltips should maybe inherit the style of the parent?
- Putting an `TextEdit` in a `egui::Grid` makes it too small
- Web canvas resize loop HOT 8
- Window dragging is not working with `custom_window_frame` example on Linux
- Text ellipsis stopped working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egui.