feat(titlebar): add custom titlebar with headermenu
to squash
This commit is contained in:
parent
bafa837931
commit
dd2007c895
|
@ -1,5 +1,6 @@
|
|||
use crate::model::builder_traits::*;
|
||||
|
||||
use adw::HeaderBar;
|
||||
use gtk4 as gtk;
|
||||
|
||||
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
||||
|
@ -7,6 +8,7 @@ use info_bar::InfoBar;
|
|||
|
||||
#[allow(unused)]
|
||||
use crate::view::{
|
||||
components::{about::open_about_dialogue, info_bar::InfoBar, menu::HeaderMenu, pages::Pages},
|
||||
pages::*,
|
||||
properties::*,
|
||||
};
|
||||
|
@ -52,13 +54,35 @@ pub fn ui(application: &adw::Application) {
|
|||
application_box.append(info_bar.get());
|
||||
application_box.append(pages.get());
|
||||
|
||||
let title_bar = Box::new(Orientation::Horizontal, 0);
|
||||
|
||||
let mut menu_button = HeaderMenu::<&str>::new();
|
||||
|
||||
menu_button.set_action_group_name(Some("menu_group_action"));
|
||||
menu_button.append_items([(open_about_dialogue, "about_software", "О программе")]);
|
||||
|
||||
title_bar.append(
|
||||
&Label::builder()
|
||||
.css_name("title")
|
||||
.set_align(Alignment::new(Align::Center, Align::Center))
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.label("Комплексная программа для лаб. работ")
|
||||
.build(),
|
||||
);
|
||||
title_bar.append(menu_button.get_button());
|
||||
|
||||
let header_bar = HeaderBar::builder().title_widget(&title_bar).build();
|
||||
|
||||
let window = ApplicationWindow::builder()
|
||||
.title("Комплексная программа для лаб. работ")
|
||||
.width_request(800)
|
||||
.height_request(600)
|
||||
.application(application)
|
||||
.titlebar(&header_bar)
|
||||
.child(&application_box)
|
||||
.build();
|
||||
|
||||
window.insert_action_group("menu_group_action", Some(menu_button.get_actions_group()));
|
||||
|
||||
window.present();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue