Compare commits

..

No commits in common. "2399903cda6b3a9cd431eb4c1732a9c643181db4" and "62b703693371a504a82aa265be7264feea35c512" have entirely different histories.

9 changed files with 81 additions and 68 deletions

View File

@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
bitvec = "1.0.1"
gio = { version = "0.20.0", features = ["v2_74"] }
gtk4 = { version = "0.9.0", features = ["v4_12"] }
gio = {version = "0.20.0", features = ["v2_74"]}
gtk4 = { version = "0.9.0"}
tokio = { version = "1.39.2", features = ["rt", "time", "rt-multi-thread", "macros", "sync"] }

View File

@ -1,4 +1,3 @@
use gio::glib::Object;
use gtk4 as gtk;
use std::str::FromStr;
@ -10,7 +9,7 @@ use crate::{
};
use gtk::{
prelude::{Cast, CastNone, EditableExt, ListItemExt, WidgetExt},
prelude::{Cast, CastNone, EditableExt, ListItemExt, ObjectExt, WidgetExt},
ColumnView, Entry, Label, ListItem, SignalListItemFactory,
};
@ -43,12 +42,12 @@ pub fn parse_fields(all_inputs: Vec<Input<Entry>>) -> Result<SignalReduce> {
#[inline]
pub fn update_column_view(column_view: &ColumnView) {
column_view.set_visible(false);
column_view.set_visible(true);
column_view.hide();
column_view.show();
}
#[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
.downcast_ref::<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(
_factory: &SignalListItemFactory,
list_item: &Object,
list_item: &ListItem,
values: SignalReduce,
label: &str,
) {
@ -75,19 +74,29 @@ pub fn column_view_bind_factory(
.and_downcast::<Label>()
.expect("The child has to be a `Label`.");
cell_value
.bind_property("frequency", &cell_label, "label")
.sync_create()
.build();
if cell_value.reactive_resist() == 0.0 {
cell_value.set_reactive_resist(reactive_resistance_of_capacitor(
values.wire_capacity * 10f64.powi(-12),
values.length,
cell_value.frequency() * 10f64.powi(6),
));
}
if cell_value.full_resistance() == 0.0 {
cell_value.set_full_resistance(full_resistance_of_capacitor(
cell_value.reactive_resist(),
values.source_resistance,
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),
@ -95,6 +104,7 @@ pub fn column_view_bind_factory(
cell_value.full_resistance(),
) * 1000.0,
);
}
match label {
"f, МГц" => {

View File

@ -16,7 +16,7 @@ pub enum HammingMode {
}
#[allow(dead_code)]
#[derive(Default, Copy, Clone, Debug, PartialEq)]
#[derive(Default, Copy, Clone, Debug)]
pub struct SignalReduce {
pub length: f64,
pub wire_resistance: f64,

View File

@ -124,20 +124,18 @@ pub fn signal_reducing_page(wrapper: &Box) {
result_table,
move |_| match parse_fields(all_inputs.clone()) {
Ok(results) => {
if values.get() == results {
info_bar.set_text_label(Some("Эти данные уже были введены."));
info_bar.show_infobar(5u64);
} else {
values.set(results);
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() {
if exist_elem_pos.is_some() {
info_bar.set_text_label(Some("Данная частота уже была задана."));
info_bar.show_infobar(5u64);
} else {
model.append(&new_elem);
}
update_column_view(&result_table);
update_column_view(&result_table)
}
}
Err(error) => {

View File

@ -1,28 +1,2 @@
#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;
}
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;
}
@import url("info_bar.css");
@import url("text_view.css");

View File

@ -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;
}

View File

@ -1,6 +1,8 @@
use adw::gdk::Display;
use gtk4 as gtk;
use std::path::Path;
use gtk::{
style_context_add_provider_for_display, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION,
};
@ -8,7 +10,7 @@ use gtk::{
pub fn load_css() {
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(
&Display::default().expect("Could not connect to a display"),

View File

@ -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;
}

View File

@ -59,5 +59,5 @@ pub fn ui(application: &adw::Application) {
.child(&application_box)
.build();
window.present();
window.show();
}