Наброски UI
This commit is contained in:
50
src/main.zig
50
src/main.zig
@@ -2,6 +2,9 @@ const std = @import("std");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const dvui = @import("dvui");
|
const dvui = @import("dvui");
|
||||||
const SDLBackend = @import("sdl-backend");
|
const SDLBackend = @import("sdl-backend");
|
||||||
|
const sdl_c = SDLBackend.c;
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
|
const Color = dvui.Color;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
@@ -21,6 +24,7 @@ pub fn main() !void {
|
|||||||
.dark => dvui.Theme.builtin.adwaita_dark,
|
.dark => dvui.Theme.builtin.adwaita_dark,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defer win.deinit();
|
defer win.deinit();
|
||||||
|
|
||||||
var interrupted = false;
|
var interrupted = false;
|
||||||
@@ -61,5 +65,51 @@ pub fn main() !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn gui_frame() bool {
|
fn gui_frame() bool {
|
||||||
|
for (dvui.events()) |*e| {
|
||||||
|
if (e.evt == .window and e.evt.window.action == .close) return false;
|
||||||
|
if (e.evt == .app and e.evt.app.action == .quit) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = dvui.box(
|
||||||
|
@src(),
|
||||||
|
.{ .dir = .horizontal },
|
||||||
|
.{ .expand = .both, .background = true, .style = .window },
|
||||||
|
);
|
||||||
|
defer root.deinit();
|
||||||
|
|
||||||
|
// Левая панель с фиксированной шириной
|
||||||
|
{
|
||||||
|
var left_panel = dvui.box(@src(), .{ .dir = .vertical }, .{ .expand = .vertical, .min_size_content = .{ .w = 200 }, .background = true });
|
||||||
|
defer left_panel.deinit();
|
||||||
|
|
||||||
|
dvui.label(@src(), "Tools", .{}, .{});
|
||||||
|
_ = dvui.button(@src(), "Button", .{}, .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Правая панель - занимает оставшееся пространство
|
||||||
|
{
|
||||||
|
const back = dvui.box(
|
||||||
|
@src(),
|
||||||
|
.{ .dir = .horizontal },
|
||||||
|
.{ .expand = .both, .padding = dvui.Rect.all(12), .background = true },
|
||||||
|
);
|
||||||
|
defer back.deinit();
|
||||||
|
|
||||||
|
const fill_color = Color.white.opacity(0.5);
|
||||||
|
var right_panel = dvui.box(
|
||||||
|
@src(),
|
||||||
|
.{ .dir = .vertical },
|
||||||
|
.{
|
||||||
|
.expand = .both,
|
||||||
|
.background = true,
|
||||||
|
.corner_radius = dvui.Rect.all(10),
|
||||||
|
.color_fill = fill_color,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
defer right_panel.deinit();
|
||||||
|
|
||||||
|
dvui.label(@src(), "Canvas", .{}, .{ .gravity_x = 0.5 });
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user