fix tooltips not disappearing, clippy
This commit is contained in:
@@ -59,7 +59,7 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
})
|
||||
}
|
||||
"::OverlayToggle" => {
|
||||
let Some(arg): Option<Arc<str>> = args.next().map(|a| a.into()) else {
|
||||
let Some(arg): Option<Arc<str>> = args.next().map(Into::into) else {
|
||||
log::error!("{command} has missing arguments");
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
clippy::struct_excessive_bools,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::needless_pass_by_ref_mut,
|
||||
clippy::multiple_crate_versions
|
||||
clippy::multiple_crate_versions,
|
||||
clippy::cargo_common_metadata
|
||||
)]
|
||||
mod backend;
|
||||
mod config;
|
||||
|
||||
@@ -19,22 +19,22 @@ use wgui::{
|
||||
use crate::{backend::task::TaskType, windowing::OverlaySelector};
|
||||
use crate::{
|
||||
backend::{input::HoverResult, task::TaskContainer},
|
||||
gui::panel::{button::BUTTON_EVENTS, GuiPanel, NewGuiPanelParams, OnCustomAttribFunc},
|
||||
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS},
|
||||
overlays::edit::{
|
||||
lock::InteractLockHandler, pos::PositioningHandler, tab::ButtonPaneTabSwitcher,
|
||||
},
|
||||
state::AppState,
|
||||
subsystem::hid::WheelDelta,
|
||||
windowing::{
|
||||
OverlayID,
|
||||
backend::{DummyBackend, OverlayBackend, OverlayEventData, RenderResources, ShouldRender},
|
||||
window::OverlayWindowConfig,
|
||||
OverlayID,
|
||||
},
|
||||
};
|
||||
|
||||
mod lock;
|
||||
mod pos;
|
||||
pub(crate) mod tab;
|
||||
pub mod tab;
|
||||
|
||||
pub(super) struct LongPressButtonState {
|
||||
pub(super) pressed: Instant,
|
||||
|
||||
@@ -19,16 +19,16 @@ use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||
use crate::{
|
||||
backend::task::{ManagerTask, TaskType},
|
||||
gui::{
|
||||
panel::{button::BUTTON_EVENTS, GuiPanel, NewGuiPanelParams, OnCustomAttribFunc},
|
||||
panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS},
|
||||
timer::GuiTimer,
|
||||
},
|
||||
overlays::edit::LongPressButtonState,
|
||||
state::AppState,
|
||||
windowing::{
|
||||
OverlaySelector, Z_ORDER_WATCH,
|
||||
backend::{OverlayEventData, OverlayMeta},
|
||||
manager::MAX_OVERLAY_SETS,
|
||||
window::{OverlayWindowConfig, OverlayWindowData},
|
||||
OverlaySelector, Z_ORDER_WATCH,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -48,6 +48,7 @@ struct WatchState {
|
||||
}
|
||||
|
||||
#[allow(clippy::significant_drop_tightening)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
let state = WatchState::default();
|
||||
|
||||
@@ -92,7 +93,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
};
|
||||
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
OverlaySelector::Id(overlay.id.clone()),
|
||||
OverlaySelector::Id(overlay.id),
|
||||
Box::new(move |app, owc| {
|
||||
if owc.active_state.is_none() {
|
||||
owc.activate(app);
|
||||
@@ -187,42 +188,36 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
} else {
|
||||
taffy::Display::None
|
||||
};
|
||||
panel.widget_set_display(rect_id, display, &mut common.alterables);
|
||||
panel.widget_set_display(rect_id, display, common.alterables);
|
||||
}
|
||||
let display = if num_sets < 7 {
|
||||
taffy::Display::Flex
|
||||
} else {
|
||||
taffy::Display::None
|
||||
};
|
||||
panel.widget_set_display(
|
||||
panel.state.edit_add_widget,
|
||||
display,
|
||||
&mut common.alterables,
|
||||
);
|
||||
panel.widget_set_display(panel.state.edit_add_widget, display, common.alterables);
|
||||
}
|
||||
OverlayEventData::EditModeChanged(edit_mode) => {
|
||||
for (w, e) in panel.state.edit_mode_widgets.iter() {
|
||||
for (w, e) in &panel.state.edit_mode_widgets {
|
||||
let display = if *e == edit_mode {
|
||||
taffy::Display::Flex
|
||||
} else {
|
||||
taffy::Display::None
|
||||
};
|
||||
panel.widget_set_display(*w, display, &mut common.alterables);
|
||||
panel.widget_set_display(*w, display, common.alterables);
|
||||
}
|
||||
let display = if edit_mode && panel.state.num_sets < 7 {
|
||||
taffy::Display::Flex
|
||||
} else {
|
||||
taffy::Display::None
|
||||
};
|
||||
panel.widget_set_display(
|
||||
panel.state.edit_add_widget,
|
||||
display,
|
||||
&mut common.alterables,
|
||||
);
|
||||
panel.widget_set_display(panel.state.edit_add_widget, display, common.alterables);
|
||||
}
|
||||
OverlayEventData::OverlaysChanged(metas) => {
|
||||
panel.state.overlay_metas = metas;
|
||||
// FIXME: should we suppress this clippy warning in the crate itself? the resulting code isn't always more readable than before
|
||||
for (idx, btn) in panel.state.overlay_buttons.iter().enumerate() {
|
||||
#[allow(clippy::option_if_let_else)]
|
||||
let display = if let Some(meta) = panel.state.overlay_metas.get(idx) {
|
||||
btn.set_text(&mut common, Translation::from_raw_text(&meta.name));
|
||||
//TODO: add category icons
|
||||
@@ -230,7 +225,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
} else {
|
||||
taffy::Display::None
|
||||
};
|
||||
panel.widget_set_display(btn.get_rect(), display, &mut common.alterables);
|
||||
panel.widget_set_display(btn.get_rect(), display, common.alterables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ use vulkano::{
|
||||
image::view::ImageView,
|
||||
};
|
||||
use wgui::gfx::{
|
||||
cmd::{GfxCommandBuffer, WGfxClearMode},
|
||||
WGfx,
|
||||
cmd::{GfxCommandBuffer, WGfxClearMode},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -16,7 +16,7 @@ use crate::{
|
||||
graphics::ExtentExt,
|
||||
state::AppState,
|
||||
subsystem::hid::WheelDelta,
|
||||
windowing::{window::OverlayCategory, OverlayID},
|
||||
windowing::{OverlayID, window::OverlayCategory},
|
||||
};
|
||||
|
||||
#[derive(Default, Clone, Copy)]
|
||||
@@ -71,6 +71,7 @@ pub struct OverlayMeta {
|
||||
pub category: OverlayCategory,
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum OverlayEventData {
|
||||
ActiveSetChanged(Option<usize>),
|
||||
NumSetsChanged(usize),
|
||||
|
||||
@@ -12,11 +12,11 @@ use crate::{
|
||||
},
|
||||
state::AppState,
|
||||
windowing::{
|
||||
OverlayID, OverlaySelector,
|
||||
backend::{OverlayEventData, OverlayMeta},
|
||||
set::OverlayWindowSet,
|
||||
snap_upright,
|
||||
window::{OverlayCategory, OverlayWindowData},
|
||||
OverlayID, OverlaySelector,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -246,12 +246,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
) -> Option<OverlayWindowData<T>> {
|
||||
let id = match selector {
|
||||
OverlaySelector::Id(id) => *id,
|
||||
OverlaySelector::Name(name) => {
|
||||
let Some(id) = self.lookup(name) else {
|
||||
return None;
|
||||
};
|
||||
id
|
||||
}
|
||||
OverlaySelector::Name(name) => self.lookup(name)?,
|
||||
};
|
||||
|
||||
let ret_val = self.overlays.remove(id);
|
||||
@@ -260,7 +255,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
.is_some_and(|o| matches!(o.config.category, OverlayCategory::Internal));
|
||||
|
||||
if !internal && let Err(e) = self.overlays_changed(app) {
|
||||
log::error!("Error while removing overlay: {e:?}")
|
||||
log::error!("Error while removing overlay: {e:?}");
|
||||
}
|
||||
|
||||
ret_val
|
||||
@@ -455,12 +450,12 @@ impl<T> OverlayWindowManager<T> {
|
||||
|
||||
fn overlays_changed(&mut self, app: &mut AppState) -> anyhow::Result<()> {
|
||||
let mut meta = Vec::with_capacity(self.overlays.len());
|
||||
for (id, data) in self.overlays.iter() {
|
||||
for (id, data) in &self.overlays {
|
||||
if matches!(data.config.category, OverlayCategory::Internal) {
|
||||
continue;
|
||||
}
|
||||
meta.push(OverlayMeta {
|
||||
id: id.clone(),
|
||||
id,
|
||||
name: data.config.name.clone(),
|
||||
category: data.config.category,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user