mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 10:18:11 +08:00
Improve the Data panel's data display with monospaced text and copyable number values (#4040)
* Improve the Data panel's data display with monospaced text and copyable number values * Revert attempted fix for dropdown menus appearing lower in scrolled Properties panel, since it makes other floating menus freeze the app * Code review
This commit is contained in:
@@ -362,6 +362,7 @@ pub struct TextAreaInput {
|
||||
pub value: String,
|
||||
pub label: Option<String>,
|
||||
pub disabled: bool,
|
||||
pub monospace: bool,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
|
||||
@@ -584,7 +584,7 @@ impl TableRowLayout for f64 {
|
||||
"Number (f64)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
let widgets = vec![NumberInput::new(Some(*self)).disabled(true).max_width(220).display_decimal_places(20).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
}
|
||||
}
|
||||
@@ -597,7 +597,7 @@ impl TableRowLayout for u32 {
|
||||
"Number (u32)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
let widgets = vec![NumberInput::new(Some(*self as f64)).disabled(true).max_width(220).display_decimal_places(20).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,8 @@ impl TableRowLayout for u64 {
|
||||
"Number (u64)".to_string()
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
// TODO: Make this robust for large u64 values that don't fit in f64 (above roughly 2^53). Perhaps using a bigint kind of approach through the widget's data flow.
|
||||
let widgets = vec![NumberInput::new(Some(*self as f64)).disabled(true).max_width(220).display_decimal_places(20).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
}
|
||||
}
|
||||
@@ -642,7 +643,7 @@ impl TableRowLayout for String {
|
||||
}
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_instance()];
|
||||
let widgets = vec![TextAreaInput::new(self.to_string()).monospace(true).disabled(true).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2355,7 +2355,12 @@ pub mod choice {
|
||||
.map(|(item, metadata)| {
|
||||
let updater = updater_factory();
|
||||
let committer = committer_factory();
|
||||
MenuListEntry::new(metadata.name).label(metadata.label).on_update(move |_| updater(item)).on_commit(committer)
|
||||
MenuListEntry::new(metadata.name)
|
||||
.label(metadata.label)
|
||||
.tooltip_label(metadata.label)
|
||||
.tooltip_description(metadata.description.unwrap_or_default())
|
||||
.on_update(move |_| updater(item))
|
||||
.on_commit(committer)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user