Use the minus character instead of "dash" (#3271)

* Use the minus character instead of "dash"

See https://github.com/rerun-io/rerun/issues/3053

* docstring

* fix
This commit is contained in:
Emil Ernerfeldt 2023-08-22 15:35:27 +02:00 committed by GitHub
parent 32a63da580
commit ec506c0a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 10 deletions

View File

@ -788,7 +788,7 @@ impl Key {
Key::ArrowLeft => "",
Key::ArrowRight => "",
Key::ArrowUp => "",
Key::Minus => "-",
Key::Minus => crate::MINUS_CHAR_STR,
Key::PlusEquals => "+",
_ => self.name(),
}

View File

@ -25,7 +25,7 @@
//! fn ui_counter(ui: &mut egui::Ui, counter: &mut i32) {
//! // Put the buttons and label on the same row:
//! ui.horizontal(|ui| {
//! if ui.button("-").clicked() {
//! if ui.button("").clicked() {
//! *counter -= 1;
//! }
//! ui.label(counter.to_string());
@ -467,6 +467,9 @@ macro_rules! egui_assert {
// ----------------------------------------------------------------------------
/// The minus character: <https://www.compart.com/en/unicode/U+2212>
pub(crate) const MINUS_CHAR_STR: &str = "";
/// The default egui fonts supports around 1216 emojis in total.
/// Here are some of the most useful:
/// ∞⊗⎗⎘⎙⏏⏴⏵⏶⏷

View File

@ -271,7 +271,7 @@ impl<'a> DragValue<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$b}", n as i64))
} else {
self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$b}", n.abs() as i64)
})
}
@ -306,7 +306,7 @@ impl<'a> DragValue<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$o}", n as i64))
} else {
self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$o}", n.abs() as i64)
})
}
@ -345,11 +345,11 @@ impl<'a> DragValue<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$x}", n as i64))
}
(false, true) => self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$X}", n.abs() as i64)
}),
(false, false) => self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$x}", n.abs() as i64)
}),
}

View File

@ -395,7 +395,7 @@ impl<'a> Slider<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$b}", n as i64))
} else {
self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$b}", n.abs() as i64)
})
}
@ -430,7 +430,7 @@ impl<'a> Slider<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$o}", n as i64))
} else {
self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$o}", n.abs() as i64)
})
}
@ -469,11 +469,11 @@ impl<'a> Slider<'a> {
self.custom_formatter(move |n, _| format!("{:0>min_width$x}", n as i64))
}
(false, true) => self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$X}", n.abs() as i64)
}),
(false, false) => self.custom_formatter(move |n, _| {
let sign = if n < 0.0 { "-" } else { "" };
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
format!("{sign}{:0>min_width$x}", n.abs() as i64)
}),
}