Merge pull request #1780 from ramox81/codex/ribbon-keytips

Ribbon key tips (Alt): codes on tabs, buttons and menu items

# Conflicts:
#	locales/ar-SA/opencadstudio.ftl
#	locales/bg-BG/opencadstudio.ftl
#	locales/cs-CZ/opencadstudio.ftl
#	locales/de-DE/opencadstudio.ftl
#	locales/el-GR/opencadstudio.ftl
#	locales/en-US/opencadstudio.ftl
#	locales/es-ES/opencadstudio.ftl
#	locales/fi-FI/opencadstudio.ftl
#	locales/fr-FR/opencadstudio.ftl
#	locales/hi-IN/opencadstudio.ftl
#	locales/hu-HU/opencadstudio.ftl
#	locales/it-IT/opencadstudio.ftl
#	locales/ja-JP/opencadstudio.ftl
#	locales/ko-KR/opencadstudio.ftl
#	locales/lo-LA/opencadstudio.ftl
#	locales/nl-NL/opencadstudio.ftl
#	locales/pl-PL/opencadstudio.ftl
#	locales/pt-BR/opencadstudio.ftl
#	locales/ru-RU/opencadstudio.ftl
#	locales/tr-TR/opencadstudio.ftl
#	locales/zh-CN/opencadstudio.ftl
#	locales/zh-TW/opencadstudio.ftl
#	src/app/control/actions.rs
This commit is contained in:
Hakan Seven committed 2026-10-14 12:14:23 +03:00
commit be6dbfdd78
34 files changed
+1570 -54

No files matched your search

+7
View File
@@ -6545,3 +6545,10 @@ image-adjust =
.reset = استعادة الافتراضي
.apply = تطبيق
.help = يضبط سطوع الصور النقطية المحددة وتباينها وتلاشيها.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = Възстанови стандартните
.apply = Приложи
.help = Задава яркостта, контраста и избледняването на избраните растерни изображения.
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
+7
View File
@@ -6530,3 +6530,10 @@ image-adjust =
.reset = Obnovit výchozí
.apply = Použít
.help = Nastaví jas, kontrast a vyblednutí vybraných rastrových obrázků.
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
+7
View File
@@ -6531,3 +6531,10 @@ image-adjust =
.reset = Standardwerte wiederherstellen
.apply = Anwenden
.help = Legt Helligkeit, Kontrast und Ausblendung der gewählten Rasterbilder fest.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = Επαναφορά προεπιλογών
.apply = Εφαρμογή
.help = Ορίζει τη φωτεινότητα, την αντίθεση και το ξεθώριασμα των επιλεγμένων εικόνων ράστερ.
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
+7
View File
@@ -6532,3 +6532,10 @@ image-adjust =
.reset = Restore defaults
.apply = Apply
.help = Sets the brightness, contrast and fade of the selected raster images.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = Restablecer valores por defecto
.apply = Aplicar
.help = Define el brillo, el contraste y la atenuación de las imágenes ráster seleccionadas.
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
+7
View File
@@ -6530,3 +6530,10 @@ image-adjust =
.reset = Palauta oletukset
.apply = Käytä
.help = Asettaa valittujen rasterikuvien kirkkauden, kontrastin ja häivytyksen.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = Rétablir les valeurs par défaut
.apply = Appliquer
.help = Définit la luminosité, le contraste et l'estompage des images raster sélectionnées.
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
+7
View File
@@ -6521,3 +6521,10 @@ image-adjust =
.reset = डिफ़ॉल्ट पुनर्स्थापित करें
.apply = लागू करें
.help = चयनित रास्टर छवियों की चमक, कंट्रास्ट और फ़ेड सेट करता है।
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
+7
View File
@@ -6517,3 +6517,10 @@ image-adjust =
.reset = Alapértékek visszaállítása
.apply = Alkalmaz
.help = Beállítja a kijelölt raszterképek fényerejét, kontrasztját és halványítását.
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
+7
View File
@@ -6532,3 +6532,10 @@ image-adjust =
.reset = Ripristina valori predefiniti
.apply = Applica
.help = Imposta luminosità, contrasto e dissolvenza delle immagini raster selezionate.
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
+7
View File
@@ -6521,3 +6521,10 @@ image-adjust =
.reset = 既定値に戻す
.apply = 適用
.help = 選択したラスター イメージの明るさ、コントラスト、フェードを設定します。
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
+7
View File
@@ -6532,3 +6532,10 @@ image-adjust =
.reset = 기본값 복원
.apply = 적용
.help = 선택한 래스터 이미지의 밝기, 대비 및 페이드를 설정합니다.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = ກູ້ຄືນຄ່າເລີ່ມຕົ້ນ
.apply = ນຳໃຊ້
.help = ຕັ້ງຄວາມສະຫວ່າງ, ຄວາມຄົມຊັດ ແລະ ຄວາມຈາງຂອງຮູບພາບ raster ທີ່ເລືອກ.
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
+7
View File
@@ -6531,3 +6531,10 @@ image-adjust =
.reset = Standaardwaarden herstellen
.apply = Toepassen
.help = Stelt helderheid, contrast en vervaging van de geselecteerde rasterafbeeldingen in.
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
+7
View File
@@ -6532,3 +6532,10 @@ image-adjust =
.reset = Przywróć domyślne
.apply = Zastosuj
.help = Ustawia jasność, kontrast i zanikanie wybranych obrazów rastrowych.
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
+7
View File
@@ -6533,3 +6533,10 @@ image-adjust =
.reset = Restaurar padrões
.apply = Aplicar
.help = Define o brilho, o contraste e o esmaecimento das imagens raster selecionadas.
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
+7
View File
@@ -6534,3 +6534,10 @@ image-adjust =
.reset = Восстановить по умолчанию
.apply = Применить
.help = Задает яркость, контраст и затенение выбранных растровых изображений.
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
+7
View File
@@ -6454,3 +6454,10 @@ image-adjust =
.reset = Varsayılana dön
.apply = Uygula
.help = Seçilen raster görüntülerin parlaklığını, karşıtlığını ve soluklığını ayarlar.
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
+7
View File
@@ -6516,3 +6516,10 @@ image-adjust =
.reset = 恢复默认值
.apply = 应用
.help = 设置所选光栅图像的亮度、对比度和淡入度。
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
+7
View File
@@ -6528,3 +6528,10 @@ image-adjust =
.reset = 還原預設值
.apply = 套用
.help = 設定選取之點陣影像的亮度、對比與淡入度。
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
+23
View File
@@ -116,6 +116,7 @@ pub(super) const NAMES: &[&str] = &[
"pc_section",
"ribbon_tab",
"ribbon_dropdown",
"keytips",
"dialog_ok",
"attdef_dialog",
"field_dialog",
@@ -1916,6 +1917,28 @@ impl OpenCADStudio {
})
}
}
// 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",
// "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",
+2
View File
@@ -559,6 +559,7 @@ impl OpenCADStudio {
| "audit"
| "text_search"
| "text_audit"
| "keytips"
);
if !query && !self.control.enabled {
return (
@@ -850,6 +851,7 @@ impl OpenCADStudio {
}
}
"grips" => self.control_grips(),
"keytips" => self.ribbon.keytips_json(req["detail"].as_str() == Some("full")),
"xdata_get" => self.xdata_read(&req),
"get_selection" => self.control_get_selection(),
"text_search" => self.control_text_search(&req).unwrap_or_else(|e| e),
+2
View File
@@ -2765,6 +2765,8 @@ pub enum Message {
SetProjection(bool),
/// Select a ribbon module tab by index.
RibbonSelectTab(usize),
/// Ribbon key tips: Alt, typed codes and Esc.
KeyTip(crate::ui::ribbon::KeyTipInput),
/// Change the ribbon tool-panel density (persisted).
SetRibbonCollapseMode(crate::ui::ribbon::CollapseMode),
/// A ribbon tool button was clicked — highlights the tool and dispatches its event.
+80
View File
@@ -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()
}
}
}
+6
View File
@@ -102,6 +102,7 @@ mod dialog;
mod dynamic;
mod file;
mod graphic_attributes;
mod keytips;
pub(in crate::app) use file::background_task;
#[cfg(not(target_arch = "wasm32"))]
pub(in crate::app) use file::native_paths_match;
@@ -628,6 +629,10 @@ impl OpenCADStudio {
if Some(id) == self.main_window {
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()
}
Message::SpaceMouseEnabled(enabled) => {
@@ -2285,6 +2290,7 @@ impl OpenCADStudio {
Message::PcManager(message) => self.update_pc_manager(message),
Message::Count(message) => self.on_count(message),
Message::SheetSet(message) => self.on_sheet_set(message),
Message::KeyTip(input) => self.on_keytip(input),
Message::RibbonSelectTab(idx) => {
self.ribbon.select(idx);
Task::none()
+30 -1
View File
@@ -2261,12 +2261,23 @@ bg={bg_ms:.1}ms n={view_count}"
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![
main_ui,
keytip_bar,
dropdown_layer,
qselect_layer,
snap_override_layer,
open_progress_layer,
keytip_layer,
];
// If the Plot Style editor was launched from PLOT, keep the Plot dialog
@@ -2556,9 +2567,18 @@ impl OpenCADStudio {
event::listen_with(|ev, status, win_id| {
use iced::event::Status;
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::mouse::Button::Left,
)) => Some(Message::PropPointerPressed),
)) => {
crate::ui::ribbon::keytip_pointer_pressed();
Some(Message::PropPointerPressed)
}
iced::Event::Window(window::Event::CloseRequested) => {
Some(Message::WindowCloseRequested(win_id))
}
@@ -2571,6 +2591,9 @@ impl OpenCADStudio {
iced::Event::Window(window::Event::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)) => {
// `command()` is Cmd on macOS, Ctrl elsewhere — the
// platform multi-select modifier for the layer list.
@@ -2584,8 +2607,14 @@ impl OpenCADStudio {
physical_key,
modifiers,
text,
repeat,
..
}) => {
if let Some(keytip) =
crate::ui::ribbon::keytip_key_pressed(&key, modifiers, repeat)
{
return keytip;
}
#[cfg(target_arch = "wasm32")]
let accel = modifiers.command();
// AltGr reaches Windows apps as Ctrl+Alt, and a macOS
+2 -1
View File
@@ -32,7 +32,7 @@ const MODERN_PROTOCOL_VERSION: &str = "2026-07-28";
///
/// `block_delete` gained its optional `force` parameter.
#[cfg(test)]
const TOOL_SCHEMA_DIGEST: &str = "c5f9ad00e04c0acc809c7de0c75e789fd9bf3ad6db68bdde36bd771a859fef79";
const TOOL_SCHEMA_DIGEST: &str = "9a7aeb5e1fd76b94fabece3a7ba213f622f449076fac9c25c7e69592989094fd";
const MAX_REQUEST: usize = 1_048_576;
const MAX_RESPONSE: u64 = 16 * 1024 * 1024;
const CACHE_TTL_MS: u64 = 3_600_000;
@@ -68,6 +68,7 @@ const READ_OPS: &[&str] = &[
"audit",
"text_search",
"text_audit",
"keytips",
"capture",
];
const EXECUTE_OPS: &[&str] = &[
+49 -15
View File
@@ -9,7 +9,7 @@ use super::widgets::{
make_icon, make_tip, muted_text_style, popup_panel_style, popup_row_style, tip_style,
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::modules::IconKind;
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
/// each of its submenu options.
pub(super) fn slide_out_commands(
@@ -337,6 +363,7 @@ pub(super) fn group_title<'a>(
.delay(Duration::from_millis(400))
.style(tip_style);
// 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]
.spacing(6)
.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))
.style(tip_style)
.into();
let face = keytips::anchor_with(|| keytips::item_anchor(panel_id, tool.command), face);
if !tool.options.is_empty() {
row![
face,
@@ -401,6 +429,7 @@ fn reference_overlay<'a>(ribbon: &Ribbon, panel: Panel, win: (f32, f32)) -> Elem
.style(popup_row_style)
.width(Fill)
.padding([3, 6]);
let edit = keytips::anchor_with(|| keytips::item_anchor(panel.id, tool.command), edit);
let fade = ribbon.xref_fade;
let on = fade > 0;
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))
.padding(3);
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![
tooltip(
switch,
make_tip(format!(
"{}\n{} XDWGFADECTL",
t!("Xref fading"),
t!("Command:")
)),
tooltip::Position::Bottom
)
.delay(Duration::from_millis(400))
.style(tip_style),
switch,
text(t!("Xref fading")).size(11),
iced::widget::slider(0..=90u8, amount, Message::XrefFadeSlide)
.on_release(Message::XrefFadeCommit)
@@ -468,7 +502,7 @@ pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element
tool.options
.iter()
.map(|&(cmd, label)| {
button(text(t!(label)).size(11))
let item = button(text(t!(label)).size(11))
.on_press(Message::DropdownSelectItem {
dropdown_id: tool.command,
cmd,
@@ -476,8 +510,8 @@ pub(super) fn overlay<'a>(ribbon: &Ribbon, id: &str, win: (f32, f32)) -> Element
.style(popup_row_style)
.width(Fill)
.height(OPTION_HEIGHT)
.padding([3, 7])
.into()
.padding([3, 7]);
keytips::anchor_with(|| keytips::item_anchor(tool.command, cmd), item)
})
.collect::<Vec<Element<'static, Message>>>(),
)
File diff suppressed because it is too large. Load diff
+22 -7
View File
@@ -31,6 +31,12 @@ use widgets::{StyleContext, *};
pub(crate) use widgets::{REDO_HISTORY_ID, UNDO_HISTORY_ID};
mod collapse;
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::ui::wrap_bar::{PosReport, WrapBar, WrapFlow};
pub use collapse::CollapseMode;
@@ -122,6 +128,8 @@ pub struct Ribbon {
block_editing: Option<usize>,
/// XDWGFADECTL as the Reference slide-out shows it (negative = off).
pub xref_fade: i32,
/// Open key tips (Alt).
keytips: Option<keytips::State>,
}
/// Per-layer display data shown in the ribbon layer dropdown.
@@ -224,6 +232,7 @@ impl Ribbon {
point_cloud_ctx: None,
block_editing: None,
xref_fade: 50,
keytips: None,
}
}
@@ -662,7 +671,7 @@ impl Ribbon {
},
..Default::default()
});
acc.push(btn.into());
acc.push(keytips::anchor_with(|| format!("tab:{}", module.id()), btn));
acc
},
);
@@ -800,7 +809,7 @@ impl Ribbon {
tool_bar
};
column![tab_bar, tool_bar].into()
keytips::ribbon_area(column![tab_bar, tool_bar])
}
// ── Dropdown overlay ──────────────────────────────────────────────────
@@ -971,7 +980,7 @@ impl Ribbon {
.then_some(theme.palette().background.base.text.scale_alpha(0.72)),
});
button(
let item = button(
row![checkmark, icon_el, label_el]
.spacing(4)
.align_y(iced::Center),
@@ -982,8 +991,8 @@ impl Ribbon {
}))
.style(popup_row_style)
.width(Fill)
.padding([4, 10])
.into()
.padding([4, 10]);
keytips::anchor_with(|| keytips::item_anchor(dd_id, cmd), item)
})
.collect();
@@ -1571,7 +1580,10 @@ fn collapse_button<'a>(
.style(opener_style(holds))
.width(Fill)
.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
@@ -1636,7 +1648,10 @@ fn collapse_button<'a>(
.style(opener_style(holds && !face_lit))
.width(Fill)
.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
// 3-row panel, letting `CollapsePanels` shrink the ribbon row.
+34 -26
View File
@@ -543,11 +543,13 @@ pub(super) fn render_small<'a>(
.width(Length::Fixed(SMALL_W))
.height(ROW_H)
.padding([4, 4]);
tooltip(btn, make_tip(tip_text), TipPos::Right)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style)
.into()
super::keytips::anchor(
t.id,
tooltip(btn, make_tip(tip_text), TipPos::Right)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style),
)
}
RibbonItem::LabeledTool(t) => {
@@ -568,11 +570,13 @@ pub(super) fn render_small<'a>(
.width(Length::Fixed(LABELED_SMALL_W + ARROW_W))
.height(ROW_H)
.padding([3, 4]);
tooltip(btn, make_tip(tip_text), TipPos::Right)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style)
.into()
super::keytips::anchor(
t.id,
tooltip(btn, make_tip(tip_text), TipPos::Right)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style),
)
}
RibbonItem::Dropdown {
@@ -895,7 +899,7 @@ fn tool_row<'a>(tools: &[ToolDef], active_tool: &Option<String>) -> Element<'a,
let event = t.event.clone();
let icon_el: Element<Message> = make_icon(t.icon, 16.0);
let msg = module_event_to_message(event);
tooltip(
let btn = tooltip(
button(icon_el)
.on_press(msg)
.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)
.delay(Duration::from_millis(400))
.style(tip_style)
.into()
.style(tip_style);
super::keytips::anchor(t.id, btn)
})
.collect();
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,
left: 4.0,
});
tooltip(
automatic_large_button(label, btn.into()),
make_tip(tip_text),
TipPos::Right,
super::keytips::anchor(
t.id,
tooltip(
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 {
@@ -1308,11 +1314,13 @@ pub(super) fn quick_access_btn<'a>(
.width(Length::Fixed(TOP_HIST_W))
.height(24)
.padding([2, 0]);
tooltip(btn, make_tip(t!(label).into_owned()), TipPos::Bottom)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style)
.into()
super::keytips::anchor_with(
|| super::keytips::quick_access_anchor(cmd),
tooltip(btn, make_tip(t!(label).into_owned()), TipPos::Bottom)
.gap(6.0)
.delay(Duration::from_millis(400))
.style(tip_style),
)
}
pub(super) fn render_history_control<'a>(
+37 -4
View File
@@ -34,14 +34,46 @@ use crate::app::Message;
thread_local! {
/// 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
/// size. Written by `PosReport` on draw, read by `dropdown_bounds`.
static DD_BOUNDS: RefCell<FxHashMap<String, Rectangle>> =
/// size. Written by `PosReport` on draw, read by `dropdown_bounds`. Each
/// entry keeps the frame it was drawn in (see `fresh_bounds`).
static DD_BOUNDS: RefCell<FxHashMap<String, (Rectangle, u64)>> =
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.
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> {
@@ -1038,7 +1070,8 @@ impl<'a> Widget<Message, Theme, Renderer> for PosReport<'a> {
viewport: &Rectangle,
) {
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(
&tree.children[0],