MCPcopy Index your code
hub / github.com/encounter/objdiff / font_id_ui

Function font_id_ui

objdiff-gui/src/views/appearance.rs:226–283  ·  view source on GitHub ↗
(
    ui: &mut egui::Ui,
    label: &str,
    mut font_id: FontId,
    default: FontId,
    appearance: &Appearance,
)

Source from the content-addressed store, hash-verified

224];
225
226fn font_id_ui(
227 ui: &mut egui::Ui,
228 label: &str,
229 mut font_id: FontId,
230 default: FontId,
231 appearance: &Appearance,
232) -> Option<FontId> {
233 ui.push_id(label, |ui| {
234 let font_size = font_id.size;
235 let label_job = LayoutJob::simple(
236 font_id.family.to_string(),
237 font_id.clone(),
238 appearance.text_color,
239 0.0,
240 );
241 let mut changed = ui
242 .horizontal(|ui| {
243 ui.label(label);
244 let mut changed = egui::Slider::new(&mut font_id.size, 4.0..=40.0)
245 .max_decimals(1)
246 .ui(ui)
247 .changed();
248 if ui.button("Reset").clicked() {
249 font_id = default;
250 changed = true;
251 }
252 changed
253 })
254 .inner;
255 let family = &mut font_id.family;
256 changed |= egui::ComboBox::from_label("Font family")
257 .selected_text(label_job)
258 .width(font_size * 20.0)
259 .show_ui(ui, |ui| {
260 let mut result = false;
261 result |= ui
262 .selectable_value(family, FontFamily::Proportional, "Proportional (built-in)")
263 .changed();
264 result |= ui
265 .selectable_value(family, FontFamily::Monospace, "Monospace (built-in)")
266 .changed();
267 for family_name in &appearance.fonts.family_names {
268 result |= ui
269 .selectable_value(
270 family,
271 FontFamily::Name(Arc::from(family_name.as_str())),
272 family_name,
273 )
274 .changed();
275 }
276 result
277 })
278 .inner
279 .unwrap_or(false);
280 changed.then_some(font_id)
281 })
282 .inner
283}

Callers 1

appearance_windowFunction · 0.85

Calls 1

uiMethod · 0.80

Tested by

no test coverage detected