mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Enable colored text (and other misc fixes)
This commit is contained in:
@@ -3,7 +3,7 @@ use emigui::{math::*, types::*, widgets::*, Align, Region, TextStyle};
|
||||
pub struct App {
|
||||
checked: bool,
|
||||
count: i32,
|
||||
selected_alternative: i32,
|
||||
radio: i32,
|
||||
|
||||
size: Vec2,
|
||||
corner_radius: f32,
|
||||
@@ -14,7 +14,7 @@ impl Default for App {
|
||||
fn default() -> App {
|
||||
App {
|
||||
checked: true,
|
||||
selected_alternative: 0,
|
||||
radio: 0,
|
||||
count: 0,
|
||||
size: vec2(100.0, 50.0),
|
||||
corner_radius: 5.0,
|
||||
@@ -35,6 +35,11 @@ impl App {
|
||||
gui.input().screen_size.y,
|
||||
)));
|
||||
|
||||
gui.horizontal(Align::Min, |gui| {
|
||||
gui.add(label("Text can have").text_color(srgba(110, 255, 110, 255)));
|
||||
gui.add(label("color").text_color(srgba(128, 140, 255, 255)));
|
||||
});
|
||||
|
||||
gui.add(label("Hover me")).tooltip_text(
|
||||
"This is a multiline tooltip that demonstrates that you can easily add tooltips to any element.\nThis is the second line.\nThis is the third.",
|
||||
);
|
||||
@@ -42,35 +47,30 @@ impl App {
|
||||
gui.add(Checkbox::new(&mut self.checked, "checkbox"));
|
||||
|
||||
gui.horizontal(Align::Min, |gui| {
|
||||
if gui
|
||||
.add(radio(self.selected_alternative == 0, "First"))
|
||||
.clicked
|
||||
{
|
||||
self.selected_alternative = 0;
|
||||
if gui.add(radio(self.radio == 0, "First")).clicked {
|
||||
self.radio = 0;
|
||||
}
|
||||
if gui
|
||||
.add(radio(self.selected_alternative == 1, "Second"))
|
||||
.clicked
|
||||
{
|
||||
self.selected_alternative = 1;
|
||||
if gui.add(radio(self.radio == 1, "Second")).clicked {
|
||||
self.radio = 1;
|
||||
}
|
||||
if gui
|
||||
.add(radio(self.selected_alternative == 2, "Final"))
|
||||
.clicked
|
||||
{
|
||||
self.selected_alternative = 2;
|
||||
if gui.add(radio(self.radio == 2, "Final")).clicked {
|
||||
self.radio = 2;
|
||||
}
|
||||
});
|
||||
|
||||
if gui
|
||||
.add(Button::new("Click me"))
|
||||
.tooltip_text("This will just increase a counter.")
|
||||
.clicked
|
||||
{
|
||||
self.count += 1;
|
||||
}
|
||||
|
||||
gui.add(label(format!("This is a multiline label.\nThe button have been clicked {} times.\nBelow are more options.", self.count)));
|
||||
gui.horizontal(Align::Min, |gui| {
|
||||
if gui
|
||||
.add(Button::new("Click me"))
|
||||
.tooltip_text("This will just increase a counter.")
|
||||
.clicked
|
||||
{
|
||||
self.count += 1;
|
||||
}
|
||||
gui.add(label(format!(
|
||||
"The button have been clicked {} times",
|
||||
self.count
|
||||
)));
|
||||
});
|
||||
|
||||
gui.foldable("Test box rendering", |gui| {
|
||||
gui.add(Slider::new(&mut self.size.x, 0.0, 500.0).text("width"));
|
||||
|
||||
Reference in New Issue
Block a user