mirror of
https://gitlab.com/erkanisik/yali-rs.git
synced 2026-07-31 03:09:00 +00:00
ccc851d79f
- Create src/ui/combobox.rs with helper functions (show_combo_box, selectable_value, selectable_value_custom) - Create src/ui/combobox_stil.rs with ComboBox visual constants (weak_bg_fill, text/border colors) - Move theme.rs ComboBox visuals (weak_bg_fill, fg_stroke, bg_stroke) into combobox_stil::apply_visuals - Move LocationStep from installer.rs to src/steps/location.rs - Re-register LocationStep in steps/mod.rs - Update all ComboBox usages across steps (bootloader, display_manager, partition, funct) to use theme::show_combo_box / selectable_value - Replace manual mesh drawing in language selector with combobox helper - Add region/timezone i18n keys - Vertical-align region/zone labels to match ComboBox height
122 lines
4.1 KiB
Rust
122 lines
4.1 KiB
Rust
use eframe::egui;
|
||
|
||
#[macro_export]
|
||
macro_rules! draw_icon {
|
||
($ui:expr, $path:literal, $size:expr, $color:expr) => {
|
||
$ui.add(
|
||
eframe::egui::Image::new(eframe::egui::include_image!($path))
|
||
.max_width($size)
|
||
.max_height($size)
|
||
.tint($color),
|
||
)
|
||
};
|
||
}
|
||
|
||
pub fn form_input_text(
|
||
ui: &mut eframe::egui::Ui,
|
||
text: &mut String,
|
||
)-> eframe::egui::Response {
|
||
|
||
let width_percent = 0.90; // Mevcut genişliğin %90'ı
|
||
let height = 32.0; // Standart yükseklik
|
||
let hesaplanan_genislik = ui.available_width() * width_percent;
|
||
let boyut = eframe::egui::vec2(hesaplanan_genislik, height);
|
||
|
||
ui.spacing_mut().button_padding = eframe::egui::vec2(10.0, 10.0);
|
||
ui.add_sized(
|
||
boyut,
|
||
eframe::egui::TextEdit::singleline(text)
|
||
.vertical_align(eframe::egui::Align::Center)
|
||
)
|
||
}
|
||
|
||
pub fn form_input_password(
|
||
ui: &mut eframe::egui::Ui,
|
||
text: &mut String,
|
||
show_password: &mut bool,
|
||
) -> eframe::egui::Response {
|
||
let width_percent = 0.90;
|
||
let height = 32.0;
|
||
let toplam_genislik = ui.available_width() * width_percent;
|
||
let dugme_genislik = 40.0;
|
||
let alan_genislik = toplam_genislik - dugme_genislik - 4.0;
|
||
let boyut = eframe::egui::vec2(alan_genislik, height);
|
||
|
||
ui.spacing_mut().button_padding = eframe::egui::vec2(10.0, 10.0);
|
||
|
||
ui.horizontal(|ui| {
|
||
let r = ui.add_sized(
|
||
boyut,
|
||
eframe::egui::TextEdit::singleline(text)
|
||
.password(!*show_password)
|
||
.vertical_align(eframe::egui::Align::Center),
|
||
);
|
||
let göz = if *show_password { "🙈" } else { "👁" };
|
||
if ui.add(
|
||
eframe::egui::Button::new(göz)
|
||
.min_size(eframe::egui::vec2(dugme_genislik, height))
|
||
).clicked() {
|
||
*show_password = !*show_password;
|
||
}
|
||
r
|
||
}).inner
|
||
}
|
||
|
||
pub fn form_label(ui: &mut eframe::egui::Ui, text: &str) {
|
||
ui.label(
|
||
eframe::egui::RichText::new(text)
|
||
.strong()
|
||
.color(crate::ui::theme::c_text()) // Atomic temandan rengi çekiyor
|
||
);
|
||
}
|
||
|
||
pub fn form_checkbox(ui: &mut eframe::egui::Ui, checked: &mut bool, text: &str) {
|
||
ui.checkbox(checked, eframe::egui::RichText::new(text).strong().color(crate::ui::theme::c_text()));
|
||
}
|
||
|
||
|
||
|
||
pub fn language_selector_ui(ui: &mut eframe::egui::Ui, state: &mut crate::installer::GlobalState) {
|
||
ui.horizontal(|ui| {
|
||
// Satır yüksekliğini tam olarak 32px'e eşitliyoruz
|
||
ui.set_height(32.0);
|
||
|
||
// 1. Sol taraftaki ikon alanı
|
||
ui.vertical(|ui| {
|
||
ui.add_space(4.0);
|
||
ui.add(
|
||
eframe::egui::Image::new(eframe::egui::include_image!("../assets/icons/language-icon.svg"))
|
||
.max_width(40.0)
|
||
);
|
||
});
|
||
|
||
ui.add_space(6.0);
|
||
|
||
// 2. ComboBox alanı (%90 genişlik payı)
|
||
let available_width = ui.available_width() * 0.90;
|
||
let current_lang_label = if state.language == "tr" { "Türkçe" } else { "English" };
|
||
|
||
let languages = [
|
||
("tr", "Türkçe", eframe::egui::include_image!("../assets/flags/tr.svg")),
|
||
("en", "English", eframe::egui::include_image!("../assets/flags/us.svg")),
|
||
];
|
||
|
||
crate::ui::theme::show_combo_box(ui, "language_select_combo", current_lang_label, available_width, |ui, w| {
|
||
for (code, label, image_source) in languages.iter() {
|
||
let resp = crate::ui::theme::selectable_value_custom(ui, w, |ui, rect| {
|
||
ui.put(rect, |ui: &mut egui::Ui| {
|
||
ui.horizontal(|ui| {
|
||
ui.add_space(6.0);
|
||
ui.add(eframe::egui::Image::new(image_source.clone()).max_width(18.0));
|
||
ui.add_space(4.0);
|
||
ui.label(*label);
|
||
}).response
|
||
});
|
||
});
|
||
if resp.clicked() {
|
||
state.language = code.to_string();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
} |