Skip to content

Commit

Permalink
add icons
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Nov 27, 2024
1 parent 1b9444f commit 7a55752
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ log = "0.4"
serde = { version = "1", features = ["derive"] }
tracing = { version = "0.1" }
seed-keeper-core = { git = "https://github.com/DougAnderson444/seed-keeper.git" }
egui_material_icons = "0.1.0"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
90 changes: 89 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ mod error;
mod file_dialog;
mod platform;

use egui::text::LayoutJob;
use egui::FontId;
use egui::TextFormat;
use egui::TextStyle;
use egui::Widget as _;
use egui_material_icons::icon_button;
use egui_material_icons::icons;

pub(crate) use platform::Platform;

/// We derive Deserialize/Serialize so we can persist app state on shutdown.
Expand Down Expand Up @@ -59,6 +67,7 @@ impl eframe::App for MultinodeApp {

// pass the ctx to the platform
if !self.platform.egui_ctx() {
egui_material_icons::initialize(ctx);
self.platform.set_egui_ctx(ctx.clone());
}

Expand Down Expand Up @@ -107,8 +116,87 @@ impl eframe::App for MultinodeApp {
}

ui.separator();
ui.horizontal(|ui| {
icon_button(ui, icons::ICON_ADD);
icon_button(ui, icons::ICON_REMOVE);
icon_button(ui, icons::ICON_IMAGE);
ui.label("Ayyy")
});

ui.group(|ui| {
ui.horizontal(|ui| {
egui::Label::new(
egui::RichText::new(icons::ICON_FAVORITE)
.size(16.0)
.family(egui::FontFamily::Proportional),
)
.ui(ui);
egui::Label::new("2").ui(ui);
});
});

ui.group(|ui| {
ui.horizontal(|ui| {
egui::Label::new(
egui::RichText::new(icons::ICON_SETTINGS)
.size(16.0)
.family(egui::FontFamily::Proportional),
)
.ui(ui);
egui::Label::new("Settings").ui(ui);
});
})
.response
.on_hover_cursor(egui::CursorIcon::PointingHand);

if ui
.add(egui::Button::new(
// Settings button
egui::RichText::new(format!("{} Settings", icons::ICON_SETTINGS))
.size(16.0)
.family(egui::FontFamily::Proportional),
))
.on_hover_cursor(egui::CursorIcon::PointingHand)
.clicked()
{
// Handle click event here
tracing::info!("Settings 2 clicked");
}
ui.horizontal(|ui| {
let mut job = LayoutJob::default();
job.append(
icons::ICON_SETTINGS,
0.0,
TextFormat {
font_id: FontId::proportional(16.0),
color: ui.visuals().text_color(),
..Default::default()
},
);
job.append(
" Settings",
0.0,
TextFormat {
font_id: FontId::proportional(
ui.style().text_styles[&TextStyle::Body].size,
),
color: ui.visuals().text_color(),
..Default::default()
},
);

if ui
.add_sized(
ui.spacing().button_padding, // This sets the minimum size
egui::Button::new(job),
)
.clicked()
{
// Handle button click
tracing::info!("Settings 3 clicked");
}
});

// #[cfg(not(target_arch = "wasm32"))]
ui.vertical(|ui| {
self.platform.show(ctx, ui);
});
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#[cfg(not(target_arch = "wasm32"))]
#[tokio::main]
async fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let _ = tracing_subscriber::fmt()
.with_env_filter("eframe_multinode=debug")
.try_init();

tracing::info!("Starting eframe multinode");

let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
Expand Down

0 comments on commit 7a55752

Please sign in to comment.