diff --git a/.idea/dictionaries/paranid5.xml b/.idea/dictionaries/paranid5.xml
new file mode 100644
index 0000000..ac685fd
--- /dev/null
+++ b/.idea/dictionaries/paranid5.xml
@@ -0,0 +1,7 @@
+
+
+
+ paranid
+
+
+
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index b602f12..62f74ed 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,21 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "android-tzdata"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "autocfg"
version = "1.0.1"
@@ -10,36 +25,53 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
-version = "1.2.1"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "booklibrs"
-version = "1.1.9"
+version = "1.2.0"
dependencies = [
"chrono",
- "fltk 0.16.5",
+ "fltk",
"fltk-calendar",
"yaml-rust",
]
+[[package]]
+name = "bumpalo"
+version = "3.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
+
[[package]]
name = "cc"
-version = "1.0.66"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
-version = "0.4.19"
+version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
+checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
dependencies = [
- "libc",
- "num-integer",
+ "android-tzdata",
+ "iana-time-zone",
+ "js-sys",
"num-traits",
"time",
+ "wasm-bindgen",
"winapi",
]
@@ -53,91 +85,99 @@ dependencies = [
]
[[package]]
-name = "fltk"
-version = "0.16.4"
+name = "core-foundation-sys"
+version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "883b9420ac7a803357a762ce532394a2f76f6fa6eef5b22209b614bf301c42b1"
+checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
dependencies = [
- "bitflags",
- "fltk-derive 0.16.4",
- "fltk-sys 0.16.4",
- "lazy_static",
- "objc",
- "raw-window-handle",
+ "cfg-if",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
+dependencies = [
+ "cfg-if",
]
[[package]]
name = "fltk"
-version = "0.16.5"
-source = "git+https://github.com/MoAlyousef/fltk-rs#f7f6da14ab210acd54db2140bd210005d642e706"
+version = "1.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d42b3f65dbb1fa926afd14dfddf252a73bf1bd4c82c82ef24fcade2d939d1cf6"
dependencies = [
"bitflags",
- "fltk-derive 0.16.5",
- "fltk-sys 0.16.5",
- "lazy_static",
- "objc",
- "raw-window-handle",
+ "crossbeam-channel",
+ "fltk-sys",
+ "paste",
+ "ttf-parser",
]
[[package]]
name = "fltk-calendar"
-version = "0.2.0"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "00d6f08b5146544a10f6eae72fc3fdd9099a75ca3b6a0652434921327db40277"
+checksum = "ce3b50107b2f78bda554f99ad642c6e694d66146056b70df2ee68848165b45ca"
dependencies = [
"chrono",
- "fltk 0.16.4",
+ "fltk",
]
[[package]]
-name = "fltk-derive"
-version = "0.16.4"
+name = "fltk-sys"
+version = "1.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "428b021d5c90f23fbd5ad6e95a5bdefda12ce9ff9ba10d9a9c18104dadfbd156"
+checksum = "aa7b7a55f195f791f3e8df2e4e9561a0f5582457665b8011730815b7e80baf28"
dependencies = [
- "quote",
- "syn",
+ "cmake",
]
[[package]]
-name = "fltk-derive"
-version = "0.16.5"
-source = "git+https://github.com/MoAlyousef/fltk-rs#f7f6da14ab210acd54db2140bd210005d642e706"
+name = "iana-time-zone"
+version = "0.1.57"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613"
dependencies = [
- "quote",
- "syn",
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "wasm-bindgen",
+ "windows",
]
[[package]]
-name = "fltk-sys"
-version = "0.16.4"
+name = "iana-time-zone-haiku"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aefc17808df8f75a533c6d4f34ae39cfc09b33d76a95cd1e82052fce17b8bd27"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
- "cmake",
- "libc",
+ "cc",
]
[[package]]
-name = "fltk-sys"
-version = "0.16.5"
-source = "git+https://github.com/MoAlyousef/fltk-rs#f7f6da14ab210acd54db2140bd210005d642e706"
+name = "js-sys"
+version = "0.3.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
dependencies = [
- "cmake",
- "libc",
+ "wasm-bindgen",
]
-[[package]]
-name = "lazy_static"
-version = "1.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-
[[package]]
name = "libc"
-version = "0.2.92"
+version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714"
+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "linked-hash-map"
@@ -146,23 +186,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
-name = "malloc_buf"
-version = "0.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "num-integer"
-version = "0.1.44"
+name = "log"
+version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
-dependencies = [
- "autocfg",
- "num-traits",
-]
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "num-traits"
@@ -174,50 +201,44 @@ dependencies = [
]
[[package]]
-name = "objc"
-version = "0.2.7"
+name = "once_cell"
+version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
-dependencies = [
- "malloc_buf",
-]
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
-name = "proc-macro2"
-version = "1.0.26"
+name = "paste"
+version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
-dependencies = [
- "unicode-xid",
-]
+checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
-name = "quote"
-version = "1.0.9"
+name = "proc-macro2"
+version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
+checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [
- "proc-macro2",
+ "unicode-ident",
]
[[package]]
-name = "raw-window-handle"
-version = "0.3.3"
+name = "quote"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
- "libc",
+ "proc-macro2",
]
[[package]]
name = "syn"
-version = "1.0.68"
+version = "2.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
+checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
dependencies = [
"proc-macro2",
"quote",
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
@@ -232,10 +253,16 @@ dependencies = [
]
[[package]]
-name = "unicode-xid"
-version = "0.2.1"
+name = "ttf-parser"
+version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "wasi"
@@ -243,6 +270,60 @@ version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
+dependencies = [
+ "cfg-if",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
+dependencies = [
+ "bumpalo",
+ "log",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.87"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
+
[[package]]
name = "winapi"
version = "0.3.9"
@@ -265,6 +346,72 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+[[package]]
+name = "windows"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
[[package]]
name = "yaml-rust"
version = "0.4.5"
diff --git a/Cargo.toml b/Cargo.toml
index 2b1e935..08c59c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,15 +1,15 @@
[package]
name = "booklibrs"
-version = "1.1.9"
+version = "1.2.0"
authors = ["Paranid5 "]
-edition = "2018"
+edition = "2021"
license = "MIT/Apache-2.0"
description = "Book libarary project including giveaway operations and gui interface."
homepage = "https://github.com/dinaraparanid/Library_rs"
-documentation = "https://docs.rs/booklibrs/1.1.9/booklibrs/"
+documentation = "https://docs.rs/booklibrs/1.2.0/booklibrs/"
[dependencies]
-chrono = "0.4.19"
-fltk = { version = "^0.16", git = "https://github.com/MoAlyousef/fltk-rs" }
-fltk-calendar = "0.2.0"
+chrono = "0.4.26"
+fltk = "1.4.9"
+fltk-calendar = "0.4.0"
yaml-rust = "0.4.5"
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 929f4ed..fc4c1ad 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2022 Paranid5
+ Copyright 2021 Paranid5
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index 4131559..938b7b3 100644
--- a/README.md
+++ b/README.md
@@ -1,91 +1,90 @@
-**Author**:
---------------------------
-**dinaraparanid (Follow me on github: https://github.com/dinaraparanid)**
-
-**Licence**:
---------------------------
-MIT or Apache-2.0
-
-**Documentation**:
---------------------------
-
- public: https://docs.rs/binartree/1.1.9/booklibrs/
-
- private (whole project): go to librs/target/doc/booklibrs/all.html (click on it)
-**About project**:
---------------------------
-This is a project that aims to create a system for issuing books in libraries.
-The entire project is written in the *Rust programming language* using the *fltk, chrono,* and *yaml_rust* crates.
-
-**How to use**:
---------------------------
-
-**1. Start**
---------------------------
-
-If you a *windows user*, you need to just press on run.bat, and programme'll start working.
-
-If you are *not windows user*, than you need to install
-*Rust compiler*: https://www.rust-lang.org/tools/install
-*C/C++ MVSC compiler* (**NOT MinGW!!!**): https://visualstudio.microsoft.com/vs/features/cplusplus/
-*Git*: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
-*CMake*: https://cmake.org/install/
-
-After that you need to use your console, go to project direction, write "*cargo run --release*" and programme'll start working.
-
-**2. Tools**
---------------------------
-First of all you will see a table. It contains all readers in an ascending order and their reading status (book / start date / finish date)
-In main menu (on the left top corner) you will see 6 sub menus: "Readers", "Books", "Giveaway", "Restore", "Language", "Help".
-
-**Reader menu**: contains all action that you can do with readers: Add, Remove, Change 1-st name, 2-nd name, mid. name, get information.
-There are also 2 types of getting info: with books that reader is reading now and with all books that reader read
-(all existing books in library, if you delete book, it will not be shown.)
-All these action requires your input. But you can simply click on reader you need in main table and all needed action will be there
+**Library-Rs**
+--------------
+
+[](https://www.rust-lang.org)
+
+## **Developer**
+[Paranid5](https://github.com/dinaraparanid)
+
+## **About project**:
+This is a project that aims to create a system for issuing books in libraries
+
+*[Documentation](https://docs.rs/binartree/1.1.9/booklibrs/)*
+
+### **Preview**
+
+[video](preview.webm)
+
+
+
+### **Description**
+First of all, you will see a table.
+It contains all readers in ascending order and their reading status (book / start date / finish date)
+In the main menu (on the left top corner) you will see 6 sub menus: "Readers", "Books", "Giveaway", "Restore", "Language", "Help".
+
+**Reader menu**: contains all actions that you can do with readers: Add, Remove, Change 1-st name, 2-nd name, mid. Name, get information.
+There are also two types of getting info: with books that reader is reading now and with all books that reader read
+(all existing books in a library, if you delete book, it will not be shown.)
+All these actions require your input. But you can simply click on reader you need in the main table and all needed action will be there
(except adding reader, that's can't handle without input)
**Book menu**:
-1) Add books (if book in library, it'll add new books, else it'll create new books in library)
-2) Remove book. You can remove only one book in this action. Requires number of book.
-3) Remove all specific books. It'll remove all books with same title, author and amount of pages.
-4) Change title, author, amount of pages. I think it'll be obvious.
-5) Change book's location. You'll change cabinet and shelf where book is located. I don't know anything about your library, so I can't
- control your input
+1) Add books (if a book in a library, it'll add new books, else it'll create new books in a library)
+2) Remove a book. You can remove only one book in this action. Requires number of books.
+3) Remove all specific books. It'll remove all books with the same title, author and number of pages.
+4) Change title, author, number of pages. I think it'll be obvious.
+5) Change the book's location.
+ You'll change cabinet and shelf where book is located.
+ I don't know anything about your library, so I can't
+ control your input
6) Get type book's information. As for reader, you'll get a window with info and all actions for it.
-7) Get current book's information. You'll get info window about current book. Also you can change location (cabinet and shelf) of book.
+7) Get the current book's information. You'll get info window about a current book. Also you can change location (cabinet and shelf) of book.
8) List of all books by authors. Window with all books sorted by authors. Authors sorted by ascending.
9) List of all books.
**Genres menu**:
1) List of all books by genres. Sort all books by genres.
-2) Add genre / Remove genre. By default it'll be no genres, so, you need to add it. It can be anything, so you can use your imagination :)
-3) Customize book genres. You'll get window with genres. You need to choose genre. If book has some genres, it'll be a check mark near genre
+2) Add genre / Remove genre. By default, it'll be no genre, so you need to add it. It can be anything, so you can use your imagination :)
+3) Customize book genres. You'll get a window with genres. You need to choose genre. If a book has some genres, it'll be a check mark near genre
**Giveaway menu** is a menu for giving and returning books.
-1) Give book. Requires input for reader and book. At the end you need to choose return date. Also you can do it in reader info
-(or just click on reader)
-2) Get book from reader. Requires reader input. Also you can do it in reader info or click on reader.
-3) Change return date. You can also click on return date in main table and change it.
+1) Give a book.
+ Requires to be input for reader and book.
+ In the end, you need to choose return date.
+ Also, you can do it in reader info
+ (or just click on reader)
+2) Get a book from reader. Requires reader input. Also, you can do it in reader info or click on reader.
+3) Change return date. You can also click on return date in the main table and change it.
**Restore menu**:
-1) Restore previous data. Also you can use Ctrl-Z.
-2) Restore next date. Also you can use Ctrl-Shift-Z.
+1) Restore previous data. Also, you can use Ctrl-Z.
+2) Restore next date. Also, you can use Ctrl-Shift-Z.
-In **language menu** you can choose language. My languages are Russian and English, so I don't add others,
+In **language menu** you can choose language.
+My languages are Russian and English, so I don't add others,
so I hope your english is not worse than mine :D
-In **Help** menu you can read same things if you forgot something.
+In the **Help menu**, you can read the same things if you forgot something.
-Screenshot
---------------------------
+### **Stack**
-
+
+ - Rust 2021 edition
+ - FLTK-rs
+ - Yaml-Rust
+
-**Enjoy!**
---------------------------
+## **Setup**
-*Full version with all decompiled files (recommend to download from here):
- https://drive.google.com/drive/u/0/folders/1mOTWStFbS_NS7iYs0uxS6MlT9jv8qZRf*
+1. Install [all necessary libraries for FLTK](https://fltk-rs.github.io/fltk-book/Setup.html)
+2. Clone from git and compile project:
+```shell
+git clone https://github.com/dinaraparanid/Library_rs.git
+cd Library_rs
+cargo run --release
+```
+## **License**
+*MIT or Apache-2.0*
diff --git a/preview.webm b/preview.webm
new file mode 100644
index 0000000..08d1d87
Binary files /dev/null and b/preview.webm differ
diff --git a/run.bat b/run.bat
deleted file mode 100644
index 9d946ca..0000000
--- a/run.bat
+++ /dev/null
@@ -1 +0,0 @@
-start "" "target\release/booklibrs.exe"
\ No newline at end of file
diff --git a/src/actions/book/info/full.rs b/src/actions/book/info/full.rs
index 678a36a..785d14c 100644
--- a/src/actions/book/info/full.rs
+++ b/src/actions/book/info/full.rs
@@ -21,6 +21,7 @@ use fltk::{
table::Table,
tree::Tree,
window::SingleWindow,
+ enums::Font
};
use std::{cell::RefCell, cmp::max, collections::BTreeMap, rc::Rc};
@@ -192,7 +193,7 @@ pub fn show_all_books(
.center_screen();
let mut table = Table::new(10, 10, 800, 540, "");
- table.set_rows(max(20, (*book_system).borrow().books.len() as u32));
+ table.set_rows(max(20, (*book_system).borrow().books.len() as i32));
table.set_row_header(true);
table.set_cols(4);
table.set_col_header(true);
@@ -201,7 +202,7 @@ pub fn show_all_books(
let bs = book_system.clone();
- table.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ table.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
fltk::table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
fltk::table::TableContext::ColHeader => draw_header(
diff --git a/src/actions/book/info/simple.rs b/src/actions/book/info/simple.rs
index 18e771f..de2a1c1 100644
--- a/src/actions/book/info/simple.rs
+++ b/src/actions/book/info/simple.rs
@@ -19,6 +19,7 @@ use fltk::{
app::App,
dialog::alert,
draw,
+ enums::{Font, Shortcut},
frame::Frame,
group::VGrid,
input::IntInput,
@@ -86,139 +87,125 @@ pub fn book_info_simple(
})
};
- let mut wind = SingleWindow::new(
- 800,
- 100,
- 848,
- 600,
- format!(
- "{} {} {}",
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .title
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .author
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .pages
- },
- )
- .as_str(),
- )
- .center_screen();
+ let label = format!(
+ "{} {} {}",
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .title
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .author
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .pages
+ },
+ );
+
+ let mut wind = SingleWindow::new(800, 100, 848, 600, None)
+ .with_label(label.as_str())
+ .center_screen();
let mut table1 = VGrid::new(0, 0, 908, 170, "");
table1.set_params(6, 1, 1);
- table1.add(&Frame::new(
- 10,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Title",
- Lang::Russian => "Название",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .title
- }
- )
- .as_str(),
- ));
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Title",
+ Lang::Russian => "Название",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .title
+ }
+ );
- table1.add(&Frame::new(
- 30,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Author",
- Lang::Russian => "Автор",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .author
- }
- )
- .as_str(),
- ));
-
- table1.add(&Frame::new(
- 50,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Amount of Pages",
- Lang::Russian => "Кол-во страниц",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .pages
- },
- )
- .as_str(),
- ));
-
- table1.add(&Frame::new(
- 70,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Order Number",
- Lang::Russian => "Порядковый номер",
- },
- get_book_ind(&*(*book_system).borrow(), unsafe {
- (**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind)
- .as_ptr()
- }),
- )
- .as_str(),
- ));
-
- table1.add(&Frame::new(
- 90,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Now is Read By",
- Lang::Russian => "В данный момент читается",
- },
- if unsafe {
+ table1.add(&Frame::new(10, 50, 100, 30, None).with_label(label.as_str()));
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Author",
+ Lang::Russian => "Автор",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .author
+ }
+ );
+
+ table1.add(&Frame::new(30, 50, 100, 30, None).with_label(label.as_str()));
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Amount of Pages",
+ Lang::Russian => "Кол-во страниц",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .pages
+ },
+ );
+
+ table1.add(&Frame::new(50, 50, 100, 30, None).with_label(label.as_str()));
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Order Number",
+ Lang::Russian => "Порядковый номер",
+ },
+ get_book_ind(&*(*book_system).borrow(), unsafe {
+ (**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .books
+ .get_unchecked(s_ind)
+ .as_ptr()
+ }),
+ );
+
+ table1.add(&Frame::new(70, 50, 100, 30, None).with_label(label.as_str()));
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Now is Read By",
+ Lang::Russian => "В данный момент читается",
+ },
+ if unsafe {
+ (**(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .borrow()
+ .books
+ .get_unchecked(s_ind))
+ .borrow()
+ .is_using
+ } {
+ unsafe {
(**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
.books
.get_unchecked(s_ind))
.borrow()
- .is_using
- } {
- unsafe {
- (**(**(*book_system).borrow().books.get_unchecked(t_ind))
+ .readers
+ .last()
+ .unwrap()
+ .0
+ .upgrade()
+ .unwrap()
+ .borrow()
+ .name
+ .clone()
+ + " "
+ + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
.books
.get_unchecked(s_ind))
@@ -228,135 +215,105 @@ pub fn book_info_simple(
.unwrap()
.0
.upgrade()
- .unwrap()
+ .unwrap())
.borrow()
- .name
- .clone()
- + " "
- + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind))
- .borrow()
- .readers
- .last()
- .unwrap()
- .0
- .upgrade()
- .unwrap())
- .borrow()
- .family
- .as_str()
- + " "
- + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind))
+ .family
+ .as_str()
+ + " "
+ + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
- .readers
- .last()
- .unwrap()
- .0
- .upgrade()
- .unwrap())
- .borrow()
- .father
- .as_str()
- + " "
- + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind))
- .borrow()
- .readers
- .last()
- .unwrap()
- .0
- .upgrade()
- .unwrap())
+ .books
+ .get_unchecked(s_ind))
+ .borrow()
+ .readers
+ .last()
+ .unwrap()
+ .0
+ .upgrade()
+ .unwrap())
+ .borrow()
+ .father
+ .as_str()
+ + " "
+ + (*(**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
- .age()
- .to_string()
- .as_str()
- }
- } else {
- match lang {
- Lang::English => "None",
- Lang::Russian => "Никем",
- }
- .to_string()
+ .books
+ .get_unchecked(s_ind))
+ .borrow()
+ .readers
+ .last()
+ .unwrap()
+ .0
+ .upgrade()
+ .unwrap())
+ .borrow()
+ .age()
+ .to_string()
+ .as_str()
}
- )
- .as_str(),
- ));
-
- let mut cab_frame = Frame::new(
- 110,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
+ } else {
match lang {
- Lang::English => "Cabinet",
- Lang::Russian => "Шкаф",
- },
- unsafe {
- (**(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind))
+ Lang::English => "None",
+ Lang::Russian => "Никем",
+ }
+ .to_string()
+ }
+ );
+
+ table1.add(&Frame::new(90, 50, 100, 30, None).with_label(label.as_str()));
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Cabinet",
+ Lang::Russian => "Шкаф",
+ },
+ unsafe {
+ (**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
- .cabinet
- },
- )
- .as_str(),
+ .books
+ .get_unchecked(s_ind))
+ .borrow()
+ .cabinet
+ },
);
- let mut shelf_frame = Frame::new(
- 130,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Shelf",
- Lang::Russian => "Полка",
- },
- unsafe {
- (**(**(*book_system).borrow().books.get_unchecked(t_ind))
- .borrow()
- .books
- .get_unchecked(s_ind))
+ let mut cab_frame = Frame::new(110, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Shelf",
+ Lang::Russian => "Полка",
+ },
+ unsafe {
+ (**(**(*book_system).borrow().books.get_unchecked(t_ind))
.borrow()
- .shelf
- }
- )
- .as_str(),
+ .books
+ .get_unchecked(s_ind))
+ .borrow()
+ .shelf
+ }
);
+ let mut shelf_frame = Frame::new(130, 50, 100, 30, None).with_label(label.as_str());
+
table1.add(&cab_frame);
table1.add(&shelf_frame);
- table1.add(&Frame::new(
- 150,
- 50,
- 100,
- 30,
- format!(
- "{}:",
- match lang {
- Lang::English => "All Readers",
- Lang::Russian => "Все читатели",
- }
- )
- .as_str(),
- ));
+ let label = format!(
+ "{}:",
+ match lang {
+ Lang::English => "All Readers",
+ Lang::Russian => "Все читатели",
+ }
+ );
+
+ table1.add(&Frame::new(150, 50, 100, 30, None).with_label(label.as_str()));
table1.auto_layout();
- let mut table2 = Table::new(0, 127, 848, 600, "");
+ let mut table2 = Table::new(0, 127, 848, 600, None);
table2.set_rows(max(30, unsafe {
(**(**(*book_system).borrow().books.get_unchecked(t_ind))
@@ -365,7 +322,7 @@ pub fn book_info_simple(
.get_unchecked(s_ind))
.borrow()
.readers
- .len() as u32
+ .len() as i32
}));
table2.set_row_header(true);
@@ -379,10 +336,10 @@ pub fn book_info_simple(
let bs = book_system.clone();
- table2.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
- fltk::table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
+ table2.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
+ table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
- fltk::table::TableContext::ColHeader => draw_header(
+ table::TableContext::ColHeader => draw_header(
&format!(
"{}",
match col {
@@ -423,9 +380,9 @@ pub fn book_info_simple(
h,
),
- fltk::table::TableContext::RowHeader => draw_header(&format!("{}", row + 1), x, y, w, h),
+ table::TableContext::RowHeader => draw_header(&format!("{}", row + 1), x, y, w, h),
- fltk::table::TableContext::Cell => draw_data(
+ table::TableContext::Cell => draw_data(
&format!(
"{}",
cell_reader2(
@@ -618,131 +575,100 @@ pub fn the_book_info_simple(
lang: Lang,
main_table: &mut Table,
) {
- let mut wind = SingleWindow::new(
- 800,
- 100,
- 520,
- 600,
- format!(
- "{} {}",
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .title
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .author
- }
- )
- .as_str(),
+ let label = format!(
+ "{} {}",
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .title
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .author
+ }
);
+ let mut wind = SingleWindow::new(800, 100, 520, 600, None).with_label(label.as_str());
+
let mut table = VGrid::new(0, 30, 520, 180, "");
table.set_params(5, 1, 1);
- let mut title_frame = Frame::new(
- 30,
- 50,
- 420,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Title",
- Lang::Russian => "Название",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .title
- },
- )
- .as_str(),
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Title",
+ Lang::Russian => "Название",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .title
+ },
);
- let mut author_frame = Frame::new(
- 50,
- 50,
- 420,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Author",
- Lang::Russian => "Автор",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .author
- }
- )
- .as_str(),
+ let mut title_frame = Frame::new(30, 50, 420, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Author",
+ Lang::Russian => "Автор",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .author
+ }
);
- let mut pages_frame = Frame::new(
- 70,
- 50,
- 420,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Amount of Pages",
- Lang::Russian => "Кол-во страниц",
- },
- *unsafe {
- &(**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .pages
- }
- )
- .as_str(),
+ let mut author_frame = Frame::new(50, 50, 420, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Amount of Pages",
+ Lang::Russian => "Кол-во страниц",
+ },
+ *unsafe {
+ &(**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .pages
+ }
);
- let mut amount_frame = Frame::new(
- 90,
- 50,
- 320,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Amount of books",
- Lang::Russian => "Кол-во книг",
- },
- unsafe {
- (**(*book_system).borrow().books.get_unchecked(ind))
- .borrow()
- .books
- .len()
- }
- )
- .as_str(),
+ let mut pages_frame = Frame::new(70, 50, 420, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Amount of books",
+ Lang::Russian => "Кол-во книг",
+ },
+ unsafe {
+ (**(*book_system).borrow().books.get_unchecked(ind))
+ .borrow()
+ .books
+ .len()
+ }
);
+ let mut amount_frame = Frame::new(90, 50, 320, 30, None).with_label(label.as_str());
+
table.add(&title_frame);
table.add(&author_frame);
table.add(&pages_frame);
table.add(&amount_frame);
- table.add(&Frame::new(
- 90,
- 50,
- 320,
- 30,
- format!(
- "{}:",
- match lang {
- Lang::English => "Genres",
- Lang::Russian => "Жанры",
- },
- )
- .as_str(),
- ));
+ let label = format!(
+ "{}:",
+ match lang {
+ Lang::English => "Genres",
+ Lang::Russian => "Жанры",
+ },
+ );
+ table.add(&Frame::new(90, 50, 320, 30, None).with_label(label.as_str()));
table.auto_layout();
let mut genre_table = Table::new(0, 200, 520, 380, "");
@@ -753,7 +679,7 @@ pub fn the_book_info_simple(
.borrow()
.genres
} {
- max(20, g.len() as u32)
+ max(20, g.len() as i32)
} else {
20
},
@@ -765,7 +691,7 @@ pub fn the_book_info_simple(
let b = unsafe { (*book_system).borrow().books.get_unchecked(ind).clone() };
- genre_table.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ genre_table.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
table::TableContext::Cell => {
diff --git a/src/actions/genres/full.rs b/src/actions/genres/full.rs
index 9aa78d9..398e2fb 100644
--- a/src/actions/genres/full.rs
+++ b/src/actions/genres/full.rs
@@ -24,6 +24,7 @@ use fltk::{
table::Table,
tree::{Tree, TreeItem},
window::SingleWindow,
+ enums::Font
};
use std::cmp::max;
@@ -315,13 +316,13 @@ fn find_by_genre(book_system: &BookSystem, app: &App, lang: Lang) {
}
});
- book_table.set_rows(max(20, find.len() as u32));
+ book_table.set_rows(max(20, find.len() as i32));
book_table.set_cols(1);
book_table.set_col_width_all(300);
book_table.end();
- book_table.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ book_table.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
table::TableContext::Cell => {
@@ -445,7 +446,7 @@ pub fn all_genres(
wind.show();
while app.wait() {
- if let Some(item) = tree.set_item_clicked() {
+ if let Some(item) = tree.callback_item() {
if !item.has_children() {
wind.hide();
return Some(item);
diff --git a/src/actions/giveaway/full.rs b/src/actions/giveaway/full.rs
index 2d1f416..fded9a9 100644
--- a/src/actions/giveaway/full.rs
+++ b/src/actions/giveaway/full.rs
@@ -9,7 +9,7 @@ use crate::{
Lang,
};
-use fltk::{app::App, input::*};
+use fltk::{app::App, input::*, prelude::WidgetExt};
/// Function that changes
/// return date for the book
diff --git a/src/actions/read/info/simple.rs b/src/actions/read/info/simple.rs
index 070e3f5..7bf306e 100644
--- a/src/actions/read/info/simple.rs
+++ b/src/actions/read/info/simple.rs
@@ -17,6 +17,7 @@ use fltk::{
app,
app::App,
draw,
+ enums::{Font, Shortcut},
frame::Frame,
group::VGrid,
menu::{MenuBar, MenuFlag},
@@ -56,165 +57,130 @@ pub fn reader_info_simple_reading(
lang: Lang,
main_table: &mut Table,
) {
- let mut wind = SingleWindow::new(
- 800,
- 100,
- 670,
- 600,
- format!(
- "{} {} {}",
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .name
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .family
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .father
- },
- )
- .as_str(),
- )
- .center_screen();
+ let label = format!(
+ "{} {} {}",
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .name
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .family
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .father
+ },
+ );
+
+ let mut wind = SingleWindow::new(800, 100, 670, 600, None)
+ .with_label(label.as_str())
+ .center_screen();
let mut table1 = VGrid::new(0, 0, 670, 200, "");
table1.set_params(6, 1, 1);
- let mut name_frame = Frame::new(
- 10,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "First Name",
- Lang::Russian => "\t\tИмя",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .name
- }
- )
- .as_str(),
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "First Name",
+ Lang::Russian => "\t\tИмя",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .name
+ }
);
- let mut family_frame = Frame::new(
- 30,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Second Name",
- Lang::Russian => "\t\tФамилия",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .family
- }
- )
- .as_str(),
+ let mut name_frame = Frame::new(10, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Second Name",
+ Lang::Russian => "\t\tФамилия",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .family
+ }
);
- let mut father_frame = Frame::new(
- 50,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Middle Name",
- Lang::Russian => "\t\tОтчество",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .father
- }
- )
- .as_str(),
+ let mut family_frame = Frame::new(30, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Middle Name",
+ Lang::Russian => "\t\tОтчество",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .father
+ }
);
- let mut age_frame = Frame::new(
- 70,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Age",
- Lang::Russian => "\t\tВозраст",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .age()
- }
- )
- .as_str(),
+ let mut father_frame = Frame::new(50, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Age",
+ Lang::Russian => "\t\tВозраст",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .age()
+ }
);
- let mut info_frame = Frame::new(
- 200,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Additional Info",
- Lang::Russian => "Дополнительная Информация",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .info
- }
- )
- .as_str(),
+ let mut age_frame = Frame::new(70, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Additional Info",
+ Lang::Russian => "Дополнительная Информация",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .info
+ }
);
+ let mut info_frame = Frame::new(200, 50, 100, 30, None).with_label(label.as_str());
+
table1.add(&name_frame);
table1.add(&family_frame);
table1.add(&father_frame);
table1.add(&age_frame);
table1.add(&info_frame);
- table1.add(&Frame::new(
- 200,
- 50,
- 100,
- 30,
- format!(
- "{}:",
- match lang {
- Lang::English => "Books read by reader now",
- Lang::Russian => "Книги, читаемые сейчас",
- }
- )
- .as_str(),
- ));
+ let label = format!(
+ "{}:",
+ match lang {
+ Lang::English => "Books read by reader now",
+ Lang::Russian => "Книги, читаемые сейчас",
+ }
+ );
+ table1.add(&Frame::new(200, 50, 100, 30, None).with_label(label.as_str()));
table1.auto_layout();
- let mut table2 = Table::new(0, 230, 670, 600, "");
+ let mut table2 = Table::new(0, 230, 670, 600, None);
table2.set_rows(max(30, unsafe {
(**(*reader_base).borrow().readers.get_unchecked(ind))
.borrow()
.books
- .len() as u32
+ .len() as i32
}));
table2.set_row_header(true);
table2.set_cols(4);
@@ -331,7 +297,7 @@ pub fn reader_info_simple_reading(
let rb = reader_base.clone();
let bs = book_system.clone();
- table2.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ table2.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
fltk::table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
fltk::table::TableContext::ColHeader => draw_header(
@@ -611,177 +577,143 @@ pub(crate) fn reader_info_simple_all_books(
lang: Lang,
main_table: &mut Table,
) {
- let mut wind = SingleWindow::new(
- 800,
- 100,
- 670,
- 600,
- format!(
- "{} {} {}",
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .name
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .family
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .father
- },
- )
- .as_str(),
- )
- .center_screen();
+ let label = format!(
+ "{} {} {}",
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .name
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .family
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .father
+ },
+ );
- let mut table1 = VGrid::new(0, 0, 670, 200, "");
+ let mut wind = SingleWindow::new(800, 100, 670, 600, None)
+ .with_label(label.as_str())
+ .center_screen();
+
+ let mut table1 = VGrid::new(0, 0, 670, 200, None);
table1.set_params(6, 1, 1);
- let mut name_frame = Frame::new(
- 10,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "First Name",
- Lang::Russian => "\t\tИмя",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .name
- }
- )
- .as_str(),
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "First Name",
+ Lang::Russian => "\t\tИмя",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .name
+ }
);
- let mut family_frame = Frame::new(
- 30,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Second Name",
- Lang::Russian => "\t\tФамилия",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .family
- }
- )
- .as_str(),
+ let mut name_frame = Frame::new(10, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Second Name",
+ Lang::Russian => "\t\tФамилия",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .family
+ }
);
- let mut father_frame = Frame::new(
- 50,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Middle Name",
- Lang::Russian => "\t\tОтчество",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .father
- }
- )
- .as_str(),
+ let mut family_frame = Frame::new(30, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Middle Name",
+ Lang::Russian => "\t\tОтчество",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .father
+ }
);
- let mut age_frame = Frame::new(
- 70,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Age",
- Lang::Russian => "\t\tВозраст",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .age()
- }
- )
- .as_str(),
+ let mut father_frame = Frame::new(50, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Age",
+ Lang::Russian => "\t\tВозраст",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .age()
+ }
);
- let mut reading_frame = Frame::new(
- 90,
- 50,
- 100,
- 30,
- format!(
- "{}: {}",
- match lang {
- Lang::English => "Nearest to return deadline",
- Lang::Russian => "Ближайщее к сдаче",
- },
- if unsafe {
- (**(*reader_base).borrow().readers.get_unchecked(ind))
+ let mut age_frame = Frame::new(70, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Nearest to return deadline",
+ Lang::Russian => "Ближайщее к сдаче",
+ },
+ if unsafe {
+ (**(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .reading
+ .is_some()
+ } {
+ unsafe {
+ (*(**(*reader_base).borrow().readers.get_unchecked(ind))
.borrow()
.reading
- .is_some()
- } {
- unsafe {
- (*(**(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .reading
- .as_ref()
- .unwrap()
- .first()
- .unwrap()
- .upgrade()
- .unwrap())
- .borrow()
- .to_string(&*(*book_system).borrow())
- }
- } else {
- match lang {
- Lang::English => "None",
- Lang::Russian => "Ничего",
- }
- .to_string()
+ .as_ref()
+ .unwrap()
+ .first()
+ .unwrap()
+ .upgrade()
+ .unwrap())
+ .borrow()
+ .to_string(&*(*book_system).borrow())
}
- )
- .as_str(),
- );
-
- let mut info_frame = Frame::new(
- 100,
- 50,
- 100,
- 50,
- format!(
- "{}: {}",
+ } else {
match lang {
- Lang::English => "Additional information",
- Lang::Russian => "Дополнительная информация",
- },
- *unsafe {
- &(*(*reader_base).borrow().readers.get_unchecked(ind))
- .borrow()
- .info
+ Lang::English => "None",
+ Lang::Russian => "Ничего",
}
- )
- .as_str(),
+ .to_string()
+ }
);
+ let mut reading_frame = Frame::new(90, 50, 100, 30, None).with_label(label.as_str());
+
+ let label = format!(
+ "{}: {}",
+ match lang {
+ Lang::English => "Additional information",
+ Lang::Russian => "Дополнительная информация",
+ },
+ *unsafe {
+ &(*(*reader_base).borrow().readers.get_unchecked(ind))
+ .borrow()
+ .info
+ }
+ );
+
+ let mut info_frame = Frame::new(100, 50, 100, 50, None).with_label(label.as_str());
+
table1.add(&name_frame);
table1.add(&family_frame);
table1.add(&father_frame);
@@ -789,21 +721,15 @@ pub(crate) fn reader_info_simple_all_books(
table1.add(&reading_frame);
table1.add(&info_frame);
- table1.add(&Frame::new(
- 160,
- 50,
- 100,
- 30,
- format!(
- "{}:",
- match lang {
- Lang::English => "Books read by reader",
- Lang::Russian => "Прочитанные книги",
- }
- )
- .as_str(),
- ));
+ let label = format!(
+ "{}:",
+ match lang {
+ Lang::English => "Books read by reader",
+ Lang::Russian => "Прочитанные книги",
+ }
+ );
+ table1.add(&Frame::new(160, 50, 100, 30, None).with_label(label.as_str()));
table1.auto_layout();
let mut table2 = Table::new(0, 230, 570, 600, "");
@@ -811,7 +737,7 @@ pub(crate) fn reader_info_simple_all_books(
(**(*reader_base).borrow().readers.get_unchecked(ind))
.borrow()
.books
- .len() as u32
+ .len() as i32
}));
table2.set_row_header(true);
table2.set_cols(4);
@@ -928,7 +854,7 @@ pub(crate) fn reader_info_simple_all_books(
let rb = reader_base.clone();
let bs = book_system.clone();
- table2.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ table2.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
fltk::table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
fltk::table::TableContext::ColHeader => draw_header(
diff --git a/src/actions/tables.rs b/src/actions/tables.rs
index 6e38856..c615c4b 100644
--- a/src/actions/tables.rs
+++ b/src/actions/tables.rs
@@ -10,7 +10,7 @@ use crate::{
use chrono::Datelike;
-use fltk::{draw, enums::Color, prelude::*};
+use fltk::{draw, enums::Color, enums::{Align, FrameType}};
use std::{
cell::RefCell,
@@ -39,24 +39,24 @@ pub fn draw_data(
w: i32,
h: i32,
selected: bool,
- color: Option,
+ color: Option,
) {
draw::push_clip(x, y, w, h);
draw::set_draw_color(if color.is_some() {
if selected {
- fltk::enums::Color::DarkRed
+ Color::DarkRed
} else {
- fltk::enums::Color::Red
+ Color::Red
}
} else if selected {
- fltk::enums::Color::from_u32(0xD3D3D3)
+ Color::from_u32(0xD3D3D3)
} else {
- fltk::enums::Color::White
+ Color::White
});
draw::draw_rectf(x, y, w, h);
- draw::set_draw_color(fltk::enums::Color::Gray0);
+ draw::set_draw_color(Color::Gray0);
draw::draw_text2(txt, x, y, w, h, Align::Center);
draw::draw_rect(x, y, w, h);
draw::pop_clip();
@@ -64,7 +64,7 @@ pub fn draw_data(
/// Function that returns String with reader's data and color.
/// If column is 0, it' ll return reader's params,
-/// if column is 1, it' ll return books's params (or none)
+/// if column is 1, it' ll return books' params (or none)
/// if column is 2, it' ll return start date's params (or none)
/// if column is 2, it' ll return finish date's params (or none).
/// if reader is late, it' ll return some color,
@@ -77,7 +77,7 @@ pub fn cell_reader(
reader_base: &ReaderBase,
book_system: &BookSystem,
lang: Lang,
-) -> (String, Option) {
+) -> (String, Option) {
return if y < reader_base.len() as i32 {
let reader_date =
match RefCell::borrow(unsafe { &(**reader_base.readers.get_unchecked(y as usize)) })
diff --git a/src/books/book_sys.rs b/src/books/book_sys.rs
index 35af91e..8480067 100644
--- a/src/books/book_sys.rs
+++ b/src/books/book_sys.rs
@@ -8,7 +8,6 @@ use crate::{
};
use std::{
- borrow::*,
cell::RefCell,
collections::HashSet,
fmt::{Debug, Formatter},
@@ -519,7 +518,6 @@ impl BookSystem {
if {
let check = (**s).borrow().is_using
&& *(*(*(**s).borrow().readers.last().unwrap())
- .borrow()
.0
.upgrade()
.unwrap())
diff --git a/src/change/input1.rs b/src/change/input1.rs
index ef4d497..3cca7a3 100644
--- a/src/change/input1.rs
+++ b/src/change/input1.rs
@@ -1,4 +1,5 @@
extern crate fltk;
+
use crate::{change::Inputable, Lang};
use fltk::{button::Button, dialog::alert, frame::Frame, prelude::*, window::SingleWindow};
use std::{cell::RefCell, rc::Rc};
@@ -38,7 +39,7 @@ impl Inputable for Input1 {
);
}
- InputExt::set_value(&*(*self.input).borrow(), "");
+ InputExt::set_value(&mut *(*self.input).borrow_mut(), "");
Err(())
}
}
@@ -49,19 +50,23 @@ impl Input1 {
#[inline]
pub fn new(title: &str, what_mes: &str) -> Self {
let win: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, title)));
+ Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, None)));
+ win.borrow_mut().set_label(title);
+
let but: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, "OK")));
+ Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, Some("OK"))));
let wat: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 80, 200, 30, what_mes)));
- let inp: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 80, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 80, 200, 30, None)));
+ wat.borrow_mut().set_label(what_mes);
+
+ let inp: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 80, 300, 30, None)));
WidgetExt::set_label_size(&mut *(*wat).borrow_mut(), 12);
InputExt::set_text_size(&mut *(inp).borrow_mut(), 15);
GroupExt::end(&*(*win).borrow());
- Input1 {
+ Self {
wind: win,
ok: but,
what: wat,
diff --git a/src/change/input2.rs b/src/change/input2.rs
index b66eb59..c9d5115 100644
--- a/src/change/input2.rs
+++ b/src/change/input2.rs
@@ -1,4 +1,5 @@
extern crate fltk;
+
use crate::{change::Inputable, Lang};
use fltk::{button::Button, dialog::alert, frame::Frame, prelude::*, window::SingleWindow};
use std::{cell::RefCell, rc::Rc};
@@ -51,8 +52,8 @@ where
);
}
- InputExt::set_value(&*(*self.input1).borrow(), "");
- InputExt::set_value(&*(*self.input2).borrow(), "");
+ InputExt::set_value(&mut *(*self.input1).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input2).borrow_mut(), "");
Err(())
}
}
@@ -67,17 +68,23 @@ where
#[inline]
pub fn new(title: &str, what_mes1: &str, what_mes2: &str) -> Self {
let win: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, title)));
+ Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, None)));
+ win.borrow_mut().set_label(title);
+
let but: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, "OK")));
+ Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, Some("OK"))));
let wat1: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 20, 200, 30, what_mes1)));
- let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 20, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 20, 200, 30, None)));
+ wat1.borrow_mut().set_label(what_mes1);
+
+ let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 20, 300, 30, None)));
let wat2: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 100, 200, 30, what_mes2)));
- let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 100, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 100, 200, 30, None)));
+ wat2.borrow_mut().set_label(what_mes2);
+
+ let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 100, 300, 30, None)));
WidgetExt::set_label_size(&mut *(*wat1).borrow_mut(), 12);
WidgetExt::set_label_size(&mut *(*wat2).borrow_mut(), 12);
@@ -85,7 +92,7 @@ where
InputExt::set_text_size(&mut *(inp2).borrow_mut(), 15);
GroupExt::end(&*(*win).borrow());
- Input2 {
+ Self {
wind: win,
ok: but,
what1: wat1,
diff --git a/src/change/input3.rs b/src/change/input3.rs
index 8161760..23d99fe 100644
--- a/src/change/input3.rs
+++ b/src/change/input3.rs
@@ -1,4 +1,5 @@
extern crate fltk;
+
use crate::{change::Inputable, Lang};
use fltk::{button::Button, dialog::alert, frame::Frame, prelude::*, window::SingleWindow};
use std::{cell::RefCell, rc::Rc};
@@ -58,9 +59,9 @@ where
);
}
- InputExt::set_value(&*(*self.input1).borrow(), "");
- InputExt::set_value(&*(*self.input2).borrow(), "");
- InputExt::set_value(&*(*self.input3).borrow(), "");
+ InputExt::set_value(&mut *(*self.input1).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input2).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input3).borrow_mut(), "");
Err(())
}
}
@@ -76,21 +77,29 @@ where
#[inline]
pub fn new(title: &str, what_mes1: &str, what_mes2: &str, what_mes3: &str) -> Self {
let win: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, title)));
+ Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 200, None)));
+ win.borrow_mut().set_label(title);
+
let but: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, "OK")));
+ Rc::new(RefCell::new(WidgetBase::new(410, 170, 75, 25, Some("OK"))));
let wat1: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 20, 200, 30, what_mes1)));
- let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 20, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 20, 200, 30, None)));
+ wat1.borrow_mut().set_label(what_mes1);
+
+ let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 20, 300, 30, None)));
let wat2: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 60, 200, 30, what_mes2)));
- let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 60, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 60, 200, 30, None)));
+ wat2.borrow_mut().set_label(what_mes2);
+
+ let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 60, 300, 30, None)));
let wat3: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 100, 200, 30, what_mes3)));
- let inp3: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 100, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 100, 200, 30, None)));
+ wat3.borrow_mut().set_label(what_mes3);
+
+ let inp3: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 100, 300, 30, None)));
WidgetExt::set_label_size(&mut *(*wat1).borrow_mut(), 12);
WidgetExt::set_label_size(&mut *(*wat2).borrow_mut(), 12);
@@ -100,7 +109,7 @@ where
InputExt::set_text_size(&mut *(inp3).borrow_mut(), 15);
GroupExt::end(&*(*win).borrow());
- Input3 {
+ Self {
wind: win,
ok: but,
what1: wat1,
diff --git a/src/change/input4.rs b/src/change/input4.rs
index e993b33..2b6147a 100644
--- a/src/change/input4.rs
+++ b/src/change/input4.rs
@@ -3,9 +3,7 @@ extern crate fltk;
use crate::{change::Inputable, Lang};
use std::{cell::RefCell, rc::Rc};
-use fltk::{
- button::Button, dialog::alert, frame::Frame, prelude::*, window::SingleWindow, WidgetExt,
-};
+use fltk::{button::Button, dialog::alert, frame::Frame, prelude::*, window::SingleWindow};
/// Changes four values
@@ -69,10 +67,10 @@ where
);
}
- InputExt::set_value(&*(*self.input1).borrow(), "");
- InputExt::set_value(&*(*self.input2).borrow(), "");
- InputExt::set_value(&*(*self.input3).borrow(), "");
- InputExt::set_value(&*(*self.input4).borrow(), "");
+ InputExt::set_value(&mut *(*self.input1).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input2).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input3).borrow_mut(), "");
+ InputExt::set_value(&mut *(*self.input4).borrow_mut(), "");
Err(())
}
}
@@ -101,25 +99,35 @@ where
K: InputExt + WidgetBase,
{
let win: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 220, title)));
+ Rc::new(RefCell::new(WidgetBase::new(500, 500, 500, 220, None)));
+ win.borrow_mut().set_label(title);
+
let but: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(410, 190, 75, 25, "OK")));
+ Rc::new(RefCell::new(WidgetBase::new(410, 190, 75, 25, Some("OK"))));
let wat1: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 10, 200, 30, what_mes1)));
- let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 10, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 10, 200, 30, None)));
+ wat1.borrow_mut().set_label(what_mes1);
+
+ let inp1: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 10, 300, 30, None)));
let wat2: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 50, 200, 30, what_mes2)));
- let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 50, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 50, 200, 30, None)));
+ wat2.borrow_mut().set_label(what_mes2);
+
+ let inp2: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 50, 300, 30, None)));
let wat3: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 90, 200, 30, what_mes3)));
- let inp3: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 90, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 90, 200, 30, None)));
+ wat3.borrow_mut().set_label(what_mes3);
+
+ let inp3: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 90, 300, 30, None)));
let wat4: Rc> =
- Rc::new(RefCell::new(WidgetBase::new(-20, 130, 200, 30, what_mes4)));
- let inp4: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 130, 300, 30, "")));
+ Rc::new(RefCell::new(WidgetBase::new(-20, 130, 200, 30, None)));
+ wat4.borrow_mut().set_label(what_mes4);
+
+ let inp4: Rc> = Rc::new(RefCell::new(WidgetBase::new(150, 130, 300, 30, None)));
WidgetExt::set_label_size(&mut *(*wat1).borrow_mut(), 12);
WidgetExt::set_label_size(&mut *(*wat2).borrow_mut(), 12);
@@ -131,7 +139,7 @@ where
InputExt::set_text_size(&mut *(inp4).borrow_mut(), 15);
GroupExt::end(&*(*win).borrow());
- Input4 {
+ Self {
wind: win,
ok: but,
what1: wat1,
diff --git a/src/change/mod.rs b/src/change/mod.rs
index bb877d0..210ed14 100644
--- a/src/change/mod.rs
+++ b/src/change/mod.rs
@@ -1,4 +1,5 @@
extern crate fltk;
+
use crate::Lang;
use fltk::{prelude::*, window::SingleWindow};
use std::{cell::RefCell, rc::Rc};
diff --git a/src/main.rs b/src/main.rs
index 59d227e..34a7672 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,21 +27,22 @@ use booklibrs::{
use fltk::{
app,
app::Sender,
- button::*,
dialog::alert,
draw,
enums::Shortcut,
+ enums::{Color, Font},
frame::Frame,
image::*,
input::{Input, SecretInput},
menu::*,
+ prelude::*,
table,
table::Table,
window::*,
};
use booklibrs::actions::tables::cell_date_time;
-use std::time::Duration;
+
use std::{
cell::RefCell,
cmp::max,
@@ -50,6 +51,7 @@ use std::{
io::{Read, Write},
rc::Rc,
thread,
+ time::Duration,
};
/// Hashing login and password
@@ -80,7 +82,7 @@ fn main() -> Result<(), Box> {
let genres = Rc::new(RefCell::new(Genres::new()));
let lang = Lang::new();
- let app = app::App::default().with_scheme(fltk::app::AppScheme::Plastic);
+ let app = app::App::default().with_scheme(app::AppScheme::Plastic);
let (s, r) = app::channel();
(*reader_base).borrow_mut().load();
@@ -247,7 +249,7 @@ fn main() -> Result<(), Box> {
let mut frame = Frame::new(0, 0, 1800, 900, "");
let mut background = SharedImage::load("src/utils/background.jpg")?;
- frame.draw2(move |f| background.draw(f.x(), f.y(), f.width(), f.height()));
+ frame.draw(move |f| background.draw(f.x(), f.y(), f.width(), f.height()));
main_window.set_icon(Some(JpegImage::load("src/utils/icon.jpg")?));
@@ -262,7 +264,7 @@ fn main() -> Result<(), Box> {
date_frame.end();
let mut table = Table::new(10, 120, 1780, 890, "");
- table.set_rows(max(50, (*reader_base).borrow().len() as u32));
+ table.set_rows(max(50, (*reader_base).borrow().len() as i32));
table.set_row_header(true);
table.set_cols(4);
table.set_col_header(true);
@@ -290,7 +292,7 @@ fn main() -> Result<(), Box> {
let rb = reader_base.clone();
let bs = book_system.clone();
- date_frame.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ date_frame.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
table::TableContext::ColHeader => draw_header(
@@ -336,7 +338,7 @@ fn main() -> Result<(), Box> {
_ => (),
});
- table.draw_cell2(move |t, ctx, row, col, x, y, w, h| match ctx {
+ table.draw_cell(move |t, ctx, row, col, x, y, w, h| match ctx {
table::TableContext::StartPage => draw::set_font(Font::Helvetica, 14),
table::TableContext::ColHeader => draw_header(
@@ -703,7 +705,7 @@ fn main() -> Result<(), Box> {
Lang::English => "&Restore/Restore previous data\t",
Lang::Russian => "&Откат/Откатить изменения назад\t",
},
- fltk::enums::Shortcut::Ctrl | 'z',
+ Shortcut::Ctrl | 'z',
MenuFlag::Normal,
s,
Message::PrevData,
@@ -714,7 +716,7 @@ fn main() -> Result<(), Box> {
Lang::English => "&Restore/Restore next data\t",
Lang::Russian => "&Откат/Откатить изменения вперед\t",
},
- fltk::enums::Shortcut::Ctrl | fltk::enums::Shortcut::Shift | 'z',
+ Shortcut::Ctrl | Shortcut::Shift | 'z',
MenuFlag::Normal,
s,
Message::NextData,
@@ -773,7 +775,7 @@ fn main() -> Result<(), Box> {
lang,
);
- table.set_rows(max(50, (*reader_base).borrow().len() as u32));
+ table.set_rows(max(50, (*reader_base).borrow().len() as i32));
table.redraw();
}
@@ -787,7 +789,7 @@ fn main() -> Result<(), Box> {
lang,
);
- table.set_rows(max(50, (*reader_base).borrow().len() as u32));
+ table.set_rows(max(50, (*reader_base).borrow().len() as i32));
table.redraw();
}
@@ -1116,7 +1118,7 @@ fn main() -> Result<(), Box> {
}
Message::English => {
- if fltk::dialog::choice(
+ if fltk::dialog::choice2(
500,
500,
match lang {
@@ -1132,14 +1134,14 @@ fn main() -> Result<(), Box> {
Lang::Russian => "Отмена"
},
""
- ) == 0 {
+ ) == Some(0) {
Lang::change(Lang::English);
app.quit()
}
}
Message::Russian => {
- if fltk::dialog::choice(
+ if fltk::dialog::choice2(
500,
500,
match lang {
@@ -1155,7 +1157,7 @@ fn main() -> Result<(), Box> {
Lang::Russian => "Отмена"
},
""
- ) == 0 {
+ ) == Some(0) {
Lang::change(Lang::Russian);
app.quit()
}
diff --git a/src/utils/admin.bin b/src/utils/admin.bin
index e69de29..9fc809b 100644
Binary files a/src/utils/admin.bin and b/src/utils/admin.bin differ
diff --git a/src/utils/books.yaml b/src/utils/books.yaml
index e69de29..7e85a5f 100644
--- a/src/utils/books.yaml
+++ b/src/utils/books.yaml
@@ -0,0 +1,29 @@
+---
+- №: 1
+ Title: History of Bebra
+ Author: Asdasdad
+ Pages: 200
+ Simple Books:
+ - Cabinet: 12
+ Shelf: 22
+ Using: true
+ Readers:
+ - Name: Vasya
+ Family: Bebra
+ Father: Bebrovich
+ Day: 4
+ Month: 8
+ Year: 2023
+ Start date:
+ - 28
+ - 8
+ - 2023
+ Finish date:
+ - 30
+ - 8
+ - 2023
+ - Cabinet: 12
+ Shelf: 23
+ Using: false
+ Readers: []
+ Genres: ~
\ No newline at end of file
diff --git a/src/utils/lang.bin b/src/utils/lang.bin
index e69de29..26d9537 100644
--- a/src/utils/lang.bin
+++ b/src/utils/lang.bin
@@ -0,0 +1 @@
+russian
\ No newline at end of file
diff --git a/src/utils/readers.yaml b/src/utils/readers.yaml
index e69de29..e9eb717 100644
--- a/src/utils/readers.yaml
+++ b/src/utils/readers.yaml
@@ -0,0 +1,11 @@
+---
+- №: 1
+ Name: Vasya
+ Family: Bebra
+ Father: Bebrovich
+ Info: " Gay party organizer"
+ Day: 4
+ Month: 8
+ Year: 2023
+ Reading:
+ - History of Bebra Asdasdad 200
\ No newline at end of file