continued to work on new UI library

- implemented CgStatusBar widget which is a specific version of the CgIndicatorBar widget with predefined fields

- std::io::Screen is now an enum that makes switching between display modes more intuitive

- created a basic CgLineEdit implementation that allows for a user to type in a character and have it re-render that widget

- other more minor changes like fixes for existing apps to work with new features
This commit is contained in:
FantasyPvP
2023-11-23 20:29:51 +00:00
parent 461c9d9c6a
commit 467a42a5fa
14 changed files with 352 additions and 128 deletions
+11 -4
View File
@@ -7,17 +7,24 @@ use crate::kernel::render::{ColorCode, RenderError, ScreenChar};
use crate::{printerr, serial_println};
use crate::std::frame::{ColouredChar, Dimensions, Position, special_char, Frame};
pub trait CgOutline {
/// implement this trait if you require the widget to be able to have an outline
pub trait CgOutline: CgComponent {
fn render_outline(&self, frame: &mut Frame);
}
/// generic components for the user interface that defined a render method. this should be implemented for all types
/// that can be rendered to the screen.
pub trait CgComponent {
fn render(&self) -> Result<Frame, RenderError>;
}
/// trait for components that can have editable text, such as search boxes, command palletes, terminals, text inputs etc.
pub trait CgTextEdit: CgComponent {
fn write_char(&self) -> Result<Frame, RenderError>; // this can also be implemented in a way that inserts characters
fn delete_char(&self) -> Result<Frame, RenderError>;
fn move_cursor(&self, direction: bool) -> Result<(), RenderError>; // true = right, false = left
fn clear(&self) -> Result<Frame, RenderError>;
}