Giter Club home page Giter Club logo

Comments (6)

YgorSouza avatar YgorSouza commented on June 25, 2024

You mean this?

// We paint the cursor selection on top of the text, so make it transparent:
let color = visuals.selection.bg_fill.linear_multiply(0.5);

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.

image

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.

sbechet avatar sbechet commented on June 25, 2024

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.

sbechet avatar sbechet commented on June 25, 2024

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.

YgorSouza avatar YgorSouza commented on June 25, 2024

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.

image

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.

sbechet avatar sbechet commented on June 25, 2024

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.

YgorSouza avatar YgorSouza commented on June 25, 2024

There could be an option to override the text color when it is highlighted. Here on GitHub we have both possibilities:

image

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.