forked from 1b-agent/opencadstudio-upstream
Ribbon key tips: Alt shows codes on tabs, buttons and menu items
A lone Alt shows a code on every ribbon tab and quick-access button. Typing a tab code opens the tab and shows the codes of its buttons, dropdowns, slide-outs and collapsed panels; a button code runs it, a dropdown or slide-out code opens it and shows its item codes, Esc goes back one level. Codes follow the reference ribbon; buttons without a reference counterpart get none and unnamed menu items are numbered. Codes are drawn as accent pills over the widgets that reported their bounds in the current frame, with a hint bar under the ribbon. While the tips are open keys go to them only. The automation gets a keytips action and read operation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
592289f4fd
commit
86429bf439
34 files changed
+1569
-53
No files matched your search
@@ -6501,3 +6501,10 @@ ref-edit =
|
|||||||
.redefined = تمت إعادة تعريف __ocs_fmt_0__.
|
.redefined = تمت إعادة تعريف __ocs_fmt_0__.
|
||||||
.ok = موافق
|
.ok = موافق
|
||||||
.nested = متداخلة
|
.nested = متداخلة
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ е предефиниран.
|
.redefined = __ocs_fmt_0__ е предефиниран.
|
||||||
.ok = Ок
|
.ok = Ок
|
||||||
.nested = Вложени
|
.nested = Вложени
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6486,3 +6486,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ předefinován.
|
.redefined = __ocs_fmt_0__ předefinován.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Vnořené
|
.nested = Vnořené
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6487,3 +6487,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ neu definiert.
|
.redefined = __ocs_fmt_0__ neu definiert.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Verschachtelt
|
.nested = Verschachtelt
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = Το __ocs_fmt_0__ επαναορίστηκε.
|
.redefined = Το __ocs_fmt_0__ επαναορίστηκε.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Ένθετα
|
.nested = Ένθετα
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6488,3 +6488,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ redefined.
|
.redefined = __ocs_fmt_0__ redefined.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Nested
|
.nested = Nested
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ redefinido.
|
.redefined = __ocs_fmt_0__ redefinido.
|
||||||
.ok = Aceptar
|
.ok = Aceptar
|
||||||
.nested = Anidados
|
.nested = Anidados
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6486,3 +6486,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ määritetty uudelleen.
|
.redefined = __ocs_fmt_0__ määritetty uudelleen.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Sisäkkäiset
|
.nested = Sisäkkäiset
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ redéfini.
|
.redefined = __ocs_fmt_0__ redéfini.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Imbriqués
|
.nested = Imbriqués
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6477,3 +6477,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ पुनः परिभाषित किया गया।
|
.redefined = __ocs_fmt_0__ पुनः परिभाषित किया गया।
|
||||||
.ok = ठीक
|
.ok = ठीक
|
||||||
.nested = नेस्टेड
|
.nested = नेस्टेड
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6473,3 +6473,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ újradefiniálva.
|
.redefined = __ocs_fmt_0__ újradefiniálva.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Beágyazott
|
.nested = Beágyazott
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6488,3 +6488,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ ridefinito.
|
.redefined = __ocs_fmt_0__ ridefinito.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Nidificati
|
.nested = Nidificati
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6477,3 +6477,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ を再定義しました。
|
.redefined = __ocs_fmt_0__ を再定義しました。
|
||||||
.ok = OK
|
.ok = OK
|
||||||
.nested = ネスト
|
.nested = ネスト
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6488,3 +6488,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__이(가) 재정의되었습니다.
|
.redefined = __ocs_fmt_0__이(가) 재정의되었습니다.
|
||||||
.ok = 확인
|
.ok = 확인
|
||||||
.nested = 내포
|
.nested = 내포
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = ນິຍາມ __ocs_fmt_0__ ໃໝ່ແລ້ວ.
|
.redefined = ນິຍາມ __ocs_fmt_0__ ໃໝ່ແລ້ວ.
|
||||||
.ok = ຕົກລົງ
|
.ok = ຕົກລົງ
|
||||||
.nested = ຊ້ອນ
|
.nested = ຊ້ອນ
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6487,3 +6487,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ opnieuw gedefinieerd.
|
.redefined = __ocs_fmt_0__ opnieuw gedefinieerd.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Genest
|
.nested = Genest
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6488,3 +6488,10 @@ ref-edit =
|
|||||||
.redefined = Przedefiniowano __ocs_fmt_0__.
|
.redefined = Przedefiniowano __ocs_fmt_0__.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Zagnieżdżone
|
.nested = Zagnieżdżone
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6489,3 +6489,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ redefinido.
|
.redefined = __ocs_fmt_0__ redefinido.
|
||||||
.ok = Ok
|
.ok = Ok
|
||||||
.nested = Aninhados
|
.nested = Aninhados
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6490,3 +6490,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ переопределен.
|
.redefined = __ocs_fmt_0__ переопределен.
|
||||||
.ok = Ок
|
.ok = Ок
|
||||||
.nested = Вложенные
|
.nested = Вложенные
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6410,3 +6410,10 @@ ref-edit =
|
|||||||
.redefined = __ocs_fmt_0__ yeniden tanımlandı.
|
.redefined = __ocs_fmt_0__ yeniden tanımlandı.
|
||||||
.ok = Tamam
|
.ok = Tamam
|
||||||
.nested = İç içe
|
.nested = İç içe
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Yazılan: { $path }
|
||||||
|
.hint-tabs = Sekme harfini yazın · Esc kapatır
|
||||||
|
.hint-tab = { $tab } sekmesi · Esc bir düzey geri
|
||||||
|
.hint-items = Öğe harfini yazın · Esc bir düzey geri
|
||||||
@@ -6472,3 +6472,10 @@ ref-edit =
|
|||||||
.redefined = 已重定义 __ocs_fmt_0__。
|
.redefined = 已重定义 __ocs_fmt_0__。
|
||||||
.ok = 确定
|
.ok = 确定
|
||||||
.nested = 嵌套
|
.nested = 嵌套
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -6484,3 +6484,10 @@ ref-edit =
|
|||||||
.redefined = 已重新定義 __ocs_fmt_0__。
|
.redefined = 已重新定義 __ocs_fmt_0__。
|
||||||
.ok = 確定
|
.ok = 確定
|
||||||
.nested = 巢狀
|
.nested = 巢狀
|
||||||
|
|
||||||
|
keytips =
|
||||||
|
.title = KeyTip
|
||||||
|
.typed = Typed: { $path }
|
||||||
|
.hint-tabs = Type a tab letter · Esc closes
|
||||||
|
.hint-tab = { $tab } tab · Esc goes back one level
|
||||||
|
.hint-items = Type an item letter · Esc goes back one level
|
||||||
@@ -114,6 +114,7 @@ pub(super) const NAMES: &[&str] = &[
|
|||||||
"pc_section",
|
"pc_section",
|
||||||
"ribbon_tab",
|
"ribbon_tab",
|
||||||
"ribbon_dropdown",
|
"ribbon_dropdown",
|
||||||
|
"keytips",
|
||||||
"dialog_ok",
|
"dialog_ok",
|
||||||
"attdef_dialog",
|
"attdef_dialog",
|
||||||
"field_dialog",
|
"field_dialog",
|
||||||
@@ -1884,6 +1885,28 @@ impl OpenCADStudio {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
"ribbon_dropdown" => Message::ToggleRibbonDropdown(string(req, "value")?.into()),
|
"ribbon_dropdown" => Message::ToggleRibbonDropdown(string(req, "value")?.into()),
|
||||||
|
// Ribbon key tips: `show`, `alt` (a lone Alt), `type:<codes>`, `enter`,
|
||||||
|
// `esc` or `hide`. Read them back with the `keytips` read operation.
|
||||||
|
"keytips" => {
|
||||||
|
use crate::ui::ribbon::KeyTipInput as K;
|
||||||
|
let value = string(req, "value")?;
|
||||||
|
let inputs: Vec<K> = match value {
|
||||||
|
"show" => vec![K::Open { refocus: false }],
|
||||||
|
"alt" => vec![K::AltTap],
|
||||||
|
"esc" => vec![K::Escape],
|
||||||
|
"hide" => vec![K::Hide],
|
||||||
|
"enter" => vec![K::Enter],
|
||||||
|
_ => match value.strip_prefix("type:") {
|
||||||
|
Some(codes) if !codes.is_empty() => codes
|
||||||
|
.chars()
|
||||||
|
.map(|ch| K::Char(ch.to_uppercase().collect()))
|
||||||
|
.collect(),
|
||||||
|
_ => return Err(failure("invalid_value", "Use show, alt, type:<codes>, enter, esc or hide")),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let tasks: Vec<_> = inputs.into_iter().map(|input| self.on_keytip(input)).collect();
|
||||||
|
return Ok(Task::batch(tasks));
|
||||||
|
}
|
||||||
// The -VIEW Background dialog, one field per call: "type=gradient",
|
// The -VIEW Background dialog, one field per call: "type=gradient",
|
||||||
// "color|top|middle|bottom=r,g,b", "three=1", "rotation=30",
|
// "color|top|middle|bottom=r,g,b", "three=1", "rotation=30",
|
||||||
// "image=<path>", "position=center|stretch|tile", "aspect=1", "offset=x,y" (pixels), "scale=x,y",
|
// "image=<path>", "position=center|stretch|tile", "aspect=1", "offset=x,y" (pixels), "scale=x,y",
|
||||||
|
|||||||
@@ -559,6 +559,7 @@ impl OpenCADStudio {
|
|||||||
| "audit"
|
| "audit"
|
||||||
| "text_search"
|
| "text_search"
|
||||||
| "text_audit"
|
| "text_audit"
|
||||||
|
| "keytips"
|
||||||
);
|
);
|
||||||
if !query && !self.control.enabled {
|
if !query && !self.control.enabled {
|
||||||
return (
|
return (
|
||||||
@@ -850,6 +851,7 @@ impl OpenCADStudio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"grips" => self.control_grips(),
|
"grips" => self.control_grips(),
|
||||||
|
"keytips" => self.ribbon.keytips_json(req["detail"].as_str() == Some("full")),
|
||||||
"xdata_get" => self.xdata_read(&req),
|
"xdata_get" => self.xdata_read(&req),
|
||||||
"get_selection" => self.control_get_selection(),
|
"get_selection" => self.control_get_selection(),
|
||||||
"text_search" => self.control_text_search(&req).unwrap_or_else(|e| e),
|
"text_search" => self.control_text_search(&req).unwrap_or_else(|e| e),
|
||||||
|
|||||||
@@ -2754,6 +2754,8 @@ pub enum Message {
|
|||||||
SetProjection(bool),
|
SetProjection(bool),
|
||||||
/// Select a ribbon module tab by index.
|
/// Select a ribbon module tab by index.
|
||||||
RibbonSelectTab(usize),
|
RibbonSelectTab(usize),
|
||||||
|
/// Ribbon key tips: Alt, typed codes and Esc.
|
||||||
|
KeyTip(crate::ui::ribbon::KeyTipInput),
|
||||||
/// Change the ribbon tool-panel density (persisted).
|
/// Change the ribbon tool-panel density (persisted).
|
||||||
SetRibbonCollapseMode(crate::ui::ribbon::CollapseMode),
|
SetRibbonCollapseMode(crate::ui::ribbon::CollapseMode),
|
||||||
/// A ribbon tool button was clicked — highlights the tool and dispatches its event.
|
/// A ribbon tool button was clicked — highlights the tool and dispatches its event.
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
//! Ribbon key tips: a lone Alt opens them, typed codes walk the ribbon and
|
||||||
|
//! Esc goes back one level.
|
||||||
|
|
||||||
|
use iced::Task;
|
||||||
|
|
||||||
|
use crate::app::{Message, OpenCADStudio};
|
||||||
|
use crate::ui::ribbon::{KeyTipInput, KeyTipStep};
|
||||||
|
|
||||||
|
impl OpenCADStudio {
|
||||||
|
pub(in crate::app) fn on_keytip(&mut self, input: KeyTipInput) -> Task<Message> {
|
||||||
|
match input {
|
||||||
|
KeyTipInput::AltTap if self.ribbon.keytips_active() => self.hide_keytips(),
|
||||||
|
KeyTipInput::AltTap => {
|
||||||
|
if self.active_modal.is_some() || self.clean_screen || self.ribbon_closed {
|
||||||
|
return Task::none();
|
||||||
|
}
|
||||||
|
// A focused field other than the command line keeps Alt.
|
||||||
|
iced::advanced::widget::operate(
|
||||||
|
iced::advanced::widget::operation::focusable::count(),
|
||||||
|
)
|
||||||
|
.then(|count| {
|
||||||
|
if count.focused.is_none() {
|
||||||
|
return Task::done(Message::KeyTip(KeyTipInput::Open { refocus: false }));
|
||||||
|
}
|
||||||
|
iced::widget::operation::is_focused(iced::widget::Id::new(
|
||||||
|
crate::ui::command_line::CMD_INPUT_ID,
|
||||||
|
))
|
||||||
|
.map(|command_line| {
|
||||||
|
if command_line {
|
||||||
|
Message::KeyTip(KeyTipInput::Open { refocus: true })
|
||||||
|
} else {
|
||||||
|
Message::Noop
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
KeyTipInput::Open { refocus } => {
|
||||||
|
self.ribbon.show_keytips(refocus);
|
||||||
|
// Typed codes must not reach the command line.
|
||||||
|
if refocus {
|
||||||
|
self.unfocus_widgets()
|
||||||
|
} else {
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeyTipInput::Hide => self.hide_keytips(),
|
||||||
|
KeyTipInput::Escape => {
|
||||||
|
if self.ribbon.keytip_escape() {
|
||||||
|
Task::none()
|
||||||
|
} else {
|
||||||
|
self.hide_keytips()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeyTipInput::Char(_) | KeyTipInput::Enter => {
|
||||||
|
let ch = match &input {
|
||||||
|
KeyTipInput::Char(ch) => Some(ch.as_str()),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
match self.ribbon.keytip_type(ch) {
|
||||||
|
KeyTipStep::Ignore | KeyTipStep::Stay => Task::none(),
|
||||||
|
KeyTipStep::Open(message) => self.update(message),
|
||||||
|
KeyTipStep::Run(message) => {
|
||||||
|
let refocus = self.hide_keytips();
|
||||||
|
Task::batch([refocus, self.update(message)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close the key tips, returning the focus to the command line if it had
|
||||||
|
/// it.
|
||||||
|
pub(in crate::app) fn hide_keytips(&mut self) -> Task<Message> {
|
||||||
|
if self.ribbon.hide_keytips() {
|
||||||
|
self.focus_cmd_input()
|
||||||
|
} else {
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -102,6 +102,7 @@ mod dialog;
|
|||||||
mod dynamic;
|
mod dynamic;
|
||||||
mod file;
|
mod file;
|
||||||
mod graphic_attributes;
|
mod graphic_attributes;
|
||||||
|
mod keytips;
|
||||||
pub(in crate::app) use file::background_task;
|
pub(in crate::app) use file::background_task;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub(in crate::app) use file::native_paths_match;
|
pub(in crate::app) use file::native_paths_match;
|
||||||
@@ -621,6 +622,10 @@ impl OpenCADStudio {
|
|||||||
if Some(id) == self.main_window {
|
if Some(id) == self.main_window {
|
||||||
self.spacemouse_focused = focused;
|
self.spacemouse_focused = focused;
|
||||||
}
|
}
|
||||||
|
// Key tips close when the window loses the focus.
|
||||||
|
if !focused && self.ribbon.keytips_active() {
|
||||||
|
return self.hide_keytips();
|
||||||
|
}
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
Message::SpaceMouseEnabled(enabled) => {
|
Message::SpaceMouseEnabled(enabled) => {
|
||||||
@@ -2277,6 +2282,7 @@ impl OpenCADStudio {
|
|||||||
Message::PcManager(message) => self.update_pc_manager(message),
|
Message::PcManager(message) => self.update_pc_manager(message),
|
||||||
Message::Count(message) => self.on_count(message),
|
Message::Count(message) => self.on_count(message),
|
||||||
Message::SheetSet(message) => self.on_sheet_set(message),
|
Message::SheetSet(message) => self.on_sheet_set(message),
|
||||||
|
Message::KeyTip(input) => self.on_keytip(input),
|
||||||
Message::RibbonSelectTab(idx) => {
|
Message::RibbonSelectTab(idx) => {
|
||||||
self.ribbon.select(idx);
|
self.ribbon.select(idx);
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|||||||
+30
-1
@@ -2252,12 +2252,23 @@ bg={bg_ms:.1}ms n={view_count}"
|
|||||||
iced::widget::Space::new().width(0).height(0).into()
|
iced::widget::Space::new().width(0).height(0).into()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Key tips: the hint bar under the dropdowns, the codes above all.
|
||||||
|
let (keytip_bar, keytip_layer): (Element<'_, Message>, Element<'_, Message>) =
|
||||||
|
self.ribbon.keytip_layers().unwrap_or_else(|| {
|
||||||
|
(
|
||||||
|
iced::widget::Space::new().width(0).height(0).into(),
|
||||||
|
iced::widget::Space::new().width(0).height(0).into(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let composed = stack![
|
let composed = stack![
|
||||||
main_ui,
|
main_ui,
|
||||||
|
keytip_bar,
|
||||||
dropdown_layer,
|
dropdown_layer,
|
||||||
qselect_layer,
|
qselect_layer,
|
||||||
snap_override_layer,
|
snap_override_layer,
|
||||||
open_progress_layer,
|
open_progress_layer,
|
||||||
|
keytip_layer,
|
||||||
];
|
];
|
||||||
|
|
||||||
// If the Plot Style editor was launched from PLOT, keep the Plot dialog
|
// If the Plot Style editor was launched from PLOT, keep the Plot dialog
|
||||||
@@ -2547,9 +2558,18 @@ impl OpenCADStudio {
|
|||||||
event::listen_with(|ev, status, win_id| {
|
event::listen_with(|ev, status, win_id| {
|
||||||
use iced::event::Status;
|
use iced::event::Status;
|
||||||
match ev {
|
match ev {
|
||||||
|
iced::Event::Mouse(iced::mouse::Event::ButtonPressed(_))
|
||||||
|
if crate::ui::ribbon::keytips_active() =>
|
||||||
|
{
|
||||||
|
crate::ui::ribbon::keytip_pointer_pressed();
|
||||||
|
Some(Message::KeyTip(crate::ui::ribbon::KeyTipInput::Hide))
|
||||||
|
}
|
||||||
iced::Event::Mouse(iced::mouse::Event::ButtonPressed(
|
iced::Event::Mouse(iced::mouse::Event::ButtonPressed(
|
||||||
iced::mouse::Button::Left,
|
iced::mouse::Button::Left,
|
||||||
)) => Some(Message::PropPointerPressed),
|
)) => {
|
||||||
|
crate::ui::ribbon::keytip_pointer_pressed();
|
||||||
|
Some(Message::PropPointerPressed)
|
||||||
|
}
|
||||||
iced::Event::Window(window::Event::CloseRequested) => {
|
iced::Event::Window(window::Event::CloseRequested) => {
|
||||||
Some(Message::WindowCloseRequested(win_id))
|
Some(Message::WindowCloseRequested(win_id))
|
||||||
}
|
}
|
||||||
@@ -2562,6 +2582,9 @@ impl OpenCADStudio {
|
|||||||
iced::Event::Window(window::Event::FileDropped(path)) => {
|
iced::Event::Window(window::Event::FileDropped(path)) => {
|
||||||
Some(Message::FileDropped(path))
|
Some(Message::FileDropped(path))
|
||||||
}
|
}
|
||||||
|
iced::Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
||||||
|
crate::ui::ribbon::keytip_key_released(&key)
|
||||||
|
}
|
||||||
iced::Event::Keyboard(keyboard::Event::ModifiersChanged(m)) => {
|
iced::Event::Keyboard(keyboard::Event::ModifiersChanged(m)) => {
|
||||||
// `command()` is Cmd on macOS, Ctrl elsewhere — the
|
// `command()` is Cmd on macOS, Ctrl elsewhere — the
|
||||||
// platform multi-select modifier for the layer list.
|
// platform multi-select modifier for the layer list.
|
||||||
@@ -2575,8 +2598,14 @@ impl OpenCADStudio {
|
|||||||
physical_key,
|
physical_key,
|
||||||
modifiers,
|
modifiers,
|
||||||
text,
|
text,
|
||||||
|
repeat,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
|
if let Some(keytip) =
|
||||||
|
crate::ui::ribbon::keytip_key_pressed(&key, modifiers, repeat)
|
||||||
|
{
|
||||||
|
return keytip;
|
||||||
|
}
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
let accel = modifiers.command();
|
let accel = modifiers.command();
|
||||||
// AltGr reaches Windows apps as Ctrl+Alt, and a macOS
|
// AltGr reaches Windows apps as Ctrl+Alt, and a macOS
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const READ_OPS: &[&str] = &[
|
|||||||
"audit",
|
"audit",
|
||||||
"text_search",
|
"text_search",
|
||||||
"text_audit",
|
"text_audit",
|
||||||
|
"keytips",
|
||||||
"capture",
|
"capture",
|
||||||
];
|
];
|
||||||
const EXECUTE_OPS: &[&str] = &[
|
const EXECUTE_OPS: &[&str] = &[
|
||||||
|
|||||||
+49
-15
@@ -9,7 +9,7 @@ use super::widgets::{
|
|||||||
make_icon, make_tip, muted_text_style, popup_panel_style, popup_row_style, tip_style,
|
make_icon, make_tip, muted_text_style, popup_panel_style, popup_row_style, tip_style,
|
||||||
tool_btn_style, LARGE_DROPDOWN_ARROW_SIZE,
|
tool_btn_style, LARGE_DROPDOWN_ARROW_SIZE,
|
||||||
};
|
};
|
||||||
use super::{dropdown_backdrop, position_ribbon_dropdown, Ribbon};
|
use super::{dropdown_backdrop, keytips, position_ribbon_dropdown, Ribbon};
|
||||||
use crate::app::Message;
|
use crate::app::Message;
|
||||||
use crate::modules::IconKind;
|
use crate::modules::IconKind;
|
||||||
use crate::t;
|
use crate::t;
|
||||||
@@ -248,6 +248,32 @@ fn panel_for_group(title: &str, group_ids: &[&'static str]) -> Option<Panel> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The slide-out under the group `title`, if it has one.
|
||||||
|
pub(super) fn slide_out_id(title: &str, group_ids: &[&'static str]) -> Option<&'static str> {
|
||||||
|
panel_for_group(title, group_ids).map(|panel| panel.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the open slide-out or tool submenu `id` offers, as (dropdown id,
|
||||||
|
/// command, opens a submenu) in display order.
|
||||||
|
pub(super) fn keytip_items(id: &str) -> Vec<(&'static str, &'static str, bool)> {
|
||||||
|
let Some(panel) = panel_for_dropdown(id) else {
|
||||||
|
return Vec::new();
|
||||||
|
};
|
||||||
|
if panel.id == id {
|
||||||
|
return panel
|
||||||
|
.tools
|
||||||
|
.iter()
|
||||||
|
.map(|tool| (panel.id, tool.command, !tool.options.is_empty()))
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
|
panel
|
||||||
|
.tools
|
||||||
|
.iter()
|
||||||
|
.filter(|tool| tool.command == id)
|
||||||
|
.flat_map(|tool| tool.options.iter().map(|(cmd, _)| (tool.command, *cmd, false)))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Every command the slide-out of the group `title` offers: each tool and
|
/// Every command the slide-out of the group `title` offers: each tool and
|
||||||
/// each of its submenu options.
|
/// each of its submenu options.
|
||||||
pub(super) fn slide_out_commands(
|
pub(super) fn slide_out_commands(
|
||||||
@@ -337,6 +363,7 @@ pub(super) fn group_title<'a>(
|
|||||||
.delay(Duration::from_millis(400))
|
.delay(Duration::from_millis(400))
|
||||||
.style(tip_style);
|
.style(tip_style);
|
||||||
// Shrink-sized: a Fill here would make the panel claim the whole row.
|
// Shrink-sized: a Fill here would make the panel claim the whole row.
|
||||||
|
let launcher = keytips::anchor(keytips::XREF_LAUNCHER, launcher);
|
||||||
row![title_button, launcher]
|
row![title_button, launcher]
|
||||||
.spacing(6)
|
.spacing(6)
|
||||||
.align_y(iced::Center)
|
.align_y(iced::Center)
|
||||||
@@ -362,6 +389,7 @@ fn tool_button(tool: &Tool, active: bool, panel_id: &'static str) -> Element<'st
|
|||||||
.delay(Duration::from_millis(400))
|
.delay(Duration::from_millis(400))
|
||||||
.style(tip_style)
|
.style(tip_style)
|
||||||
.into();
|
.into();
|
||||||
|
let face = keytips::anchor_with(|| keytips::item_anchor(panel_id, tool.command), face);
|
||||||
if !tool.options.is_empty() {
|
if !tool.options.is_empty() {
|
||||||
row![
|
row![
|
||||||
face,
|
face,
|
||||||
@@ -401,6 +429,7 @@ fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Elem
|
|||||||
.style(popup_row_style)
|
.style(popup_row_style)
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.padding([3, 6]);
|
.padding([3, 6]);
|
||||||
|
let edit = keytips::anchor_with(|| keytips::item_anchor(panel.id, tool.command), edit);
|
||||||
let fade = ribbon.xref_fade;
|
let fade = ribbon.xref_fade;
|
||||||
let on = fade > 0;
|
let on = fade > 0;
|
||||||
let switch = button(make_icon(
|
let switch = button(make_icon(
|
||||||
@@ -411,18 +440,23 @@ fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Elem
|
|||||||
.style(move |theme: &Theme, status| tool_btn_style(theme, on, status))
|
.style(move |theme: &Theme, status| tool_btn_style(theme, on, status))
|
||||||
.padding(3);
|
.padding(3);
|
||||||
let amount = fade.unsigned_abs().min(90) as u8;
|
let amount = fade.unsigned_abs().min(90) as u8;
|
||||||
|
let switch = tooltip(
|
||||||
|
switch,
|
||||||
|
make_tip(format!(
|
||||||
|
"{}\n{} XDWGFADECTL",
|
||||||
|
t!("Xref fading"),
|
||||||
|
t!("Command:")
|
||||||
|
)),
|
||||||
|
tooltip::Position::Bottom,
|
||||||
|
)
|
||||||
|
.delay(Duration::from_millis(400))
|
||||||
|
.style(tip_style);
|
||||||
|
let switch = keytips::anchor_with(
|
||||||
|
|| keytips::item_anchor(panel.id, keytips::XREF_FADE),
|
||||||
|
switch,
|
||||||
|
);
|
||||||
let fading = row![
|
let fading = row![
|
||||||
tooltip(
|
switch,
|
||||||
switch,
|
|
||||||
make_tip(format!(
|
|
||||||
"{}\n{} XDWGFADECTL",
|
|
||||||
t!("Xref fading"),
|
|
||||||
t!("Command:")
|
|
||||||
)),
|
|
||||||
tooltip::Position::Bottom
|
|
||||||
)
|
|
||||||
.delay(Duration::from_millis(400))
|
|
||||||
.style(tip_style),
|
|
||||||
text(t!("Xref fading")).size(11),
|
text(t!("Xref fading")).size(11),
|
||||||
iced::widget::slider(0..=90u8, amount, Message::XrefFadeSlide)
|
iced::widget::slider(0..=90u8, amount, Message::XrefFadeSlide)
|
||||||
.on_release(Message::XrefFadeCommit)
|
.on_release(Message::XrefFadeCommit)
|
||||||
@@ -468,7 +502,7 @@ pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element
|
|||||||
tool.options
|
tool.options
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(cmd, label)| {
|
.map(|&(cmd, label)| {
|
||||||
button(text(t!(label)).size(11))
|
let item = button(text(t!(label)).size(11))
|
||||||
.on_press(Message::DropdownSelectItem {
|
.on_press(Message::DropdownSelectItem {
|
||||||
dropdown_id: tool.command,
|
dropdown_id: tool.command,
|
||||||
cmd,
|
cmd,
|
||||||
@@ -476,8 +510,8 @@ pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element
|
|||||||
.style(popup_row_style)
|
.style(popup_row_style)
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.height(OPTION_HEIGHT)
|
.height(OPTION_HEIGHT)
|
||||||
.padding([3, 7])
|
.padding([3, 7]);
|
||||||
.into()
|
keytips::anchor_with(|| keytips::item_anchor(tool.command, cmd), item)
|
||||||
})
|
})
|
||||||
.collect::<Vec<Element<'static, Message>>>(),
|
.collect::<Vec<Element<'static, Message>>>(),
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+22
-7
@@ -31,6 +31,12 @@ use widgets::{StyleContext, *};
|
|||||||
pub(crate) use widgets::{REDO_HISTORY_ID, UNDO_HISTORY_ID};
|
pub(crate) use widgets::{REDO_HISTORY_ID, UNDO_HISTORY_ID};
|
||||||
mod collapse;
|
mod collapse;
|
||||||
mod locate;
|
mod locate;
|
||||||
|
mod keytips;
|
||||||
|
pub use keytips::{
|
||||||
|
active as keytips_active, key_pressed as keytip_key_pressed,
|
||||||
|
key_released as keytip_key_released, pointer_pressed as keytip_pointer_pressed, KeyTipInput,
|
||||||
|
KeyTipStep,
|
||||||
|
};
|
||||||
use crate::t;
|
use crate::t;
|
||||||
use crate::ui::wrap_bar::{PosReport, WrapBar, WrapFlow};
|
use crate::ui::wrap_bar::{PosReport, WrapBar, WrapFlow};
|
||||||
pub use collapse::CollapseMode;
|
pub use collapse::CollapseMode;
|
||||||
@@ -122,6 +128,8 @@ pub struct Ribbon {
|
|||||||
block_editing: Option<usize>,
|
block_editing: Option<usize>,
|
||||||
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
|
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
|
||||||
pub xref_fade: i32,
|
pub xref_fade: i32,
|
||||||
|
/// Open key tips (Alt).
|
||||||
|
keytips: Option<keytips::State>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per-layer display data shown in the ribbon layer dropdown.
|
/// Per-layer display data shown in the ribbon layer dropdown.
|
||||||
@@ -224,6 +232,7 @@ impl Ribbon {
|
|||||||
point_cloud_ctx: None,
|
point_cloud_ctx: None,
|
||||||
block_editing: None,
|
block_editing: None,
|
||||||
xref_fade: 50,
|
xref_fade: 50,
|
||||||
|
keytips: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +671,7 @@ impl Ribbon {
|
|||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
acc.push(btn.into());
|
acc.push(keytips::anchor_with(|| format!("tab:{}", module.id()), btn));
|
||||||
acc
|
acc
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -800,7 +809,7 @@ impl Ribbon {
|
|||||||
tool_bar
|
tool_bar
|
||||||
};
|
};
|
||||||
|
|
||||||
column![tab_bar, tool_bar].into()
|
keytips::ribbon_area(column![tab_bar, tool_bar])
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Dropdown overlay ──────────────────────────────────────────────────
|
// ── Dropdown overlay ──────────────────────────────────────────────────
|
||||||
@@ -971,7 +980,7 @@ impl Ribbon {
|
|||||||
.then_some(theme.palette().background.base.text.scale_alpha(0.72)),
|
.then_some(theme.palette().background.base.text.scale_alpha(0.72)),
|
||||||
});
|
});
|
||||||
|
|
||||||
button(
|
let item = button(
|
||||||
row![checkmark, icon_el, label_el]
|
row![checkmark, icon_el, label_el]
|
||||||
.spacing(4)
|
.spacing(4)
|
||||||
.align_y(iced::Center),
|
.align_y(iced::Center),
|
||||||
@@ -982,8 +991,8 @@ impl Ribbon {
|
|||||||
}))
|
}))
|
||||||
.style(popup_row_style)
|
.style(popup_row_style)
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.padding([4, 10])
|
.padding([4, 10]);
|
||||||
.into()
|
keytips::anchor_with(|| keytips::item_anchor(dd_id, cmd), item)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -1571,7 +1580,10 @@ fn collapse_button<'a>(
|
|||||||
.style(opener_style(holds))
|
.style(opener_style(holds))
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.padding([3, 5]);
|
.padding([3, 5]);
|
||||||
return automatic_large_button(localized_title, content.into());
|
return keytips::anchor_with(
|
||||||
|
|| keytips::collapsed_anchor(title),
|
||||||
|
automatic_large_button(localized_title, content.into()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapsed (not yet tight): a large representative-tool face — a live button
|
// Collapsed (not yet tight): a large representative-tool face — a live button
|
||||||
@@ -1636,7 +1648,10 @@ fn collapse_button<'a>(
|
|||||||
.style(opener_style(holds && !face_lit))
|
.style(opener_style(holds && !face_lit))
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.padding([1, 4]);
|
.padding([1, 4]);
|
||||||
let opener = automatic_large_button(localized_title, opener.into());
|
let opener = keytips::anchor_with(
|
||||||
|
|| keytips::collapsed_anchor(title),
|
||||||
|
automatic_large_button(localized_title, opener.into()),
|
||||||
|
);
|
||||||
|
|
||||||
// The large face fills a fixed slot so a collapsed panel is shorter than a full
|
// The large face fills a fixed slot so a collapsed panel is shorter than a full
|
||||||
// 3-row panel, letting `CollapsePanels` shrink the ribbon row.
|
// 3-row panel, letting `CollapsePanels` shrink the ribbon row.
|
||||||
|
|||||||
+34
-26
@@ -543,11 +543,13 @@ pub(super) fn render_small<'a>(
|
|||||||
.width(Length::Fixed(SMALL_W))
|
.width(Length::Fixed(SMALL_W))
|
||||||
.height(ROW_H)
|
.height(ROW_H)
|
||||||
.padding([4, 4]);
|
.padding([4, 4]);
|
||||||
tooltip(btn, make_tip(tip_text), TipPos::Right)
|
super::keytips::anchor(
|
||||||
.gap(6.0)
|
t.id,
|
||||||
.delay(Duration::from_millis(400))
|
tooltip(btn, make_tip(tip_text), TipPos::Right)
|
||||||
.style(tip_style)
|
.gap(6.0)
|
||||||
.into()
|
.delay(Duration::from_millis(400))
|
||||||
|
.style(tip_style),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RibbonItem::LabeledTool(t) => {
|
RibbonItem::LabeledTool(t) => {
|
||||||
@@ -568,11 +570,13 @@ pub(super) fn render_small<'a>(
|
|||||||
.width(Length::Fixed(LABELED_SMALL_W + ARROW_W))
|
.width(Length::Fixed(LABELED_SMALL_W + ARROW_W))
|
||||||
.height(ROW_H)
|
.height(ROW_H)
|
||||||
.padding([3, 4]);
|
.padding([3, 4]);
|
||||||
tooltip(btn, make_tip(tip_text), TipPos::Right)
|
super::keytips::anchor(
|
||||||
.gap(6.0)
|
t.id,
|
||||||
.delay(Duration::from_millis(400))
|
tooltip(btn, make_tip(tip_text), TipPos::Right)
|
||||||
.style(tip_style)
|
.gap(6.0)
|
||||||
.into()
|
.delay(Duration::from_millis(400))
|
||||||
|
.style(tip_style),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RibbonItem::Dropdown {
|
RibbonItem::Dropdown {
|
||||||
@@ -895,7 +899,7 @@ fn tool_row<'a>(tools: &[ToolDef], active_tool: &Option<String>) -> Element<'a,
|
|||||||
let event = t.event.clone();
|
let event = t.event.clone();
|
||||||
let icon_el: Element<Message> = make_icon(t.icon, 16.0);
|
let icon_el: Element<Message> = make_icon(t.icon, 16.0);
|
||||||
let msg = module_event_to_message(event);
|
let msg = module_event_to_message(event);
|
||||||
tooltip(
|
let btn = tooltip(
|
||||||
button(icon_el)
|
button(icon_el)
|
||||||
.on_press(msg)
|
.on_press(msg)
|
||||||
.style(move |theme: &Theme, status| tool_btn_style(theme, is_active, status))
|
.style(move |theme: &Theme, status| tool_btn_style(theme, is_active, status))
|
||||||
@@ -905,8 +909,8 @@ fn tool_row<'a>(tools: &[ToolDef], active_tool: &Option<String>) -> Element<'a,
|
|||||||
)
|
)
|
||||||
.gap(4.0)
|
.gap(4.0)
|
||||||
.delay(Duration::from_millis(400))
|
.delay(Duration::from_millis(400))
|
||||||
.style(tip_style)
|
.style(tip_style);
|
||||||
.into()
|
super::keytips::anchor(t.id, btn)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
row(btns).spacing(2).align_y(iced::Center).into()
|
row(btns).spacing(2).align_y(iced::Center).into()
|
||||||
@@ -974,15 +978,17 @@ pub(super) fn render_large<'a>(item: &RibbonItem, ctx: &RenderCtx<'_>) -> Elemen
|
|||||||
bottom: 4.0,
|
bottom: 4.0,
|
||||||
left: 4.0,
|
left: 4.0,
|
||||||
});
|
});
|
||||||
tooltip(
|
super::keytips::anchor(
|
||||||
automatic_large_button(label, btn.into()),
|
t.id,
|
||||||
make_tip(tip_text),
|
tooltip(
|
||||||
TipPos::Right,
|
automatic_large_button(label, btn.into()),
|
||||||
|
make_tip(tip_text),
|
||||||
|
TipPos::Right,
|
||||||
|
)
|
||||||
|
.gap(6.0)
|
||||||
|
.delay(Duration::from_millis(400))
|
||||||
|
.style(tip_style),
|
||||||
)
|
)
|
||||||
.gap(6.0)
|
|
||||||
.delay(Duration::from_millis(400))
|
|
||||||
.style(tip_style)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RibbonItem::LargeDropdown {
|
RibbonItem::LargeDropdown {
|
||||||
@@ -1308,11 +1314,13 @@ pub(super) fn quick_access_btn<'a>(
|
|||||||
.width(Length::Fixed(TOP_HIST_W))
|
.width(Length::Fixed(TOP_HIST_W))
|
||||||
.height(24)
|
.height(24)
|
||||||
.padding([2, 0]);
|
.padding([2, 0]);
|
||||||
tooltip(btn, make_tip(t!(label).into_owned()), TipPos::Bottom)
|
super::keytips::anchor_with(
|
||||||
.gap(6.0)
|
|| super::keytips::quick_access_anchor(cmd),
|
||||||
.delay(Duration::from_millis(400))
|
tooltip(btn, make_tip(t!(label).into_owned()), TipPos::Bottom)
|
||||||
.style(tip_style)
|
.gap(6.0)
|
||||||
.into()
|
.delay(Duration::from_millis(400))
|
||||||
|
.style(tip_style),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn render_history_control<'a>(
|
pub(super) fn render_history_control<'a>(
|
||||||
|
|||||||
+37
-4
@@ -34,14 +34,46 @@ use crate::app::Message;
|
|||||||
thread_local! {
|
thread_local! {
|
||||||
/// Screen bounds of every ribbon dropdown button, keyed by dropdown id, so
|
/// Screen bounds of every ribbon dropdown button, keyed by dropdown id, so
|
||||||
/// an open dropdown's overlay can anchor directly below its widget at any
|
/// an open dropdown's overlay can anchor directly below its widget at any
|
||||||
/// size. Written by `PosReport` on draw, read by `dropdown_bounds`.
|
/// size. Written by `PosReport` on draw, read by `dropdown_bounds`. Each
|
||||||
static DD_BOUNDS: RefCell<FxHashMap<String, Rectangle>> =
|
/// entry keeps the frame it was drawn in (see `fresh_bounds`).
|
||||||
|
static DD_BOUNDS: RefCell<FxHashMap<String, (Rectangle, u64)>> =
|
||||||
RefCell::new(FxHashMap::default());
|
RefCell::new(FxHashMap::default());
|
||||||
|
/// Advanced by `end_frame` once everything above the widgets has drawn.
|
||||||
|
static FRAME: Cell<u64> = const { Cell::new(0) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Last-drawn screen bounds of the dropdown button with this id.
|
/// Last-drawn screen bounds of the dropdown button with this id.
|
||||||
pub fn dropdown_bounds(id: &str) -> Option<Rectangle> {
|
pub fn dropdown_bounds(id: &str) -> Option<Rectangle> {
|
||||||
DD_BOUNDS.with(|m| m.borrow().get(id).copied())
|
DD_BOUNDS.with(|m| m.borrow().get(id).map(|(bounds, _)| *bounds))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bounds of the widget `id` only when it was drawn in the current frame, so
|
||||||
|
/// a widget that left the screen does not report its old place.
|
||||||
|
pub fn fresh_bounds(id: &str) -> Option<Rectangle> {
|
||||||
|
let frame = FRAME.with(Cell::get);
|
||||||
|
DD_BOUNDS.with(|m| {
|
||||||
|
m.borrow()
|
||||||
|
.get(id)
|
||||||
|
.filter(|(_, drawn)| *drawn == frame)
|
||||||
|
.map(|(bounds, _)| *bounds)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bounds of the widget `id` when it was drawn in the current or the last
|
||||||
|
/// finished frame (for use between frames).
|
||||||
|
pub fn recent_bounds(id: &str) -> Option<Rectangle> {
|
||||||
|
let frame = FRAME.with(Cell::get);
|
||||||
|
DD_BOUNDS.with(|m| {
|
||||||
|
m.borrow()
|
||||||
|
.get(id)
|
||||||
|
.filter(|(_, drawn)| drawn + 1 >= frame)
|
||||||
|
.map(|(bounds, _)| *bounds)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close the current frame for `fresh_bounds`.
|
||||||
|
pub fn end_frame() {
|
||||||
|
FRAME.with(|frame| frame.set(frame.get() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WrapBar<'a> {
|
pub struct WrapBar<'a> {
|
||||||
@@ -1038,7 +1070,8 @@ impl<'a> Widget<Message, Theme, Renderer> for PosReport<'a> {
|
|||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
DD_BOUNDS.with(|m| {
|
DD_BOUNDS.with(|m| {
|
||||||
m.borrow_mut().insert(self.id.to_string(), layout.bounds());
|
m.borrow_mut()
|
||||||
|
.insert(self.id.to_string(), (layout.bounds(), FRAME.with(Cell::get)));
|
||||||
});
|
});
|
||||||
self.child.as_widget().draw(
|
self.child.as_widget().draw(
|
||||||
&tree.children[0],
|
&tree.children[0],
|
||||||
|
|||||||
Reference in new issue
Block a user