Skip to content

Commit

Permalink
Handle light mode
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jul 3, 2024
1 parent 8fe3689 commit 6788d0c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2621,32 +2621,33 @@ fn register_rect(ui: &Ui, rect: Rect) {

// Paint rectangle around widget:
{
let rect_fg_color = if is_clicking {
// Print width and height:
let text_color = if ui.visuals().dark_mode {
Color32::WHITE
} else {
Color32::LIGHT_BLUE
Color32::BLACK
};
let rect_bg_color = Color32::BLUE.gamma_multiply(0.5);

painter.rect(rect, 0.0, rect_bg_color, (1.0, rect_fg_color));

// Print width and height:
let font_id = TextStyle::Monospace.resolve(ui.style());
let text_color = Color32::WHITE;
painter.text(
painter.debug_text(
rect.left_center() + 2.0 * Vec2::LEFT,
Align2::RIGHT_CENTER,
format!("H: {:.1}", rect.height()),
font_id.clone(),
text_color,
format!("H: {:.1}", rect.height()),
);
painter.text(
painter.debug_text(
rect.center_top(),
Align2::CENTER_BOTTOM,
format!("W: {:.1}", rect.width()),
font_id,
text_color,
format!("W: {:.1}", rect.width()),
);

// Paint rect:
let rect_fg_color = if is_clicking {
Color32::WHITE
} else {
Color32::LIGHT_BLUE
};
let rect_bg_color = Color32::BLUE.gamma_multiply(0.5);
painter.rect(rect, 0.0, rect_bg_color, (1.0, rect_fg_color));
}

// ----------------------------------------------
Expand Down

0 comments on commit 6788d0c

Please sign in to comment.