Skip to content

Commit

Permalink
Use the minus character instead of "dash" (#3271)
Browse files Browse the repository at this point in the history
* Use the minus character instead of "dash"

See rerun-io/rerun#3053

* docstring

* fix
  • Loading branch information
emilk authored Aug 22, 2023
1 parent 32a63da commit ec506c0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ impl Key {
Key::ArrowLeft => "⏴",
Key::ArrowRight => "⏵",
Key::ArrowUp => "⏶",
Key::Minus => "-",
Key::Minus => crate::MINUS_CHAR_STR,
Key::PlusEquals => "+",
_ => self.name(),
}
Expand Down
5 changes: 4 additions & 1 deletion crates/egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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:
/// ∞⊗⎗⎘⎙⏏⏴⏵⏶⏷
Expand Down
8 changes: 4 additions & 4 deletions crates/egui/src/widgets/drag_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
}),
}
Expand Down
8 changes: 4 additions & 4 deletions crates/egui/src/widgets/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
})
}
Expand Down Expand Up @@ -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)
}),
}
Expand Down

0 comments on commit ec506c0

Please sign in to comment.