egui-widget-texicon 0.1.0

An egui widget that combines an icon and text, often found in modern UIs.
Documentation
  • Coverage
  • 0%
    0 out of 15 items documented0 out of 3 items with examples
  • Size
  • Source code size: 8.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 476.86 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 29s Average build duration of successful builds.
  • all releases: 29s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • White-Rabbit-Scientific

Links

What is egui-widget-texicon?

egui-widget-texicon is an egui widget that combines an icon and text, often found in modern UIs.

Please submit an issue on Github if you have suggestions or improvements.

Usage

In Cargo.toml add the following dependency:

[dependencies]
egui-widget-texicon = 0.1.0  <--- The latest version number can be found on Crates.io.

Or you could use the following if developing locally:

[dependencies]
egui-widget-texicon = { path = "/Github/egui-widget-texicon/" }

The following asumes you are using eframe_template:

In app.rs import the crate using:

use egui_themes::{StateMachine, MOCHA};

Using the TemplateApp struct, define a run_once boolean and a StateMachine variable to hold the current theme:

pub struct TemplateApp {
    run_once: bool,
    my_theme: StateMachine,
}

impl Default for TemplateApp {
    fn default() -> Self {
        Self {
            run_once: false,
            my_theme: egui_themes::StateMachine::new(),
        }
    }
}

Inside fn update... set the startup theme state using the run_once boolean:

fn update(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
    if self.run_once == false {
        self.run_once = true;
        self.my_theme.set_theme(ctx, &MOCHA);
    }

Then in the main loop:

// Theme cycle button
let b = ui.add(egui::Button::new("☀🌙").sense(Sense::click()));

if b.clicked() {
    self.my_theme.rotate_theme(&ctx);
} else if b.hovered() {
    b.on_hover_text("Click for next theme...");
}

Video

https://github.com/user-attachments/assets/ddcfce39-8377-440f-bce6-b98e7945c441