Skip to content

Commit d2adba6

Browse files
authored
Merge pull request #184 from gdt050579/window_style
Window style
2 parents 6b7e2ac + a1c3bd5 commit d2adba6

45 files changed

Lines changed: 925 additions & 397 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appcui-proc-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "appcui_proc_macro"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
edition = "2021"
55
authors = ["Gavrilut Dragos <gavrilut.dragos@gmail.com>"]
66
description = "Procedural macros for the AppCUI TUI framework."

appcui-proc-macro/src/controls/radiobox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::control_builder::ControlBuilder;
22
use crate::parameter_parser::*;
33
use proc_macro::*;
44

5-
static TYPES: FlagsSignature = FlagsSignature::new(&["Standard", "Ascii", "Circle", "Diamond"]);
5+
static TYPES: FlagsSignature = FlagsSignature::new(&["Standard", "Ascii", "Circle", "Diamond", "Bullet"]);
66

77
static POSILITIONAL_PARAMETERS: &[PositionalParameter] = &[PositionalParameter::new("caption", ParamType::String)];
88
static NAMED_PARAMETERS: &[NamedParameter] = &[

appcui-proc-macro/src/controls/window.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ static FLAGS: FlagsSignature = FlagsSignature::new(&[
1010
"NotifyWindow",
1111
"WarningWindow",
1212
]);
13-
static TYPES: FlagsSignature = FlagsSignature::new(&["Normal", "Error", "Warning", "Notification"]);
13+
static TYPES: FlagsSignature = FlagsSignature::new(&["Classic", "Rounded", "Panel"]);
14+
static BACKGROUNDS: FlagsSignature = FlagsSignature::new(&["Normal", "Error", "Warning", "Notification"]);
1415

1516
static POSILITIONAL_PARAMETERS: &[PositionalParameter] = &[PositionalParameter::new("title", ParamType::String)];
1617
static NAMED_PARAMETERS: &[NamedParameter] = &[
@@ -19,6 +20,9 @@ static NAMED_PARAMETERS: &[NamedParameter] = &[
1920
NamedParameter::new("text", "title", ParamType::String),
2021
NamedParameter::new("flags", "flags", ParamType::Flags),
2122
NamedParameter::new("type", "type", ParamType::String),
23+
NamedParameter::new("background", "background", ParamType::String),
24+
NamedParameter::new("back", "background", ParamType::String),
25+
NamedParameter::new("bg", "background", ParamType::String),
2226
NamedParameter::new("tag", "tag", ParamType::String),
2327
NamedParameter::new("hot-key", "hotkey", ParamType::String),
2428
NamedParameter::new("hotkey", "hotkey", ParamType::String),
@@ -31,7 +35,8 @@ pub(crate) fn create(input: TokenStream) -> TokenStream {
3135
cb.add_string_parameter("title", None);
3236
cb.add_layout();
3337
cb.add_flags_parameter("flags", "window::Flags", &FLAGS);
34-
cb.add_enum_parameter("type", "window::Type", &TYPES, Some("Normal"));
38+
cb.add_enum_parameter("type", "window::Type", &TYPES, Some("Classic"));
39+
cb.add_enum_parameter("background", "window::Background", &BACKGROUNDS, Some("Normal"));
3540
cb.finish_control_initialization();
3641
if cb.has_parameter("tag") {
3742
cb.add("\n\tcontrol.set_tag(");

appcui/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ categories = ["gui", "command-line-interface", "command-line-utilities"]
1818
EnumBitFlags = "1.0.10"
1919
flat_string = "1.0.0"
2020
chrono = {version = "0.4.38", features = ["wasmbind"]}
21-
appcui_proc_macro = "0.2.2"
22-
#appcui_proc_macro = { path = "../appcui-proc-macro" }
21+
#appcui_proc_macro = "0.2.2"
22+
appcui_proc_macro = { path = "../appcui-proc-macro" }
2323

2424
[lib]
2525
crate-type = ["cdylib", "rlib"]

appcui/src/backend/utils/win32/constants.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,19 @@ pub(crate) const TRANSLATION_MATRIX: [KeyCode; 256] = [
290290

291291
pub(crate) static APPCUI_COLOR_SCEHMA: [u32; 16] = [
292292
0x_00_00_00, // Black
293-
0x_80_00_00, // Dark Red
293+
0x_80_00_00, // Dark Blue
294294
0x_00_80_00, // Dark Green
295-
0x_80_80_00, // Olive
296-
0x_00_00_80, // Dark Blue
295+
0x_80_80_00, // Teal
296+
0x_00_00_80, // Dark Red
297297
0x_80_00_80, // Magenta
298-
0x_00_80_80, // Teal
298+
0x_00_80_80, // Olive
299299
0x_C0_C0_C0, // Silver
300300
0x_80_80_80, // Gray
301-
0x_FF_00_00, // Red
301+
0x_FF_00_00, // Blue
302302
0x_00_FF_00, // Green
303303
0x_FF_FF_00, // Aqua
304-
0x_00_00_FF, // Blue
305-
0x_00_FF_FF, // Pink
306-
0x_FF_FF_00, // Yellow
304+
0x_00_00_FF, // Red
305+
0x_FF_00_FF, // Pink
306+
0x_00_FF_FF, // Yellow
307307
0x_FF_FF_FF, // White
308308
];

appcui/src/dialogs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub enum ValidateOrCancelResult {
112112
/// dialogs::error("Error", "An error has occurred during the last operation");
113113
/// ```
114114
pub fn error(title: &str, caption: &str) {
115-
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Type::Error);
115+
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Background::Error);
116116
w.show();
117117
}
118118

@@ -139,7 +139,7 @@ pub fn error(title: &str, caption: &str) {
139139
/// }
140140
/// ```
141141
pub fn retry(title: &str, caption: &str) -> bool {
142-
let w = GenericAlertDialog::new(title, caption, DialogButtons::RetryCancel, window::Type::Error);
142+
let w = GenericAlertDialog::new(title, caption, DialogButtons::RetryCancel, window::Background::Error);
143143
if let Some(result) = w.show() {
144144
return result == DialogResult::Retry;
145145
}
@@ -162,7 +162,7 @@ pub fn retry(title: &str, caption: &str) -> bool {
162162
/// dialogs::alert("Warning", "Low disk space detected");
163163
/// ```
164164
pub fn alert(title: &str, caption: &str) {
165-
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Type::Warning);
165+
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Background::Warning);
166166
w.show();
167167
}
168168

@@ -189,7 +189,7 @@ pub fn alert(title: &str, caption: &str) {
189189
/// }
190190
/// ```
191191
pub fn proceed(title: &str, caption: &str) -> bool {
192-
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNo, window::Type::Warning);
192+
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNo, window::Background::Warning);
193193
if let Some(result) = w.show() {
194194
return result == DialogResult::Yes;
195195
}
@@ -212,7 +212,7 @@ pub fn proceed(title: &str, caption: &str) -> bool {
212212
/// dialogs::message("Success", "All files have been copied");
213213
/// ```
214214
pub fn message(title: &str, caption: &str) {
215-
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Type::Notification);
215+
let w = GenericAlertDialog::new(title, caption, DialogButtons::Ok, window::Background::Notification);
216216
w.show();
217217
}
218218

@@ -239,7 +239,7 @@ pub fn message(title: &str, caption: &str) {
239239
/// }
240240
/// ```
241241
pub fn validate(title: &str, caption: &str) -> bool {
242-
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNo, window::Type::Notification);
242+
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNo, window::Background::Notification);
243243
if let Some(result) = w.show() {
244244
return result == DialogResult::Yes;
245245
}
@@ -275,7 +275,7 @@ pub fn validate(title: &str, caption: &str) -> bool {
275275
/// }
276276
/// ```
277277
pub fn validate_or_cancel(title: &str, caption: &str) -> ValidateOrCancelResult {
278-
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNoCancel, window::Type::Notification);
278+
let w = GenericAlertDialog::new(title, caption, DialogButtons::YesNoCancel, window::Background::Notification);
279279
match w.show() {
280280
Some(DialogResult::Yes) => ValidateOrCancelResult::Yes,
281281
Some(DialogResult::No) => ValidateOrCancelResult::No,

appcui/src/dialogs/generic_alert_dialog.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl GenericAlertDialog {
6060
fn add_button(text: &str, x: i32, y: i32) -> Button {
6161
Button::new(text, LayoutBuilder::new().x(x).y(y).width(11).build(), button::Type::Normal)
6262
}
63-
pub(super) fn new(title: &str, caption: &str, buttons: DialogButtons, win_type: window::Type) -> Self {
63+
pub(super) fn new(title: &str, caption: &str, buttons: DialogButtons, background: window::Background) -> Self {
6464
let size = RuntimeManager::get().terminal_size();
6565
// the minimum size of the window should contain at least all buttons
6666
let min_window_width = buttons.count() * GenericAlertDialog::BUTTON_SIZE + 3;
@@ -87,15 +87,15 @@ impl GenericAlertDialog {
8787

8888
// lets create the window
8989
let mut w = Self {
90-
base: ModalWindow::with_type(
90+
base: ModalWindow::with_background(
9191
title,
9292
LayoutBuilder::new()
9393
.alignment(Alignment::Center)
9494
.width(window_width)
9595
.height(window_height)
9696
.build(),
9797
window::Flags::NoCloseButton,
98-
win_type,
98+
background,
9999
),
100100
b_ok: Handle::None,
101101
b_yes: Handle::None,

appcui/src/system/theme/dark_gray.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ pub(crate) fn new() -> Theme {
5858
error: charattr!("black,gray"),
5959
warning: charattr!("black,gray"),
6060
info: charattr!("black,gray"),
61+
bar: WindowBar {
62+
focus: charattr!("black,w"),
63+
normal: charattr!("black,gray"),
64+
resizing: charattr!("black,silver"),
65+
close_button: charattr!("red,transparent"),
66+
maximize_button: charattr!("black,transparent"),
67+
tag: charattr!("silver,transparent"),
68+
hotkey: charattr!("dr,transparent"),
69+
},
6170
},
6271
border: controlattr!("black", "black", "black", "gray", "black,silver"),
6372
lines: controlattr!("black", "black", "w", "gray", "black,silver"),

appcui/src/system/theme/default.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use appcui_proc_macro::*;
21
use super::structures::*;
32
use crate::{controlattr, graphics::*, ui::common::ControlCharAttributesState};
3+
use appcui_proc_macro::*;
44

55
pub(crate) fn new() -> Theme {
66
Theme {
@@ -58,6 +58,15 @@ pub(crate) fn new() -> Theme {
5858
error: charattr!("black,dr"),
5959
warning: charattr!("black,olive"),
6060
info: charattr!("black,dg"),
61+
bar: WindowBar {
62+
focus: charattr!("black,w"),
63+
normal: charattr!("black,gray"),
64+
resizing: charattr!("y,magenta"),
65+
close_button: charattr!("red,transparent"),
66+
maximize_button: charattr!("black,transparent"),
67+
tag: charattr!("dg,transparent"),
68+
hotkey: charattr!("dr,transparent"),
69+
},
6170
},
6271
border: controlattr!("silver", "w", "y", "gray", "y,magenta"),
6372
lines: controlattr!("dg", "dg", "y", "gray", "y,magenta"),
@@ -99,21 +108,21 @@ pub(crate) fn new() -> Theme {
99108
unselected: controlattr!("silver", "black,w", "black,y", "gray", "w,black"),
100109
},
101110
markdown: MarkdownTheme {
102-
text: charattr!("silver"),
103-
bold: charattr!("red, flags: Bold"),
104-
italic: charattr!("magenta, flags: Italic"),
105-
link: charattr!("aqua, flags: Underline"),
106-
code: charattr!("silver, black"),
107-
h1: charattr!("white"),
108-
h2: charattr!("y"),
109-
h3: charattr!("g"),
110-
code_block: charattr!("silver, black"),
111-
ordered_list: charattr!("silver"),
111+
text: charattr!("silver"),
112+
bold: charattr!("red, flags: Bold"),
113+
italic: charattr!("magenta, flags: Italic"),
114+
link: charattr!("aqua, flags: Underline"),
115+
code: charattr!("silver, black"),
116+
h1: charattr!("white"),
117+
h2: charattr!("y"),
118+
h3: charattr!("g"),
119+
code_block: charattr!("silver, black"),
120+
ordered_list: charattr!("silver"),
112121
unordered_list: charattr!("silver"),
113122
table: charattr!("silver"),
114123
table_header: charattr!("silver, flags: Bold"),
115124
},
116-
125+
117126
progressbar: ProgressBarTheme {
118127
background: Color::Black,
119128
progress: Color::Teal,

appcui/src/system/theme/light.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ pub(crate) fn new() -> Theme {
5858
error: charattr!("black,dr"),
5959
warning: charattr!("black,olive"),
6060
info: charattr!("black,dg"),
61+
bar: WindowBar {
62+
focus: charattr!("w,b"),
63+
normal: charattr!("w,gray"),
64+
resizing: charattr!("y,magenta"),
65+
close_button: charattr!("red,transparent"),
66+
maximize_button: charattr!("w,transparent"),
67+
tag: charattr!("green,transparent"),
68+
hotkey: charattr!("aqua,transparent"),
69+
}
6170
},
6271
border: controlattr!("black", "black", "black", "gray", "y,magenta"),
6372
lines: controlattr!("dg", "dg", "y", "gray", "y,magenta"),

0 commit comments

Comments
 (0)