Add complete keyboard navigation.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use crate::components::keyboard;
|
||||
use iced::widget::button;
|
||||
use iced::widget::scrollable::Direction;
|
||||
use iced::widget::text::Shaping;
|
||||
use iced::widget::tooltip::Position;
|
||||
use iced::widget::{Space, button, container, row, scrollable, text, tooltip};
|
||||
use iced::widget::{Space, container, row, scrollable, text, tooltip};
|
||||
use iced::{Background, Border, Color, Element, Font, Length, Theme};
|
||||
|
||||
use bds_core::i18n::UiLocale;
|
||||
@@ -177,9 +179,20 @@ pub fn view(tabs: &[Tab], active_tab: Option<&str>, locale: UiLocale) -> Element
|
||||
.width(Length::Fill)
|
||||
.clip(true);
|
||||
|
||||
// Keep the tooltip around non-interactive title content so it does
|
||||
// not hide the tab and close controls from widget operations.
|
||||
let tooltip_text = build_tooltip_text(tab, locale);
|
||||
let title_area = tooltip(
|
||||
title_area,
|
||||
text(tooltip_text).size(11).shaping(Shaping::Advanced),
|
||||
Position::Bottom,
|
||||
)
|
||||
.gap(4)
|
||||
.style(inputs::tooltip_style);
|
||||
|
||||
let label = row![
|
||||
title_area,
|
||||
button(text("\u{2715}").size(10).shaping(Shaping::Advanced))
|
||||
keyboard::button(text("\u{2715}").size(10).shaping(Shaping::Advanced))
|
||||
.on_press(Message::CloseTab(close_id))
|
||||
.padding(2)
|
||||
.style(close_style),
|
||||
@@ -188,24 +201,12 @@ pub fn view(tabs: &[Tab], active_tab: Option<&str>, locale: UiLocale) -> Element
|
||||
.align_y(iced::Alignment::Center);
|
||||
|
||||
// tabs.allium: tab_min_width=100, tab_max_width=160
|
||||
let tab_btn = button(label)
|
||||
keyboard::button(label)
|
||||
.on_press(Message::SelectTab(tab_id))
|
||||
.padding([6, 8])
|
||||
.width(Length::Fixed(TAB_WIDTH))
|
||||
.style(if is_active { tab_active } else { tab_inactive });
|
||||
|
||||
// tabs.allium tooltip: title + "(Preview)" if transient + "* Modified" if dirty
|
||||
let tooltip_text = build_tooltip_text(tab, locale);
|
||||
let tip: Element<'static, Message> = tooltip(
|
||||
tab_btn,
|
||||
text(tooltip_text).size(11).shaping(Shaping::Advanced),
|
||||
Position::Bottom,
|
||||
)
|
||||
.gap(4)
|
||||
.style(inputs::tooltip_style)
|
||||
.into();
|
||||
|
||||
tip
|
||||
.style(if is_active { tab_active } else { tab_inactive })
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user