AUGHR
This commit is contained in:
parent
bc9ade91fe
commit
09eb8f134c
897
Cargo.lock
generated
897
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,11 +4,11 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clay-layout = "0.2.0"
|
# clay-layout = "0.2.0"
|
||||||
|
clay-layout = { path = "../clay-ui-rust" }
|
||||||
enum_dispatch = "0.3.13"
|
enum_dispatch = "0.3.13"
|
||||||
font-kit = "0.14.2"
|
font-kit = "0.14.2"
|
||||||
minifb = "0.28.0"
|
raylib = { version = "5.0.2", features = ["wayland"] }
|
||||||
raqote = "0.8.5"
|
|
||||||
test-case = "3.3.1"
|
test-case = "3.3.1"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
BIN
MononokiNerdFont-Regular.ttf
Normal file
BIN
MononokiNerdFont-Regular.ttf
Normal file
Binary file not shown.
28
flake.nix
28
flake.nix
|
@ -9,11 +9,13 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs =
|
||||||
self,
|
{ self
|
||||||
nixpkgs,
|
, nixpkgs
|
||||||
rust-overlay,
|
, rust-overlay
|
||||||
}: let
|
,
|
||||||
|
}:
|
||||||
|
let
|
||||||
# rust-overlay = import rust-overlay;
|
# rust-overlay = import rust-overlay;
|
||||||
pkgs =
|
pkgs =
|
||||||
import nixpkgs
|
import nixpkgs
|
||||||
|
@ -21,7 +23,8 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
overlays = [ rust-overlay.overlays.default ];
|
overlays = [ rust-overlay.overlays.default ];
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
devShells.x86_64-linux.default = pkgs.mkShell rec {
|
devShells.x86_64-linux.default = pkgs.mkShell rec {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
rust-bin.nightly.latest.default
|
rust-bin.nightly.latest.default
|
||||||
|
@ -40,16 +43,23 @@
|
||||||
wayland
|
wayland
|
||||||
libxkbcommon
|
libxkbcommon
|
||||||
rust-cbindgen
|
rust-cbindgen
|
||||||
|
cmake
|
||||||
|
glfw
|
||||||
|
clang
|
||||||
|
libclang
|
||||||
|
libllvm
|
||||||
|
nerd-fonts.mononoki
|
||||||
];
|
];
|
||||||
|
|
||||||
LD_LIBRARY_PATH =
|
LD_LIBRARY_PATH =
|
||||||
builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs;
|
builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs;
|
||||||
|
|
||||||
# NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
|
||||||
# export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
|
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
|
||||||
|
# export MONOSPACE_FONT="${pkgs.nerd-fonts.mononoki}/share/fonts/truetype/NerdFonts/Mononoki/MononokiNerdFont-Regular.ttf "
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
495
src/app/bin.rs
495
src/app/bin.rs
|
@ -1,140 +1,411 @@
|
||||||
use std::{any::Any, cell::RefCell, rc::Rc};
|
use std::{
|
||||||
|
cell::RefCell,
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
use clay_layout::{
|
use clay_layout::{
|
||||||
Clay,
|
Declaration,
|
||||||
bindings::Clay_TextElementConfig,
|
bindings::Clay_ResetMeasureTextCache,
|
||||||
elements::{
|
fit, grow,
|
||||||
CornerRadius,
|
|
||||||
rectangle::Rectangle,
|
|
||||||
text::{Text, TextElementConfig},
|
|
||||||
},
|
|
||||||
fixed,
|
|
||||||
id::Id,
|
id::Id,
|
||||||
layout::Layout,
|
layout::{LayoutDirection, Padding},
|
||||||
math::Dimensions,
|
math::Dimensions,
|
||||||
|
render_commands::RenderCommandConfig,
|
||||||
|
text::{TextConfig, TextElementConfig},
|
||||||
|
};
|
||||||
|
use raylib::{
|
||||||
|
RaylibHandle, RaylibThread,
|
||||||
|
color::Color,
|
||||||
|
ffi::Vector2,
|
||||||
|
prelude::{Font, RaylibDraw, RaylibDrawHandle, RaylibScissorModeExt},
|
||||||
|
text::RaylibFont,
|
||||||
};
|
};
|
||||||
|
|
||||||
use font_kit::{family_name::FamilyName, properties::Properties, source::SystemSource};
|
struct FontStore {
|
||||||
use gui::GUI;
|
font: String,
|
||||||
use minifb::{Window, WindowOptions};
|
fonts: HashMap<i32, Rc<Font>>,
|
||||||
use raqote::{DrawOptions, DrawTarget, SolidSource};
|
fonts_to_be_loaded: HashSet<i32>,
|
||||||
|
|
||||||
mod gui;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let clay = Clay::new((800., 600.).into());
|
|
||||||
|
|
||||||
let mut window = Window::new("Raqote", 800, 40, WindowOptions {
|
|
||||||
borderless: true,
|
|
||||||
scale_mode: minifb::ScaleMode::Center,
|
|
||||||
resize: true,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let font = SystemSource::new()
|
|
||||||
.select_best_match(&[FamilyName::Monospace], &Properties::new())
|
|
||||||
.unwrap()
|
|
||||||
.load()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
window.set_target_fps(60);
|
|
||||||
|
|
||||||
let mut size = window.get_size();
|
|
||||||
let mut dt = DrawTarget::new(size.0 as i32, size.1 as i32);
|
|
||||||
|
|
||||||
clay.measure_text_function(|text, config| {
|
|
||||||
let config: Clay_TextElementConfig = unsafe {
|
|
||||||
*std::mem::transmute::<TextElementConfig, *mut Clay_TextElementConfig>(config)
|
|
||||||
};
|
|
||||||
|
|
||||||
Dimensions {
|
|
||||||
width: config.fontSize as f32,
|
|
||||||
height: config.fontSize as f32 * text.len() as f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FontStore {
|
||||||
|
const SIZE_PARAGRAPH: f32 = 20.;
|
||||||
|
const SIZE_HEADER: f32 = 30.;
|
||||||
|
const MOD_SUBTEXT: f32 = 0.5;
|
||||||
|
|
||||||
|
pub fn new(name: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
fonts: HashMap::new(),
|
||||||
|
font: name.into(),
|
||||||
|
fonts_to_be_loaded: HashSet::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(&mut self, size: i32) -> Option<Rc<Font>> {
|
||||||
|
let size = size.max(1);
|
||||||
|
if let Some(font) = self.fonts.get(&size) {
|
||||||
|
Some(font.clone())
|
||||||
|
} else {
|
||||||
|
self.fonts_to_be_loaded.insert(size);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_no_load(&self, size: i32) -> Option<Rc<Font>> {
|
||||||
|
if let Some(font) = self.fonts.get(&size) {
|
||||||
|
Some(font.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_fonts(
|
||||||
|
&mut self,
|
||||||
|
handle: &mut RaylibHandle,
|
||||||
|
thread: &RaylibThread,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
for size in self.fonts_to_be_loaded.clone() {
|
||||||
|
assert!(size != 0, "HOW IS THIS ZERO?");
|
||||||
|
println!("Loading {} in {size}px", self.font);
|
||||||
|
let font = Rc::new(handle.load_font_ex(&thread, &self.font, size, None)?);
|
||||||
|
self.fonts.insert(size, font.clone());
|
||||||
|
}
|
||||||
|
self.fonts_to_be_loaded.clear();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn text(
|
||||||
|
&mut self,
|
||||||
|
d: &mut RaylibDrawHandle,
|
||||||
|
text: &str,
|
||||||
|
x: f32,
|
||||||
|
y: f32,
|
||||||
|
size: f32,
|
||||||
|
letter_spacing: u16,
|
||||||
|
color: Option<Color>,
|
||||||
|
) {
|
||||||
|
// Program crashes at size=0.
|
||||||
|
let size = if size == 0. { 0.1 } else { size };
|
||||||
|
if let Some(font) = self.get(size as i32) {
|
||||||
|
d.draw_text_ex(
|
||||||
|
font.as_ref(),
|
||||||
|
text,
|
||||||
|
Vector2 { x, y },
|
||||||
|
size,
|
||||||
|
letter_spacing.into(),
|
||||||
|
color.unwrap_or(Color::BLUE),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn clay2ray(c: clay_layout::color::Color) -> Color {
|
||||||
|
Color {
|
||||||
|
r: (c.r as f32 * 256.0) as u8,
|
||||||
|
g: (c.g as f32 * 256.0) as u8,
|
||||||
|
b: (c.b as f32 * 256.0) as u8,
|
||||||
|
a: (c.a as f32 * 256.0) as u8,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<(), String> {
|
||||||
|
println!("Openbirch GUI");
|
||||||
|
|
||||||
|
let (mut rl, thread) = raylib::init()
|
||||||
|
.size(640, 480)
|
||||||
|
.title("Openbirch GUI")
|
||||||
|
.msaa_4x()
|
||||||
|
.resizable()
|
||||||
|
.build();
|
||||||
|
let mut clay = clay_layout::Clay::new((640., 480.).into());
|
||||||
|
// let font = match rl.load_font_ex(&thread, "MononokiNerdFont-Regular.ttf", 20, None) {
|
||||||
|
// Ok(font) => font,
|
||||||
|
// Err(err) => panic!("Failed to load font {}", err),
|
||||||
|
// };
|
||||||
|
let font_store = Rc::new(RefCell::new(FontStore::new("MononokiNerdFont-Regular.ttf")));
|
||||||
|
let font_store_math = Rc::new(RefCell::new(FontStore::new("xits-italic.ttf")));
|
||||||
|
|
||||||
|
{
|
||||||
|
font_store.borrow_mut().get(16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// stupid fucking 'static closures
|
||||||
|
let font_store_clone = font_store.clone();
|
||||||
|
let font_store_math_clone = font_store.clone();
|
||||||
|
|
||||||
|
clay.set_measure_text_function(move |text, config| {
|
||||||
|
let mut text_size = clay_layout::math::Dimensions::new(0., 0.);
|
||||||
|
|
||||||
|
let font_store = match config.font_id {
|
||||||
|
0 => font_store_clone.clone(),
|
||||||
|
1 => font_store_math_clone.clone(),
|
||||||
|
_ => panic!("Unknown font {}", config.font_id),
|
||||||
|
};
|
||||||
|
|
||||||
|
let font = if let Some(font) = font_store.borrow_mut().get(config.font_size.into()) {
|
||||||
|
font
|
||||||
|
} else {
|
||||||
|
println!("Font not cached. Returning: {:?}", text_size);
|
||||||
|
return text_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
let size = font.measure_text(text, config.font_size.into(), config.letter_spacing.into());
|
||||||
|
|
||||||
|
text_size.width = size.x;
|
||||||
|
text_size.height = size.y;
|
||||||
|
|
||||||
|
println!("Measurements: {:?}", text_size);
|
||||||
|
|
||||||
|
text_size
|
||||||
});
|
});
|
||||||
|
|
||||||
loop {
|
rl.set_target_fps(30);
|
||||||
dt.clear(SolidSource::from_unpremultiplied_argb(
|
|
||||||
0xff, 0xff, 0xff, 0xff,
|
let mut debug = false;
|
||||||
));
|
|
||||||
|
while !rl.window_should_close() {
|
||||||
|
if rl.is_window_resized() {
|
||||||
|
let size = (rl.get_screen_width() as f32 - 200., rl.get_screen_height() as f32);
|
||||||
|
clay.layout_dimensions(size.into());
|
||||||
|
println!("Resized window to {:?}", size);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
font_store.borrow_mut().load_fonts(&mut rl, &thread)?;
|
||||||
|
font_store_math.borrow_mut().load_fonts(&mut rl, &thread)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if rl.is_key_pressed(raylib::ffi::KeyboardKey::KEY_D) {
|
||||||
|
debug = !debug;
|
||||||
|
clay.reset_measure_text_cache();
|
||||||
|
clay.enable_debug_mode(debug);
|
||||||
|
println!("Toggled debug mode to {debug}");
|
||||||
|
}
|
||||||
|
|
||||||
|
clay.set_debug_highlight((0xff, 0x0, 0x0).into());
|
||||||
|
|
||||||
clay.begin();
|
clay.begin();
|
||||||
|
|
||||||
// Adds a red rectangle with a corner radius of 5.
|
|
||||||
// The Layout makes the rectangle have a width and height of 50.
|
|
||||||
clay.with(
|
clay.with(
|
||||||
[
|
Declaration::new()
|
||||||
Id::new("red_rectangle"),
|
.id(clay.id("body"))
|
||||||
Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
|
.layout()
|
||||||
Rectangle::new()
|
.width(grow!(0.))
|
||||||
.color((0xFF, 0x00, 0x00).into())
|
.height(grow!(0.))
|
||||||
.corner_radius(CornerRadius::All(5.))
|
.direction(LayoutDirection::TopToBottom)
|
||||||
|
.padding(Padding::all(8))
|
||||||
|
.child_gap(0)
|
||||||
|
.end()
|
||||||
|
.scroll(false, true),
|
||||||
|
|clay| {
|
||||||
|
for i in 0..0 {
|
||||||
|
clay.with(
|
||||||
|
Declaration::new()
|
||||||
|
.id(clay.id(i.to_string().as_str()))
|
||||||
|
.layout()
|
||||||
|
.width(grow!(0.))
|
||||||
|
.height(fit!(0.))
|
||||||
|
.padding(Padding::all(4))
|
||||||
.end(),
|
.end(),
|
||||||
],
|
|clay| {
|
||||||
|c| {
|
clay.text(
|
||||||
c.with(
|
"test",
|
||||||
[
|
TextConfig::new()
|
||||||
Id::new("test_text"),
|
.color((0x0, 0x0, 0x0).into())
|
||||||
Layout::new().end(),
|
.font_size(16)
|
||||||
Rectangle::new().color((0xFF, 0xFF, 0xFF).into()).end(),
|
.end(),
|
||||||
// Text::new().color((0xFF, 0xFF, 0xFF).into()).end()
|
)
|
||||||
],
|
},
|
||||||
|_| {},
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return the list of render commands of your layout
|
|
||||||
let render_commands = clay.end();
|
let render_commands = clay.end();
|
||||||
|
|
||||||
for command in render_commands {
|
let mut d = rl.begin_drawing(&thread);
|
||||||
// println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
|
|
||||||
// println!("Bounding box: {:?}", command.bounding_box);
|
|
||||||
// println!("Type and config: {:?}", command.config);
|
|
||||||
|
|
||||||
match command.config {
|
d.clear_background(Color::WHITE);
|
||||||
clay_layout::render_commands::RenderCommandConfig::Rectangle(rectangle) => {
|
|
||||||
dt.fill_rect(
|
|
||||||
command.bounding_box.x,
|
|
||||||
command.bounding_box.y,
|
|
||||||
command.bounding_box.width,
|
|
||||||
command.bounding_box.height,
|
|
||||||
&raqote::Source::Solid(SolidSource {
|
|
||||||
r: (rectangle.color.r * 255.0) as u8,
|
|
||||||
g: (rectangle.color.g * 255.0) as u8,
|
|
||||||
b: (rectangle.color.b * 255.0) as u8,
|
|
||||||
a: (rectangle.color.a * 255.0) as u8,
|
|
||||||
}),
|
|
||||||
&DrawOptions::new(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::Border(border_container) => {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::Text(_, text) => todo!(),
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::Image(image) => todo!(),
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::ScissorStart() => todo!(),
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::ScissorEnd() => todo!(),
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::Custom(custom) => todo!(),
|
|
||||||
clay_layout::render_commands::RenderCommandConfig::None() => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if window.is_key_down(minifb::Key::Escape) {
|
/*
|
||||||
|
for (int j = 0; j < renderCommands.length; j++)
|
||||||
|
{
|
||||||
|
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
|
||||||
|
Clay_BoundingBox boundingBox = renderCommand->boundingBox;
|
||||||
|
switch (renderCommand->commandType)
|
||||||
|
{
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
||||||
|
// Raylib uses standard C strings so isn't compatible with cheap slices, we need to clone the string to append null terminator
|
||||||
|
Clay_TextRenderData *textData = &renderCommand->renderData.text;
|
||||||
|
char *cloned = (char *)malloc(textData->stringContents.length + 1);
|
||||||
|
memcpy(cloned, textData->stringContents.chars, textData->stringContents.length);
|
||||||
|
cloned[textData->stringContents.length] = '\0';
|
||||||
|
Font fontToUse = fonts[textData->fontId];
|
||||||
|
DrawTextEx(fontToUse, cloned, (Vector2){boundingBox.x, boundingBox.y}, (float)textData->fontSize, (float)textData->letterSpacing, CLAY_COLOR_TO_RAYLIB_COLOR(textData->textColor));
|
||||||
|
free(cloned);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_IMAGE: {
|
||||||
|
Texture2D imageTexture = *(Texture2D *)renderCommand->renderData.image.imageData;
|
||||||
|
Clay_Color tintColor = renderCommand->renderData.image.backgroundColor;
|
||||||
|
if (tintColor.r == 0 && tintColor.g == 0 && tintColor.b == 0 && tintColor.a == 0) {
|
||||||
|
tintColor = (Clay_Color) { 255, 255, 255, 255 };
|
||||||
|
}
|
||||||
|
DrawTextureEx(
|
||||||
|
imageTexture,
|
||||||
|
(Vector2){boundingBox.x, boundingBox.y},
|
||||||
|
0,
|
||||||
|
boundingBox.width / (float)imageTexture.width,
|
||||||
|
CLAY_COLOR_TO_RAYLIB_COLOR(tintColor));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLAY_RENDER_COMMAND_TYPE_CUSTOM: {
|
||||||
|
Clay_CustomRenderData *config = &renderCommand->renderData.custom;
|
||||||
|
CustomLayoutElement *customElement = (CustomLayoutElement *)config->customData;
|
||||||
|
if (!customElement) continue;
|
||||||
|
switch (customElement->type) {
|
||||||
|
case CUSTOM_LAYOUT_ELEMENT_TYPE_3D_MODEL: {
|
||||||
|
Clay_BoundingBox rootBox = renderCommands.internalArray[0].boundingBox;
|
||||||
|
float scaleValue = CLAY__MIN(CLAY__MIN(1, 768 / rootBox.height) * CLAY__MAX(1, rootBox.width / 1024), 1.5f);
|
||||||
|
Ray positionRay = GetScreenToWorldPointWithZDistance((Vector2) { renderCommand->boundingBox.x + renderCommand->boundingBox.width / 2, renderCommand->boundingBox.y + (renderCommand->boundingBox.height / 2) + 20 }, Raylib_camera, (int)roundf(rootBox.width), (int)roundf(rootBox.height), 140);
|
||||||
|
BeginMode3D(Raylib_camera);
|
||||||
|
DrawModel(customElement->customData.model.model, positionRay.position, customElement->customData.model.scale * scaleValue, WHITE); // Draw 3d model with texture
|
||||||
|
EndMode3D();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
printf("Error: unhandled render command.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
let (width, height) = window.get_size();
|
for command in render_commands {
|
||||||
|
match command.config {
|
||||||
|
RenderCommandConfig::Rectangle(rectangle) => {
|
||||||
|
println!("RECT!!! {}: {:?}\n{:?}\n\n", command.id, command.bounding_box, rectangle);
|
||||||
|
|
||||||
if width as i32 != dt.width() || height as i32 != dt.height() {
|
d.draw_rectangle_rounded(
|
||||||
dt = DrawTarget::new(width as i32, height as i32);
|
raylib::ffi::Rectangle {
|
||||||
clay.layout_dimensions((width as f32, height as f32).into());
|
x: command.bounding_box.x,
|
||||||
size = (width, height);
|
y: command.bounding_box.y,
|
||||||
// window.update();
|
width: command.bounding_box.width,
|
||||||
} else {
|
height: command.bounding_box.height,
|
||||||
window
|
},
|
||||||
.update_with_buffer(dt.get_data(), size.0, size.1)
|
rectangle.corner_radii.top_left,
|
||||||
.unwrap();
|
8,
|
||||||
|
clay2ray(rectangle.color),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
RenderCommandConfig::Text(text) => {
|
||||||
|
// println!("{:?}", text);
|
||||||
|
font_store.borrow_mut().text(
|
||||||
|
&mut d,
|
||||||
|
text.text,
|
||||||
|
command.bounding_box.x,
|
||||||
|
command.bounding_box.y,
|
||||||
|
text.font_size as f32,
|
||||||
|
text.letter_spacing,
|
||||||
|
Some(clay2ray(text.color)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderCommandConfig::ScissorStart() => unsafe {
|
||||||
|
raylib::ffi::BeginScissorMode(
|
||||||
|
command.bounding_box.x as i32,
|
||||||
|
command.bounding_box.y as i32,
|
||||||
|
command.bounding_box.width as i32,
|
||||||
|
command.bounding_box.height as i32,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
RenderCommandConfig::ScissorEnd() => unsafe {
|
||||||
|
raylib::ffi::EndScissorMode();
|
||||||
|
},
|
||||||
|
|
||||||
|
RenderCommandConfig::Border(border) => {
|
||||||
|
// if (config->cornerRadius.topLeft > 0) {
|
||||||
|
// DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.topLeft), roundf(boundingBox.y + config->cornerRadius.topLeft) }, roundf(config->cornerRadius.topLeft - config->width.top), config->cornerRadius.topLeft, 180, 270, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
// }
|
||||||
|
// if (config->cornerRadius.topRight > 0) {
|
||||||
|
// DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
// }
|
||||||
|
// if (config->cornerRadius.bottomLeft > 0) {
|
||||||
|
// DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.top), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
// }
|
||||||
|
// if (config->cornerRadius.bottomRight > 0) {
|
||||||
|
// DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// Left border
|
||||||
|
if border.width.left > 0 {
|
||||||
|
d.draw_rectangle(
|
||||||
|
command.bounding_box.x as i32,
|
||||||
|
(command.bounding_box.y + border.corner_radii.top_left) as i32,
|
||||||
|
border.width.left as i32,
|
||||||
|
(command.bounding_box.height
|
||||||
|
- border.corner_radii.top_left
|
||||||
|
- border.corner_radii.bottom_left)
|
||||||
|
as i32,
|
||||||
|
clay2ray(border.color),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Right border
|
||||||
|
if border.width.right > 0 {
|
||||||
|
d.draw_rectangle(
|
||||||
|
(command.bounding_box.x + command.bounding_box.width
|
||||||
|
- border.width.right as f32) as i32,
|
||||||
|
(command.bounding_box.y + border.corner_radii.top_right) as i32,
|
||||||
|
border.width.right as i32,
|
||||||
|
(command.bounding_box.height
|
||||||
|
- border.corner_radii.top_right
|
||||||
|
- border.corner_radii.bottom_right)
|
||||||
|
as i32,
|
||||||
|
clay2ray(border.color),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Top border
|
||||||
|
if border.width.top > 0 {
|
||||||
|
d.draw_rectangle(
|
||||||
|
(command.bounding_box.x + border.corner_radii.top_left) as i32,
|
||||||
|
(command.bounding_box.y) as i32,
|
||||||
|
(command.bounding_box.width
|
||||||
|
- border.corner_radii.top_left
|
||||||
|
- border.corner_radii.top_right) as i32,
|
||||||
|
(border.width.top) as i32,
|
||||||
|
clay2ray(border.color),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Top border
|
||||||
|
if border.width.bottom > 0 {
|
||||||
|
d.draw_rectangle(
|
||||||
|
(command.bounding_box.x + border.corner_radii.bottom_left) as i32,
|
||||||
|
(command.bounding_box.y + command.bounding_box.height
|
||||||
|
- border.width.bottom as f32) as i32,
|
||||||
|
(command.bounding_box.width
|
||||||
|
- border.corner_radii.bottom_left
|
||||||
|
- border.corner_radii.bottom_right)
|
||||||
|
as i32,
|
||||||
|
border.width.bottom as i32,
|
||||||
|
clay2ray(border.color),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderCommandConfig::None() => {}
|
||||||
|
_ => panic!("Unimplemented {:#?}", command),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
BIN
xits-italic.otf
Normal file
BIN
xits-italic.otf
Normal file
Binary file not shown.
BIN
xits-italic.ttf
Normal file
BIN
xits-italic.ttf
Normal file
Binary file not shown.
Loading…
Reference in a new issue