1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

Move Color32 constants from mod color to struct Color32

This commit is contained in:
Emil Ernerfeldt
2021-01-02 17:18:41 +01:00
parent 64dd186daf
commit 029a85c1fc
20 changed files with 77 additions and 62 deletions

View File

@@ -3,6 +3,12 @@ use std::collections::HashMap;
const GRADIENT_SIZE: Vec2 = vec2(256.0, 24.0);
const BLACK: Color32 = Color32::BLACK;
const GREEN: Color32 = Color32::GREEN;
const RED: Color32 = Color32::RED;
const TRANSPARENT: Color32 = Color32::TRANSPARENT;
const WHITE: Color32 = Color32::WHITE;
#[derive(serde::Deserialize, serde::Serialize)]
pub struct ColorTest {
#[serde(skip)]
@@ -32,7 +38,7 @@ impl epi::App for ColorTest {
egui::CentralPanel::default().show(ctx, |ui| {
if frame.is_web() {
ui.colored_label(
egui::color::RED,
RED,
"NOTE: The current WebGL backend does NOT pass the color test!",
);
ui.separator();

View File

@@ -213,7 +213,7 @@ impl BoxPainting {
response.rect,
self.corner_radius,
Color32::gray(64),
Stroke::new(self.stroke_width, WHITE),
Stroke::new(self.stroke_width, Color32::WHITE),
);
}
});
@@ -388,7 +388,11 @@ impl Tree {
}
fn children_ui(&mut self, ui: &mut Ui, depth: usize) -> Action {
if depth > 0 && ui.add(Button::new("delete").text_color(color::RED)).clicked {
if depth > 0
&& ui
.add(Button::new("delete").text_color(Color32::RED))
.clicked
{
return Action::Delete;
}

View File

@@ -11,7 +11,7 @@ impl Default for Painting {
fn default() -> Self {
Self {
lines: Default::default(),
stroke: Stroke::new(1.0, color::LIGHT_BLUE),
stroke: Stroke::new(1.0, Color32::LIGHT_BLUE),
}
}
}

View File

@@ -48,7 +48,7 @@ impl Scrolls {
const ALIGNS: [Align; 3] = [Align::Min, Align::Center, Align::Max];
ui.columns(3, |cols| {
for (i, col) in cols.iter_mut().enumerate() {
col.colored_label(WHITE, TITLES[i]);
col.colored_label(Color32::WHITE, TITLES[i]);
let mut scroll_area = ScrollArea::from_max_height(200.0).id_source(i);
if scroll_offset {
self.tracking = false;
@@ -62,7 +62,8 @@ impl Scrolls {
ui.vertical(|ui| {
for item in 1..=50 {
if self.tracking && item == self.track_item {
let response = ui.colored_label(YELLOW, format!("Item {}", item));
let response =
ui.colored_label(Color32::YELLOW, format!("Item {}", item));
response.scroll_to_me(ALIGNS[i]);
} else {
ui.label(format!("Item {}", item));
@@ -80,7 +81,10 @@ impl Scrolls {
ui.min_rect().height() - ui.clip_rect().height() + 2.0 * margin,
)
});
col.colored_label(WHITE, format!("{:.0}/{:.0}", current_scroll, max_scroll));
col.colored_label(
Color32::WHITE,
format!("{:.0}/{:.0}", current_scroll, max_scroll),
);
}
});
}

View File

@@ -100,7 +100,7 @@ impl epi::App for HttpApp {
}
Err(error) => {
// This should only happen if the fetch API isn't available or something similar.
ui.add(egui::Label::new(error).text_color(egui::color::RED));
ui.add(egui::Label::new(error).text_color(egui::Color32::RED));
}
}
}