mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-03 03:31:03 +02:00
fix(popup): re-position on resize due to content change
This commit is contained in:
parent
a55ba8c523
commit
a10466e7e9
4 changed files with 102 additions and 67 deletions
|
@ -1,4 +1,3 @@
|
|||
use std::cell::RefCell;
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
@ -215,7 +214,7 @@ pub fn create_module<TModule, TWidget, TSend, TRec>(
|
|||
ironbar: Rc<Ironbar>,
|
||||
name: Option<String>,
|
||||
info: &ModuleInfo,
|
||||
popup: &Rc<RefCell<Popup>>,
|
||||
popup: &Rc<Popup>,
|
||||
) -> Result<ModuleParts<TWidget>>
|
||||
where
|
||||
TModule: Module<TWidget, SendMessage = TSend, ReceiveMessage = TRec>,
|
||||
|
@ -251,7 +250,7 @@ where
|
|||
.style_context()
|
||||
.add_class(&format!("popup-{module_name}"));
|
||||
|
||||
register_popup_content(popup, id, instance_name, popup_content);
|
||||
popup.register_content(id, instance_name, popup_content);
|
||||
}
|
||||
|
||||
setup_receiver(tx, ui_rx, popup.clone(), module_name, id);
|
||||
|
@ -259,16 +258,6 @@ where
|
|||
Ok(module_parts)
|
||||
}
|
||||
|
||||
/// Registers the popup content with the popup.
|
||||
fn register_popup_content(
|
||||
popup: &Rc<RefCell<Popup>>,
|
||||
id: usize,
|
||||
name: String,
|
||||
popup_content: ModulePopupParts,
|
||||
) {
|
||||
popup.borrow_mut().register_content(id, name, popup_content);
|
||||
}
|
||||
|
||||
/// Sets up the bridge channel receiver
|
||||
/// to pick up events from the controller, widget or popup.
|
||||
///
|
||||
|
@ -277,7 +266,7 @@ fn register_popup_content(
|
|||
fn setup_receiver<TSend>(
|
||||
tx: broadcast::Sender<TSend>,
|
||||
rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>,
|
||||
popup: Rc<RefCell<Popup>>,
|
||||
popup: Rc<Popup>,
|
||||
name: &'static str,
|
||||
id: usize,
|
||||
) where
|
||||
|
@ -294,7 +283,6 @@ fn setup_receiver<TSend>(
|
|||
}
|
||||
ModuleUpdateEvent::TogglePopup(button_id) => {
|
||||
debug!("Toggling popup for {} [#{}]", name, id);
|
||||
let mut popup = popup.borrow_mut();
|
||||
if popup.is_visible() {
|
||||
popup.hide();
|
||||
} else {
|
||||
|
@ -309,8 +297,6 @@ fn setup_receiver<TSend>(
|
|||
}
|
||||
ModuleUpdateEvent::OpenPopup(button_id) => {
|
||||
debug!("Opening popup for {} [#{}]", name, id);
|
||||
|
||||
let mut popup = popup.borrow_mut();
|
||||
popup.hide();
|
||||
popup.show(id, button_id);
|
||||
|
||||
|
@ -324,7 +310,6 @@ fn setup_receiver<TSend>(
|
|||
ModuleUpdateEvent::OpenPopupAt(geometry) => {
|
||||
debug!("Opening popup for {} [#{}]", name, id);
|
||||
|
||||
let mut popup = popup.borrow_mut();
|
||||
popup.hide();
|
||||
popup.show_at(id, geometry);
|
||||
|
||||
|
@ -336,8 +321,6 @@ fn setup_receiver<TSend>(
|
|||
}
|
||||
ModuleUpdateEvent::ClosePopup => {
|
||||
debug!("Closing popup for {} [#{}]", name, id);
|
||||
|
||||
let mut popup = popup.borrow_mut();
|
||||
popup.hide();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue