1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-03 19:51:03 +02:00

feat: wrap modules in a revealer to support animated show/hide

Resolves #72.
This commit is contained in:
Jake Stanger 2023-04-22 14:49:15 +01:00
parent 1855416db4
commit 83f44fd92f
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
5 changed files with 83 additions and 19 deletions

View file

@ -23,14 +23,14 @@ pub mod tray;
pub mod workspaces;
use crate::bridge_channel::BridgeChannel;
use crate::config::{BarPosition, CommonConfig};
use crate::config::{BarPosition, CommonConfig, TransitionType};
use crate::popup::{Popup, WidgetGeometry};
use crate::{read_lock, send, write_lock};
use color_eyre::Result;
use glib::IsA;
use gtk::gdk::{EventMask, Monitor};
use gtk::prelude::*;
use gtk::{Application, EventBox, IconTheme, Widget};
use gtk::{Application, EventBox, IconTheme, Orientation, Revealer, Widget};
use std::sync::{Arc, RwLock};
use tokio::sync::mpsc;
use tracing::debug;
@ -234,12 +234,30 @@ fn setup_receiver<TSend>(
/// Takes a widget and adds it into a new `gtk::EventBox`.
/// The event box container is returned.
pub fn wrap_widget<W: IsA<Widget>>(widget: &W, common: CommonConfig) -> EventBox {
pub fn wrap_widget<W: IsA<Widget>>(
widget: &W,
common: CommonConfig,
orientation: Orientation,
) -> EventBox {
let revealer = Revealer::builder()
.transition_type(
common
.transition_type
.as_ref()
.unwrap_or(&TransitionType::SlideStart)
.to_revealer_transition_type(orientation),
)
.transition_duration(common.transition_duration.unwrap_or(250))
.build();
revealer.add(widget);
revealer.set_reveal_child(true);
let container = EventBox::new();
container.add_events(EventMask::SCROLL_MASK);
container.add(widget);
container.add(&revealer);
common.install(&container);
common.install(&container, &revealer);
container
}