Compare commits
No commits in common. "2399903cda6b3a9cd431eb4c1732a9c643181db4" and "62b703693371a504a82aa265be7264feea35c512" have entirely different histories.
2399903cda
...
62b7036933
|
@ -8,7 +8,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
|
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
|
||||||
bitvec = "1.0.1"
|
bitvec = "1.0.1"
|
||||||
gio = { version = "0.20.0", features = ["v2_74"] }
|
gio = {version = "0.20.0", features = ["v2_74"]}
|
||||||
gtk4 = { version = "0.9.0", features = ["v4_12"] }
|
gtk4 = { version = "0.9.0"}
|
||||||
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }
|
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use gio::glib::Object;
|
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -10,7 +9,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
prelude::{Cast, CastNone, EditableExt, ListItemExt, WidgetExt},
|
prelude::{Cast, CastNone, EditableExt, ListItemExt, ObjectExt, WidgetExt},
|
||||||
ColumnView, Entry, Label, ListItem, SignalListItemFactory,
|
ColumnView, Entry, Label, ListItem, SignalListItemFactory,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,12 +42,12 @@ pub fn parse_fields(all_inputs: Vec<Input<Entry>>) -> Result<SignalReduce> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn update_column_view(column_view: &ColumnView) {
|
pub fn update_column_view(column_view: &ColumnView) {
|
||||||
column_view.set_visible(false);
|
column_view.hide();
|
||||||
column_view.set_visible(true);
|
column_view.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn column_view_setup_factory(_factory: &SignalListItemFactory, list_item: &Object) {
|
pub fn column_view_setup_factory(_factory: &SignalListItemFactory, list_item: &ListItem) {
|
||||||
list_item
|
list_item
|
||||||
.downcast_ref::<ListItem>()
|
.downcast_ref::<ListItem>()
|
||||||
.expect("Needs to be ListItem")
|
.expect("Needs to be ListItem")
|
||||||
|
@ -57,7 +56,7 @@ pub fn column_view_setup_factory(_factory: &SignalListItemFactory, list_item: &O
|
||||||
|
|
||||||
pub fn column_view_bind_factory(
|
pub fn column_view_bind_factory(
|
||||||
_factory: &SignalListItemFactory,
|
_factory: &SignalListItemFactory,
|
||||||
list_item: &Object,
|
list_item: &ListItem,
|
||||||
values: SignalReduce,
|
values: SignalReduce,
|
||||||
label: &str,
|
label: &str,
|
||||||
) {
|
) {
|
||||||
|
@ -75,26 +74,37 @@ pub fn column_view_bind_factory(
|
||||||
.and_downcast::<Label>()
|
.and_downcast::<Label>()
|
||||||
.expect("The child has to be a `Label`.");
|
.expect("The child has to be a `Label`.");
|
||||||
|
|
||||||
cell_value.set_reactive_resist(reactive_resistance_of_capacitor(
|
cell_value
|
||||||
values.wire_capacity * 10f64.powi(-12),
|
.bind_property("frequency", &cell_label, "label")
|
||||||
values.length,
|
.sync_create()
|
||||||
cell_value.frequency() * 10f64.powi(6),
|
.build();
|
||||||
));
|
|
||||||
|
|
||||||
cell_value.set_full_resistance(full_resistance_of_capacitor(
|
if cell_value.reactive_resist() == 0.0 {
|
||||||
cell_value.reactive_resist(),
|
cell_value.set_reactive_resist(reactive_resistance_of_capacitor(
|
||||||
values.source_resistance,
|
values.wire_capacity * 10f64.powi(-12),
|
||||||
values.wire_resistance,
|
values.length,
|
||||||
values.length,
|
cell_value.frequency() * 10f64.powi(6),
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
cell_value.set_signal_source_voltage(
|
if cell_value.full_resistance() == 0.0 {
|
||||||
voltage_from_signal_source(
|
cell_value.set_full_resistance(full_resistance_of_capacitor(
|
||||||
values.source_voltage * 10f64.powi(-3),
|
|
||||||
cell_value.reactive_resist(),
|
cell_value.reactive_resist(),
|
||||||
cell_value.full_resistance(),
|
values.source_resistance,
|
||||||
) * 1000.0,
|
values.wire_resistance,
|
||||||
);
|
values.length,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if cell_value.signal_source_voltage() == 0.0 {
|
||||||
|
cell_value.set_signal_source_voltage(
|
||||||
|
voltage_from_signal_source(
|
||||||
|
values.source_voltage * 10f64.powi(-3),
|
||||||
|
cell_value.reactive_resist(),
|
||||||
|
cell_value.full_resistance(),
|
||||||
|
) * 1000.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
match label {
|
match label {
|
||||||
"f, МГц" => {
|
"f, МГц" => {
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum HammingMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Default, Copy, Clone, Debug, PartialEq)]
|
#[derive(Default, Copy, Clone, Debug)]
|
||||||
pub struct SignalReduce {
|
pub struct SignalReduce {
|
||||||
pub length: f64,
|
pub length: f64,
|
||||||
pub wire_resistance: f64,
|
pub wire_resistance: f64,
|
||||||
|
|
|
@ -124,20 +124,18 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||||
result_table,
|
result_table,
|
||||||
move |_| match parse_fields(all_inputs.clone()) {
|
move |_| match parse_fields(all_inputs.clone()) {
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
if values.get() == results {
|
values.set(results);
|
||||||
info_bar.set_text_label(Some("Эти данные уже были введены."));
|
|
||||||
|
let new_elem = Frequency::new(values.get().frequency);
|
||||||
|
|
||||||
|
let exist_elem_pos = find_by_frequency_value(&model, &new_elem);
|
||||||
|
|
||||||
|
if exist_elem_pos.is_some() {
|
||||||
|
info_bar.set_text_label(Some("Данная частота уже была задана."));
|
||||||
info_bar.show_infobar(5u64);
|
info_bar.show_infobar(5u64);
|
||||||
} else {
|
} else {
|
||||||
values.set(results);
|
model.append(&new_elem);
|
||||||
|
update_column_view(&result_table)
|
||||||
let new_elem = Frequency::new(values.get().frequency);
|
|
||||||
|
|
||||||
let exist_elem_pos = find_by_frequency_value(&model, &new_elem);
|
|
||||||
|
|
||||||
if exist_elem_pos.is_none() {
|
|
||||||
model.append(&new_elem);
|
|
||||||
}
|
|
||||||
update_column_view(&result_table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
|
@ -1,28 +1,2 @@
|
||||||
#info_bar{
|
@import url("info_bar.css");
|
||||||
background-color:#F1E6D9;
|
@import url("text_view.css");
|
||||||
padding: 5px;
|
|
||||||
font-size: 11pt;
|
|
||||||
}
|
|
||||||
#info_bar > button {
|
|
||||||
transform: scale(0.9);
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
#info_bar > button:hover {
|
|
||||||
background-color: #00000010;
|
|
||||||
}
|
|
||||||
#info_bar > button:active {
|
|
||||||
background-color: #00000020;
|
|
||||||
}
|
|
||||||
textview {
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 7px 8px;
|
|
||||||
background: #E6E6E6;
|
|
||||||
outline-offset: 2px;
|
|
||||||
outline: 2px solid #81ABDF00;
|
|
||||||
transition-duration: .15s;
|
|
||||||
transition-timing-function: ease-in-out;
|
|
||||||
}
|
|
||||||
textview:focus-within {
|
|
||||||
outline-offset: -2px;
|
|
||||||
outline: 2px solid #81ABDF;
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#info_bar{
|
||||||
|
background-color:#F1E6D9;
|
||||||
|
padding: 5px;
|
||||||
|
font-size: 11pt;
|
||||||
|
}
|
||||||
|
#info_bar > button {
|
||||||
|
transform: scale(0.9);
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
#info_bar > button:hover {
|
||||||
|
background-color: #00000010;
|
||||||
|
}
|
||||||
|
#info_bar > button:active {
|
||||||
|
background-color: #00000020;
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
use adw::gdk::Display;
|
use adw::gdk::Display;
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{
|
||||||
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION,
|
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
};
|
};
|
||||||
|
@ -8,7 +10,7 @@ use gtk::{
|
||||||
pub fn load_css() {
|
pub fn load_css() {
|
||||||
let style_provider = CssProvider::new();
|
let style_provider = CssProvider::new();
|
||||||
|
|
||||||
style_provider.load_from_string(include_str!("base.css"));
|
style_provider.load_from_path(Path::new("./src/view/styles/base.css"));
|
||||||
|
|
||||||
style_context_add_provider_for_display(
|
style_context_add_provider_for_display(
|
||||||
&Display::default().expect("Could not connect to a display"),
|
&Display::default().expect("Could not connect to a display"),
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
textview {
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 7px 8px;
|
||||||
|
background: #E6E6E6;
|
||||||
|
outline-offset: 2px;
|
||||||
|
outline: 2px solid #81ABDF00;
|
||||||
|
transition-duration: .15s;
|
||||||
|
transition-timing-function: ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
textview:focus-within {
|
||||||
|
outline-offset: -2px;
|
||||||
|
outline: 2px solid #81ABDF;
|
||||||
|
}
|
|
@ -59,5 +59,5 @@ pub fn ui(application: &adw::Application) {
|
||||||
.child(&application_box)
|
.child(&application_box)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
window.present();
|
window.show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue