2024-03-17 20:34:12 +03:00
|
|
|
|
use crate::model::builder_traits::*;
|
2024-07-27 21:22:51 +03:00
|
|
|
|
|
2024-08-16 22:32:08 +03:00
|
|
|
|
use adw::HeaderBar;
|
2024-03-10 11:54:32 +03:00
|
|
|
|
use gtk4 as gtk;
|
|
|
|
|
|
2024-08-02 00:11:22 +03:00
|
|
|
|
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
2024-03-10 11:54:32 +03:00
|
|
|
|
|
2024-04-14 19:13:15 +03:00
|
|
|
|
use crate::view::{
|
2024-08-17 20:43:19 +03:00
|
|
|
|
components::{
|
|
|
|
|
dialogues::{open_about_dialogue, open_help_dialogue},
|
|
|
|
|
info_bar::InfoBar,
|
|
|
|
|
menu::HeaderMenu,
|
|
|
|
|
pages::Pages,
|
|
|
|
|
},
|
2024-04-14 19:13:15 +03:00
|
|
|
|
pages::*,
|
|
|
|
|
properties::*,
|
|
|
|
|
};
|
2024-03-10 11:54:32 +03:00
|
|
|
|
|
2024-08-17 20:43:19 +03:00
|
|
|
|
use super::{components::MenuActions, styles::load_css};
|
2024-07-19 22:12:42 +03:00
|
|
|
|
|
2024-04-14 19:13:15 +03:00
|
|
|
|
pub fn ui(application: &adw::Application) {
|
2024-07-19 22:12:42 +03:00
|
|
|
|
load_css();
|
|
|
|
|
|
2024-08-16 22:26:53 +03:00
|
|
|
|
let hamming_code = Box::builder()
|
|
|
|
|
.orientation(Orientation::Vertical)
|
2024-03-10 11:54:32 +03:00
|
|
|
|
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
|
|
|
|
.set_margin(MarginData::EqualsMargin(15))
|
|
|
|
|
.spacing(10)
|
|
|
|
|
.build();
|
|
|
|
|
|
2024-07-27 21:22:51 +03:00
|
|
|
|
let info_bar = InfoBar::builder()
|
|
|
|
|
.set_text_label("Sample text")
|
|
|
|
|
.set_button_icon("close")
|
2024-07-19 22:12:42 +03:00
|
|
|
|
.build();
|
|
|
|
|
|
2024-07-27 21:22:51 +03:00
|
|
|
|
hamming_code::hamming_code_page(&hamming_code);
|
2024-03-10 11:54:32 +03:00
|
|
|
|
|
2024-08-16 22:26:53 +03:00
|
|
|
|
let signal_reducing = Box::builder()
|
|
|
|
|
.orientation(Orientation::Vertical)
|
2024-03-10 11:54:32 +03:00
|
|
|
|
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
|
|
|
|
.set_margin(MarginData::EqualsMargin(15))
|
|
|
|
|
.spacing(10)
|
|
|
|
|
.build();
|
|
|
|
|
|
2024-07-27 21:22:51 +03:00
|
|
|
|
signal_reducing::signal_reducing_page(&signal_reducing);
|
2024-03-10 11:54:32 +03:00
|
|
|
|
|
2024-03-12 22:49:20 +03:00
|
|
|
|
let pages = Pages::builder()
|
|
|
|
|
.set_transition(SlideLeftRight, 200)
|
2024-03-16 23:21:20 +03:00
|
|
|
|
.append_items(vec![
|
2024-03-17 20:34:12 +03:00
|
|
|
|
("Код Хэмминга", "Код Хэмминга", &hamming_code),
|
2024-04-14 19:13:15 +03:00
|
|
|
|
("Затухание сигнала", "Затухание сигнала", &signal_reducing),
|
2024-03-12 22:49:20 +03:00
|
|
|
|
])
|
2024-08-09 23:47:01 +03:00
|
|
|
|
.build(5);
|
2024-03-10 11:54:32 +03:00
|
|
|
|
|
2024-07-19 22:12:42 +03:00
|
|
|
|
let application_box = Box::new(Orientation::Vertical, 0);
|
|
|
|
|
|
2024-08-09 23:47:01 +03:00
|
|
|
|
application_box.append(info_bar.get());
|
|
|
|
|
application_box.append(pages.get());
|
2024-07-19 22:12:42 +03:00
|
|
|
|
|
2024-08-16 22:32:08 +03:00
|
|
|
|
let title_bar = Box::new(Orientation::Horizontal, 0);
|
|
|
|
|
|
|
|
|
|
let mut menu_button = HeaderMenu::<&str>::new();
|
|
|
|
|
|
2024-08-17 20:43:19 +03:00
|
|
|
|
let actions: &[MenuActions] = &[
|
|
|
|
|
(open_about_dialogue, "about_software", "О программе"),
|
|
|
|
|
(open_help_dialogue, "help", "Помощь"),
|
|
|
|
|
];
|
|
|
|
|
|
2024-08-16 22:32:08 +03:00
|
|
|
|
menu_button.set_action_group_name(Some("menu_group_action"));
|
2024-08-17 20:43:19 +03:00
|
|
|
|
menu_button.append_items(actions);
|
2024-08-16 22:32:08 +03:00
|
|
|
|
|
|
|
|
|
title_bar.append(
|
|
|
|
|
&Label::builder()
|
|
|
|
|
.css_name("title")
|
|
|
|
|
.set_align(Alignment::new(Align::Center, Align::Center))
|
|
|
|
|
.hexpand(true)
|
|
|
|
|
.vexpand(true)
|
2024-08-17 20:43:19 +03:00
|
|
|
|
.use_markup(true)
|
|
|
|
|
.label("<b>Комплексная программа для лаб. работ</b>")
|
2024-08-16 22:32:08 +03:00
|
|
|
|
.build(),
|
|
|
|
|
);
|
|
|
|
|
title_bar.append(menu_button.get_button());
|
|
|
|
|
|
|
|
|
|
let header_bar = HeaderBar::builder().title_widget(&title_bar).build();
|
|
|
|
|
|
2024-03-10 11:54:32 +03:00
|
|
|
|
let window = ApplicationWindow::builder()
|
2024-08-15 22:32:42 +03:00
|
|
|
|
.width_request(800)
|
|
|
|
|
.height_request(600)
|
2024-03-10 11:54:32 +03:00
|
|
|
|
.application(application)
|
2024-08-16 22:32:08 +03:00
|
|
|
|
.titlebar(&header_bar)
|
2024-07-19 22:12:42 +03:00
|
|
|
|
.child(&application_box)
|
2024-03-10 11:54:32 +03:00
|
|
|
|
.build();
|
|
|
|
|
|
2024-08-16 22:32:08 +03:00
|
|
|
|
window.insert_action_group("menu_group_action", Some(menu_button.get_actions_group()));
|
|
|
|
|
|
2024-08-16 12:55:24 +03:00
|
|
|
|
window.present();
|
2024-04-14 19:13:15 +03:00
|
|
|
|
}
|