outline bug fix

This commit is contained in:
2025-01-12 14:06:50 +01:00
parent cf0ced450d
commit 2318ad7f98
3 changed files with 23 additions and 18 deletions
+3 -3
View File
@@ -369,11 +369,11 @@ impl Writer {
let ol = self.style.write_outline("│");
let hl = "─".repeat(width as usize);
self.write_abs_outline(&self.style.write_outline(&format!("╭{}╮", hl)), (0, 0));
for i in 1..height {
for i in 1..height+1 {
self.write_abs_outline(&ol, (0, i));
self.write_abs_outline(&ol, (width - 1, i));
self.write_abs_outline(&ol, (width + 1, i));
}
self.write_abs_outline(&self.style.write_outline(&format!("╰{}╯", hl)), (0, height));
self.write_abs_outline(&self.style.write_outline(&format!("╰{}╯", hl)), (0, height + 1));
}
}
+17 -7
View File
@@ -1,4 +1,4 @@
use osui::prelude::*;
use osui::{examples, prelude::*};
fn main() {
launch!(App);
@@ -6,12 +6,22 @@ fn main() {
#[component]
fn App() {
let count = use_state(20);
rsx! {
%text { "Hello" }
button { on_click: |_, _, _| @count {
count += 1
}, "World: {count}" }
@SetStyle(css! {
example: "hover" {
color: Blue,
}
})
%text { "Choose an example to run" }
button { class: "example", on_click: |_, _, doc| {
doc.draw(examples::counter_example::App::default().create_element());
}, "Counter" }
button { class: "example", on_click: |_, _, doc| {
doc.draw(examples::login_example::App::default().create_element());
}, "Login" }
button { class: "example", on_click: |_, _, doc| {
doc.draw(examples::todo_example::App::default().create_element());
}, "Todo" }
}
}
+3 -8
View File
@@ -68,15 +68,10 @@ impl<'a> Frame<'a> {
element.render(&mut writer);
let (width, height) = writer.get_size_root();
{
let (mut x, mut y) = (x, y);
if style_element.outline.1 {
x -= 1;
y -= 1;
}
let height = if style_element.outline.1 {
height + 1
let (x, y, width, height) = if style_element.outline.1 {
(x - 1, y - 1, width + 2, height + 2)
} else {
height
(x, y, width, height)
};
for i in y..y + height {