Compare commits
10 Commits
2399903cda
...
cc4ba6168f
Author | SHA1 | Date | |
---|---|---|---|
doryan | cc4ba6168f | ||
doryan | dd2007c895 | ||
doryan | bafa837931 | ||
doryan | f12c499df0 | ||
doryan | ef979fde48 | ||
doryan | ad79c741e7 | ||
doryan | 32fd0305ad | ||
doryan | bbe0f42bb1 | ||
doryan | 5f544f4fe5 | ||
doryan | e6a38f3ffe |
|
@ -2,6 +2,17 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "AIT"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitvec",
|
||||||
|
"gio",
|
||||||
|
"gtk4",
|
||||||
|
"libadwaita",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.21.0"
|
version = "0.21.0"
|
||||||
|
@ -465,17 +476,6 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "laboratory_works"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"bitvec",
|
|
||||||
"gio",
|
|
||||||
"gtk4",
|
|
||||||
"libadwaita",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libadwaita"
|
name = "libadwaita"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "laboratory_works"
|
name = "AIT"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use view::ui::*;
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let app: adw::Application = adw::Application::builder()
|
let app: adw::Application = adw::Application::builder()
|
||||||
.application_id("com.laboratory-work")
|
.application_id("org.gtk-rs.AIT")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
app.connect_activate(ui);
|
app.connect_activate(ui);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
use gio::{glib::Variant, SimpleAction};
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
|
use gtk::{prelude::GtkWindowExt, AboutDialog, Image};
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub fn open_about_dialogue(_action: &SimpleAction, _var: Option<&Variant>) {
|
||||||
|
let logo = Image::from_file(Path::new("./src/view/resources/logo.png"))
|
||||||
|
.paintable()
|
||||||
|
.unwrap();
|
||||||
|
AboutDialog::builder()
|
||||||
|
.authors(vec!["Сагиев А.Д.", "Ефимов И.П."])
|
||||||
|
.version("1.0-beta")
|
||||||
|
.logo(&logo)
|
||||||
|
.website("https://gitea.doryan04.ru/doryan/AIT")
|
||||||
|
.build()
|
||||||
|
.present();
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
use std::fmt::{Debug, Display};
|
||||||
|
|
||||||
|
use gtk4 as gtk;
|
||||||
|
|
||||||
|
use gio::{
|
||||||
|
glib::Variant, prelude::ActionMapExtManual, ActionEntry, Menu, SimpleAction, SimpleActionGroup,
|
||||||
|
};
|
||||||
|
|
||||||
|
use gtk::{MenuButton, PopoverMenu};
|
||||||
|
|
||||||
|
pub struct HeaderMenu<T> {
|
||||||
|
model: Menu,
|
||||||
|
actions_group: (SimpleActionGroup, Option<T>),
|
||||||
|
button: MenuButton,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> HeaderMenu<T>
|
||||||
|
where
|
||||||
|
T: Into<String> + Debug + Display + Clone,
|
||||||
|
{
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let menu_btn = MenuButton::builder().icon_name("open-menu").build();
|
||||||
|
let menu_model = Menu::new();
|
||||||
|
let menu_popover = PopoverMenu::from_model(Some(&menu_model));
|
||||||
|
|
||||||
|
menu_btn.set_popover(Some(&menu_popover));
|
||||||
|
|
||||||
|
let action_group = SimpleActionGroup::new();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
model: menu_model,
|
||||||
|
actions_group: (action_group, None),
|
||||||
|
button: menu_btn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_action_group_name(&mut self, name: Option<T>) {
|
||||||
|
self.actions_group.1 = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_button(&self) -> &MenuButton {
|
||||||
|
&self.button
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_model(&self) -> &Menu {
|
||||||
|
&self.model
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_actions_group(&self) -> &SimpleActionGroup {
|
||||||
|
&self.actions_group.0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn append_items<Iterable, F>(&self, items: Iterable)
|
||||||
|
where
|
||||||
|
Iterable: IntoIterator<Item = (F, &'static str, &'static str)>,
|
||||||
|
F: Fn(&SimpleAction, Option<&Variant>) + 'static,
|
||||||
|
{
|
||||||
|
for (callback, action_name, action_label) in items {
|
||||||
|
let action = ActionEntry::<SimpleActionGroup>::builder(action_name)
|
||||||
|
.activate(move |_, a, b| callback(a, b))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let action_path = &*format!(
|
||||||
|
"{}.{}",
|
||||||
|
self.actions_group
|
||||||
|
.1
|
||||||
|
.clone()
|
||||||
|
.expect("ActionGroupName isn't defined"),
|
||||||
|
action_name
|
||||||
|
);
|
||||||
|
|
||||||
|
self.actions_group.0.add_action_entries([action]);
|
||||||
|
|
||||||
|
self.model.append(Some(action_label), Some(action_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
|
pub mod about;
|
||||||
pub mod info_bar;
|
pub mod info_bar;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
pub mod menu;
|
||||||
pub mod pages;
|
pub mod pages;
|
||||||
pub mod tabs;
|
pub mod tabs;
|
||||||
pub mod wrapper;
|
|
||||||
|
|
||||||
use crate::model::builder_traits;
|
use crate::model::builder_traits;
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
use gtk4 as gtk;
|
|
||||||
|
|
||||||
use gtk::{Orientation, builders::BoxBuilder, Box};
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct Wrapper;
|
|
||||||
|
|
||||||
impl Wrapper{
|
|
||||||
|
|
||||||
pub fn row_builder() -> BoxBuilder {
|
|
||||||
Box::builder().orientation(Orientation::Vertical)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn col_builder() -> BoxBuilder {
|
|
||||||
Box::builder().orientation(Orientation::Horizontal)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ use gtk4 as gtk;
|
||||||
use crate::{
|
use crate::{
|
||||||
model::builder_traits::Product,
|
model::builder_traits::Product,
|
||||||
view::{
|
view::{
|
||||||
components::{info_bar::InfoBar, input::Input, wrapper::*},
|
components::{info_bar::InfoBar, input::Input},
|
||||||
properties::*,
|
properties::*,
|
||||||
},
|
},
|
||||||
view_utils::{hamming_code_utils::start_hamming_algorithm, input_utils::clearing},
|
view_utils::{hamming_code_utils::start_hamming_algorithm, input_utils::clearing},
|
||||||
|
@ -47,13 +47,15 @@ pub fn hamming_code_page(wrapper: &Box) {
|
||||||
|
|
||||||
let crypt_mode_label = Label::builder().label("Режим: кодирование").build();
|
let crypt_mode_label = Label::builder().label("Режим: кодирование").build();
|
||||||
|
|
||||||
let crypt_mode_wrapper = Wrapper::col_builder()
|
let crypt_mode_wrapper = Box::builder()
|
||||||
|
.orientation(Orientation::Horizontal)
|
||||||
.set_align(Alignment::new(Align::Fill, Align::Center))
|
.set_align(Alignment::new(Align::Fill, Align::Center))
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let action_components_wrapper = Wrapper::col_builder()
|
let action_components_wrapper = Box::builder()
|
||||||
|
.orientation(Orientation::Horizontal)
|
||||||
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
||||||
.set_margin(MarginData::MultipleMargin((0, 5, 0, 5)))
|
.set_margin(MarginData::MultipleMargin((0, 5, 0, 5)))
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
|
|
|
@ -132,11 +132,10 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||||
|
|
||||||
let new_elem = Frequency::new(values.get().frequency);
|
let new_elem = Frequency::new(values.get().frequency);
|
||||||
|
|
||||||
let exist_elem_pos = find_by_frequency_value(&model, &new_elem);
|
if find_by_frequency_value(&model, &new_elem).is_none() {
|
||||||
|
|
||||||
if exist_elem_pos.is_none() {
|
|
||||||
model.append(&new_elem);
|
model.append(&new_elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_column_view(&result_table);
|
update_column_view(&result_table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -1,13 +1,12 @@
|
||||||
use crate::model::builder_traits::*;
|
use crate::model::builder_traits::*;
|
||||||
|
|
||||||
|
use adw::HeaderBar;
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
use gtk::{prelude::*, StackTransitionType::SlideLeftRight, *};
|
||||||
use info_bar::InfoBar;
|
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
use crate::view::{
|
use crate::view::{
|
||||||
components::{pages::Pages, wrapper::*, *},
|
components::{about::open_about_dialogue, info_bar::InfoBar, menu::HeaderMenu, pages::Pages},
|
||||||
pages::*,
|
pages::*,
|
||||||
properties::*,
|
properties::*,
|
||||||
};
|
};
|
||||||
|
@ -17,7 +16,8 @@ use super::styles::load_css;
|
||||||
pub fn ui(application: &adw::Application) {
|
pub fn ui(application: &adw::Application) {
|
||||||
load_css();
|
load_css();
|
||||||
|
|
||||||
let hamming_code = Wrapper::row_builder()
|
let hamming_code = Box::builder()
|
||||||
|
.orientation(Orientation::Vertical)
|
||||||
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
||||||
.set_margin(MarginData::EqualsMargin(15))
|
.set_margin(MarginData::EqualsMargin(15))
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
|
@ -30,7 +30,8 @@ pub fn ui(application: &adw::Application) {
|
||||||
|
|
||||||
hamming_code::hamming_code_page(&hamming_code);
|
hamming_code::hamming_code_page(&hamming_code);
|
||||||
|
|
||||||
let signal_reducing = Wrapper::row_builder()
|
let signal_reducing = Box::builder()
|
||||||
|
.orientation(Orientation::Vertical)
|
||||||
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
.set_align(Alignment::new(Align::Fill, Align::Fill))
|
||||||
.set_margin(MarginData::EqualsMargin(15))
|
.set_margin(MarginData::EqualsMargin(15))
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
|
@ -51,13 +52,35 @@ pub fn ui(application: &adw::Application) {
|
||||||
application_box.append(info_bar.get());
|
application_box.append(info_bar.get());
|
||||||
application_box.append(pages.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()
|
let window = ApplicationWindow::builder()
|
||||||
.title("Комплексная программа для лаб. работ")
|
|
||||||
.width_request(800)
|
.width_request(800)
|
||||||
.height_request(600)
|
.height_request(600)
|
||||||
.application(application)
|
.application(application)
|
||||||
|
.titlebar(&header_bar)
|
||||||
.child(&application_box)
|
.child(&application_box)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
window.insert_action_group("menu_group_action", Some(menu_button.get_actions_group()));
|
||||||
|
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue