Skip to content

Commit

Permalink
Re-exported egui.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilr612 committed Jul 30, 2024
1 parent bffb43f commit bdd3eb3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn get_mouse_input(
events: &mut Vec<Event>,
pixels_per_point: f32,
modifiers: Modifiers,
ctx: &egui::Context
ctx: &egui::Context,
) {
let mouse_delta = rl.get_mouse_delta().scale_by(1.0 / pixels_per_point);
let mouse_position = rl.get_mouse_position().scale_by(1.0 / pixels_per_point);
Expand Down Expand Up @@ -234,10 +234,6 @@ pub fn gather_input(opt: &InputOptions, ctx: &egui::Context, rl: &mut RaylibHand
Vec::new()
};

if !events.is_empty() {
println!("Events: {events:?}");
}

RawInput {
viewport_id: ViewportId::ROOT,
viewports: iter::once((ViewportId::ROOT, viewport)).collect(),
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ use raylib::{
RaylibHandle, RaylibThread,
};

/// Re-export egui crate for convenience.
pub use egui;

pub mod input;
pub mod paint;
pub mod util;
Expand Down
5 changes: 1 addition & 4 deletions src/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ impl Painter {
} else {
let lines = ps.points.iter()
.zip(ps.points.iter().skip(1))
.map(|(a,b)|
(a.convert().scale_by(pxpp),
b.convert().scale_by(pxpp))
);
.map(|(a,b)| (a.convert().scale_by(pxpp), b.convert().scale_by(pxpp)));
let thick = ps.stroke.width * pxpp;
let color = color_mode_to_color(&ps.stroke.color);

Expand Down
22 changes: 22 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,32 @@ fn it_works() {
let (mut rl, thread) = raylib::init().size(768, 1024).title("Hello, World").build();
let ctx = Context::default();

let mut fonts = egui::FontDefinitions::default();

fonts.font_data.insert("retro".to_owned(), egui::FontData::from_static(include_bytes!("../../alagard.ttf")));

// Put my font first (highest priority) for proportional text:
fonts
.families
.entry(egui::FontFamily::Proportional)
.or_default()
.insert(0, "retro".to_owned());

// Put my font as last fallback for monospace:
fonts
.families
.entry(egui::FontFamily::Monospace)
.or_default()
.push("retro".to_owned());

// Tell egui to use these fonts:
ctx.set_fonts(fonts);

ctx.set_visuals(Visuals {
override_text_color: Some(Color32::WHITE),
hyperlink_color: Color32::BLUE,
window_rounding: Rounding::ZERO,
faint_bg_color: Color32::LIGHT_YELLOW.gamma_multiply(0.4),
..Visuals::dark()
});

Expand Down

0 comments on commit bdd3eb3

Please sign in to comment.