Skip to content

Commit

Permalink
feat: add support for egui version 0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
Stonks3141 committed Apr 7, 2024
1 parent 5479933 commit a34176d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ categories = ["gui"]
exclude = ["assets/"]

[dependencies]
egui = "0.26"
egui26 = { version = "0.26", package = "egui", default-features = false, optional = true }
egui27 = { version = "0.27", package = "egui", default-features = false, optional = true }

[dev-dependencies]
eframe = "0.26"

[features]
default = [ "egui26" ]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@

## Usage

catppuccin-egui uses Cargo features to add support for new egui versions without breaking backwards compatibility.

Add the crate to your `Cargo.toml`:

```toml
[dependencies]
catppuccin-egui = "5.0"
catppuccin-egui = { version = "5.0", features = ["egui27"] }
```

To use a theme, call the `set_theme` function with a theme and the egui context:
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! # Example
//!
//! ```rust
//! # use eframe::egui;
//! struct App;
//! impl eframe::App for App {
//! fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
Expand All @@ -20,6 +21,7 @@
//! You can also customize your own theme:
//!
//! ```rust
//! # use eframe::egui;
//! use catppuccin_egui::{Theme, MOCHA};
//! const MY_MOCHA: Theme = Theme {
//! red: egui::Color32::from_rgb(255, 0, 0),
Expand All @@ -28,6 +30,14 @@
//! ```
//!

#[cfg(not(any(feature = "egui26", feature = "egui27")))]
compile_error!("at least one egui version must be enabled");

#[cfg(feature = "egui26")]
use egui26 as egui;
#[cfg(feature = "egui27")]
use egui27 as egui;

use egui::{epaint, style, Color32};

/// Apply the given theme to a [`Context`](egui::Context).
Expand All @@ -41,6 +51,7 @@ pub fn set_theme(ctx: &egui::Context, theme: Theme) {
/// # Example
///
/// ```rust
/// # use eframe::egui;
/// # use egui::__run_test_ctx;
/// # __run_test_ctx(|ctx| {
/// let mut style = (*ctx.style()).clone();
Expand Down

0 comments on commit a34176d

Please sign in to comment.