98 lines
2.8 KiB
Rust
98 lines
2.8 KiB
Rust
use crate::model::builder_traits::*;
|
||
|
||
use adw::HeaderBar;
|
||
use gtk4 as gtk;
|
||
|
||
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
||
|
||
use crate::view::{
|
||
components::{
|
||
dialogues::{open_about_dialogue, open_help_dialogue},
|
||
info_bar::InfoBar,
|
||
menu::HeaderMenu,
|
||
pages::Pages,
|
||
},
|
||
pages::*,
|
||
properties::*,
|
||
};
|
||
|
||
use super::{components::MenuActions, styles::load_css};
|
||
|
||
pub fn ui(application: &adw::Application) {
|
||
load_css();
|
||
|
||
let hamming_code = Box::builder()
|
||
.orientation(Orientation::Vertical)
|
||
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
||
.set_margin(MarginData::EqualsMargin(15))
|
||
.spacing(10)
|
||
.build();
|
||
|
||
let info_bar = InfoBar::builder()
|
||
.set_text_label("Sample text")
|
||
.set_button_icon("close")
|
||
.build();
|
||
|
||
hamming_code::hamming_code_page(&hamming_code);
|
||
|
||
let signal_reducing = Box::builder()
|
||
.orientation(Orientation::Vertical)
|
||
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
||
.set_margin(MarginData::EqualsMargin(15))
|
||
.spacing(10)
|
||
.build();
|
||
|
||
signal_reducing::signal_reducing_page(&signal_reducing);
|
||
|
||
let pages = Pages::builder()
|
||
.set_transition(SlideLeftRight, 200)
|
||
.append_items(vec![
|
||
("Код Хэмминга", "Код Хэмминга", &hamming_code),
|
||
("Затухание сигнала", "Затухание сигнала", &signal_reducing),
|
||
])
|
||
.build(5);
|
||
|
||
let application_box = Box::new(Orientation::Vertical, 0);
|
||
|
||
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();
|
||
|
||
let actions: &[MenuActions] = &[
|
||
(open_about_dialogue, "about_software", "О программе"),
|
||
(open_help_dialogue, "help", "Помощь"),
|
||
];
|
||
|
||
menu_button.set_action_group_name(Some("menu_group_action"));
|
||
menu_button.append_items(actions);
|
||
|
||
title_bar.append(
|
||
&Label::builder()
|
||
.css_name("title")
|
||
.set_align(Alignment::new(Align::Center, Align::Center))
|
||
.hexpand(true)
|
||
.vexpand(true)
|
||
.use_markup(true)
|
||
.label("<b>Комплексная программа для лаб. работ</b>")
|
||
.build(),
|
||
);
|
||
title_bar.append(menu_button.get_button());
|
||
|
||
let header_bar = HeaderBar::builder().title_widget(&title_bar).build();
|
||
|
||
let window = ApplicationWindow::builder()
|
||
.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();
|
||
}
|