changed naming convention to zig's
This commit is contained in:
parent
38cc535235
commit
5339757abe
5 changed files with 197 additions and 239 deletions
|
@ -7,7 +7,7 @@ const light_grey: cl.Color = .{ 224, 215, 210, 255 };
|
|||
const red: cl.Color = .{ 168, 66, 28, 255 };
|
||||
const orange: cl.Color = .{ 225, 138, 50, 255 };
|
||||
|
||||
const sidebarItemLayout: cl.LayoutConfig = .{
|
||||
const sidebar_item_layout: cl.LayoutConfig = .{
|
||||
.size = .{
|
||||
.w = cl.sizingGrow(.{}),
|
||||
.h = cl.sizingFixed(50),
|
||||
|
@ -15,7 +15,7 @@ const sidebarItemLayout: cl.LayoutConfig = .{
|
|||
};
|
||||
|
||||
fn sidebarItemCompoment(index: usize) void {
|
||||
cl.rectangle(cl.IDI("SidebarBlob", @intCast(index)), cl.layout(sidebarItemLayout), cl.rectangleConfig(.{ .color = orange }));
|
||||
cl.rectangle(cl.IDI("SidebarBlob", @intCast(index)), cl.layout(sidebar_item_layout), cl.rectangleConfig(.{ .color = orange }));
|
||||
defer cl.closeParent();
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,10 @@ fn createLayout(profile_picture: *const rl.Texture2D) cl.ClayArray(cl.RenderComm
|
|||
cl.image(
|
||||
cl.ID("ProfilePicture"),
|
||||
cl.layout(.{ .size = .{ .h = cl.sizingFixed(60), .w = cl.sizingFixed(60) } }),
|
||||
cl.imageConfig(.{ .sourceDimensions = .{ .h = 60, .w = 60 }, .imageData = @ptrCast(@constCast(profile_picture)) }),
|
||||
cl.imageConfig(.{ .source_dimensions = .{ .h = 60, .w = 60 }, .image_data = @ptrCast(@constCast(profile_picture)) }),
|
||||
);
|
||||
cl.closeParent();
|
||||
cl.text(cl.ID("profileTitle"), "Clay - UI Library", cl.textConfig(.{ .fontSize = 24, .textColor = light_grey }));
|
||||
cl.text(cl.ID("profileTitle"), "Clay - UI Library", cl.textConfig(.{ .font_size = 24, .text_color = light_grey }));
|
||||
}
|
||||
|
||||
for (0..5) |i| {
|
||||
|
@ -86,9 +86,9 @@ fn createLayout(profile_picture: *const rl.Texture2D) cl.ClayArray(cl.RenderComm
|
|||
return cl.endLayout();
|
||||
}
|
||||
|
||||
fn loadFont(file_data: ?[]const u8, fontId: u16, fontSize: i32) void {
|
||||
renderer.raylib_fonts[fontId] = rl.loadFontFromMemory(".ttf", file_data, fontSize * 2, null);
|
||||
rl.setTextureFilter(renderer.raylib_fonts[fontId].?.texture, .texture_filter_bilinear);
|
||||
fn loadFont(file_data: ?[]const u8, font_id: u16, font_size: i32) void {
|
||||
renderer.raylib_fonts[font_id] = rl.loadFontFromMemory(".ttf", file_data, font_size * 2, null);
|
||||
rl.setTextureFilter(renderer.raylib_fonts[font_id].?.texture, .texture_filter_bilinear);
|
||||
}
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
|
@ -132,52 +132,10 @@ pub fn main() anyerror!void {
|
|||
.w = @floatFromInt(rl.getScreenWidth()),
|
||||
.h = @floatFromInt(rl.getScreenHeight()),
|
||||
});
|
||||
var renderCommands = createLayout(&profile_picture);
|
||||
var render_commands = createLayout(&profile_picture);
|
||||
|
||||
rl.beginDrawing();
|
||||
renderer.clayRaylibRender(&renderCommands, allocator);
|
||||
renderer.clayRaylibRender(&render_commands, allocator);
|
||||
rl.endDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
// explicit:
|
||||
cl.rectangle(
|
||||
cl.ID("SideBar"),
|
||||
cl.layout(.{
|
||||
.layoutDirection = .TOP_TO_BOTTOM,
|
||||
.sizing = .{ .height = cl.sizingGrow(.{}), .width = cl.sizingFixed(300) },
|
||||
.padding = .{ .x = 16, .y = 16 },
|
||||
.childAlignment = .{ .x = .CENTER, .y = .TOP },
|
||||
.childGap = 16,
|
||||
}),
|
||||
cl.rectangleConfig(.{ .color = light_grey }),
|
||||
);
|
||||
|
||||
// compact:
|
||||
cl.rectangle(
|
||||
cl.ID("SideBar"),
|
||||
cl.layout(.{
|
||||
.direction = .TOP_TO_BOTTOM,
|
||||
.size = .{ .h = cl.sizingGrow(.{}), .w = cl.sizingFixed(300) },
|
||||
.padding = .{ .x = 16, .y = 16 },
|
||||
.alignment = .{ .x = .CENTER, .y = .TOP },
|
||||
.gap = 16,
|
||||
}),
|
||||
cl.rectangleConfig(.{ .color = cl.light_grey }),
|
||||
);
|
||||
|
||||
// explicit:
|
||||
cl.rectangle(
|
||||
cl.ID("SideBar"),
|
||||
cl.layout(.{ .layoutDirection = .TOP_TO_BOTTOM, .sizing = .{ .height = cl.sizingGrow(.{}), .width = cl.sizingFixed(300) }, .padding = .{ .x = 16, .y = 16 }, .childAlignment = .{ .x = .CENTER, .y = .TOP }, .childGap = 16 }),
|
||||
cl.rectangleConfig(.{ .color = light_grey }),
|
||||
);
|
||||
|
||||
// compact:
|
||||
cl.rectangle(
|
||||
cl.ID("SideBar"),
|
||||
cl.layout(.{ .direction = .TOP_TO_BOTTOM, .size = .{ .h = cl.sizingGrow(.{}), .w = cl.sizingFixed(300) }, .padding = .{ .x = 16, .y = 16 }, .alignment = .{ .x = .CENTER, .y = .TOP }, .gap = 16 }),
|
||||
cl.rectangleConfig(.{ .color = cl.light_grey }),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue