more layout yippee

This commit is contained in:
lunarydess
2025-02-22 19:27:21 +01:00
parent 49225218f8
commit 1e82376900
3 changed files with 50 additions and 47 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,3 @@
/target
target/
.idea/
Cargo.lock

View File

@@ -48,10 +48,8 @@ impl eframe::App for CatnipApp {
modal.body(ui, "This is a modal.");
});
modal.buttons(ui, |ui| {
if modal.button(ui, "meow").clicked() {
};
if modal.button(ui, "close").clicked() {
};
if modal.button(ui, "meow").clicked() {};
if modal.button(ui, "close").clicked() {};
});
});
@@ -82,8 +80,6 @@ impl eframe::App for CatnipApp {
// main content
egui::CentralPanel::default().show(ctx, |ui| {
ui.image(egui::include_image!("leaf.png"))
.on_hover_text_at_pointer("test meow");
ui.with_layout(egui::Layout::left_to_right(Align::Max), |ui| {
CodeEditor::default()
.id_source("cat editor :3")
@@ -118,50 +114,53 @@ impl eframe::App for CatnipApp {
ui.label(" with ♡");
ui.with_layout(egui::Layout::right_to_left(Align::Center), |ui| {
// editor theme selector
egui::ComboBox::from_label("Theme")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", &self.editor_theme.name))
.show_ui(ui, |ui| {
DEFAULT_THEMES.iter().clone().for_each(|theme| {
ui.selectable_value(&mut self.editor_theme, *theme, theme.name);
ui.menu_image_button(egui::include_image!("cogwheel.svg"), |ui| {
// syntax selector
egui::ComboBox::from_label("Syntax")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", &self.editor_syntax.language))
.show_ui(ui, |ui| {
[
Syntax::asm(),
Syntax::shell(),
Syntax::sql(),
Syntax::lua(),
Syntax::rust(),
Syntax::python(),
Syntax::java(),
]
.iter()
.for_each(|syntax| {
ui.selectable_value(
&mut self.editor_syntax,
syntax.clone(),
syntax.language,
);
});
});
});
// syntax selector
egui::ComboBox::from_label("Syntax")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", &self.editor_syntax.language))
.show_ui(ui, |ui| {
[
Syntax::asm(),
Syntax::shell(),
Syntax::sql(),
Syntax::lua(),
Syntax::rust(),
Syntax::python(),
Syntax::java(),
]
.iter()
.for_each(|syntax| {
ui.selectable_value(
&mut self.editor_syntax,
syntax.clone(),
syntax.language,
);
// theme selector
let mut theme = ui.ctx().options(|opt| opt.theme_preference);
egui::ComboBox::from_label("Theme")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", theme))
.show_ui(ui, |ui| {
ui.selectable_value(&mut theme, ThemePreference::System, "💻 System", );
ui.selectable_value(&mut theme, ThemePreference::Light, "☀ Light");
ui.selectable_value(&mut theme, ThemePreference::Dark, "🌙 Dark");
});
});
ui.ctx().set_theme(theme);
let mut theme = ui.ctx().options(|opt| opt.theme_preference);
egui::ComboBox::from_label("")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", theme))
.show_ui(ui, |ui| {
ui.selectable_value(&mut theme, ThemePreference::System, "💻 System");
ui.selectable_value(&mut theme, ThemePreference::Light, "☀ Light");
ui.selectable_value(&mut theme, ThemePreference::Dark, "🌙 Dark");
});
ui.ctx().set_theme(theme);
// scheme selector
egui::ComboBox::from_label("Scheme")
.wrap_mode(TextWrapMode::Wrap)
.selected_text(format!("{:?}", &self.editor_theme.name))
.show_ui(ui, |ui| {
DEFAULT_THEMES.iter().clone().for_each(|theme| {
ui.selectable_value(&mut self.editor_theme, *theme, theme.name);
});
});
});
});
});
});

4
src/cogwheel.svg Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 24 24">
<path d="m21.331,13.885l-.451-.26c.102-.544.153-1.088.153-1.625s-.051-1.081-.153-1.625l.451-.26c1.434-.825,1.93-2.662,1.105-4.096-.399-.695-1.045-1.193-1.819-1.401-.774-.209-1.583-.104-2.277.295l-.45.259c-.841-.721-1.81-1.279-2.857-1.649v-.522c0-1.654-1.346-3-3-3s-3,1.346-3,3v.522c-1.047.37-2.016.929-2.857,1.649l-.45-.259c-.693-.398-1.501-.504-2.277-.295-.773.208-1.419.706-1.818,1.4-.4.694-.505,1.503-.296,2.277.208.773.706,1.419,1.401,1.819l.451.259c-.102.544-.153,1.088-.153,1.626s.051,1.082.153,1.626l-.451.259c-.695.4-1.192,1.046-1.401,1.819-.209.774-.104,1.583.295,2.276.399.695,1.045,1.193,1.819,1.401.776.21,1.584.104,2.277-.295l.45-.259c.841.721,1.81,1.279,2.857,1.649v.522c0,1.654,1.346,3,3,3s3-1.346,3-3v-.522c1.047-.37,2.016-.929,2.857-1.649l.45.259c.695.399,1.503.505,2.277.295.773-.208,1.419-.706,1.819-1.401.825-1.434.329-3.271-1.105-4.096Zm-2.556-3.743c.171.624.258,1.249.258,1.858s-.087,1.234-.258,1.858c-.121.438.071.904.466,1.132l1.093.629c.478.274.643.887.369,1.365-.133.231-.349.397-.607.467-.257.069-.528.035-.759-.099l-1.09-.627c-.396-.226-.895-.157-1.213.168-.888.908-2.012,1.557-3.25,1.877-.441.113-.75.512-.75.968v1.262c0,.552-.449,1-1,1s-1-.448-1-1v-1.262c0-.456-.309-.854-.75-.968-1.237-.32-2.361-.969-3.251-1.877-.193-.198-.453-.301-.715-.301-.17,0-.342.044-.498.133l-1.09.627c-.232.134-.501.168-.759.099-.258-.069-.473-.235-.606-.468-.133-.231-.168-.5-.099-.758.07-.258.236-.474.467-.606l1.093-.629c.395-.228.586-.693.465-1.133-.171-.621-.258-1.246-.258-1.857s.087-1.236.258-1.857c.121-.439-.07-.905-.465-1.133l-1.093-.629c-.231-.133-.397-.349-.467-.606-.069-.258-.034-.526.099-.759.133-.231.348-.397.606-.467.257-.07.527-.036.759.099l1.09.627c.396.227.896.158,1.213-.168.89-.908,2.014-1.557,3.251-1.877.441-.113.75-.512.75-.968v-1.262c0-.552.449-1,1-1s1,.448,1,1v1.262c0,.456.309.854.75.968,1.238.32,2.362.969,3.25,1.877.319.325.818.394,1.213.168l1.09-.627c.231-.135.501-.169.759-.099.258.069.474.235.607.467.274.479.109,1.091-.369,1.365l-1.093.629c-.395.228-.586.693-.466,1.132Zm-8.775-.142c-.35,0-.681.067-1,.163v-2.163c0-.552.448-1,1-1s1,.448,1,1v2.163c-.319-.096-.65-.163-1-.163Zm2,3.5c0,.738-.405,1.376-1,1.723v.777c0,.552-.448,1-1,1s-1-.448-1-1v-.777c-.595-.346-1-.984-1-1.723,0-1.105.895-2,2-2s2,.895,2,2Zm4-3c0,1.105-.895,2-2,2s-2-.895-2-2c0-.738.405-1.376,1-1.723v-.777c0-.552.448-1,1-1s1,.448,1,1v.777c.595.346,1,.984,1,1.723Zm-2,3.5c.35,0,.681-.067,1-.163v2.163c0,.552-.448,1-1,1s-1-.448-1-1v-2.163c.319.096.65.163,1,.163Z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB