mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
don't require the color and the width in mez.view.set_border
This commit is contained in:
parent
6be66b6a71
commit
87259f96cb
1 changed files with 31 additions and 26 deletions
|
|
@ -328,11 +328,14 @@ pub fn get_resizing(L: *zlua.Lua) i32 {
|
||||||
pub fn set_border(L: *zlua.Lua) i32 {
|
pub fn set_border(L: *zlua.Lua) i32 {
|
||||||
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
|
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
|
||||||
|
|
||||||
|
var border_color: ?[4]f32 = null;
|
||||||
|
var width: ?u32 = null;
|
||||||
|
|
||||||
_ = L.pushString("color");
|
_ = L.pushString("color");
|
||||||
_ = L.getTable(2);
|
if (L.getTable(2) != .nil) {
|
||||||
if (!L.isString(-1)) L.raiseErrorStr("The color must be a string", .{});
|
if (!L.isString(-1)) L.raiseErrorStr("The color must be a string", .{});
|
||||||
const color = L.checkString(-1);
|
const color = L.checkString(-1);
|
||||||
const border_color: [4]f32 = color: {
|
border_color = color: {
|
||||||
errdefer L.raiseErrorStr("The color must be a valid hex string", .{});
|
errdefer L.raiseErrorStr("The color must be a valid hex string", .{});
|
||||||
|
|
||||||
var start_color_idx: u8 = 0;
|
var start_color_idx: u8 = 0;
|
||||||
|
|
@ -352,18 +355,20 @@ pub fn set_border(L: *zlua.Lua) i32 {
|
||||||
|
|
||||||
break :color .{ r, g, b, a };
|
break :color .{ r, g, b, a };
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
_ = L.pushString("width");
|
_ = L.pushString("width");
|
||||||
_ = L.getTable(2);
|
if (L.getTable(2) != .nil) {
|
||||||
const width = LuaUtils.coerceInteger(u32, L.checkInteger(-1)) catch {
|
width = LuaUtils.coerceInteger(u32, L.checkInteger(-1)) catch {
|
||||||
L.raiseErrorStr("The border width must be >= 0 and < inf", .{});
|
L.raiseErrorStr("The border width must be >= 0 and < inf", .{});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (LuaUtils.viewById(view_id)) |v| {
|
if (LuaUtils.viewById(view_id)) |v| {
|
||||||
v.setBorderColor(&border_color);
|
if (border_color != null) v.setBorderColor(&border_color.?);
|
||||||
|
|
||||||
if (width != v.border_width) {
|
if (width != null and width.? != v.border_width) {
|
||||||
v.border_width = @intCast(width);
|
v.border_width = @intCast(width.?);
|
||||||
// the size has changed which means we need to update the borders
|
// the size has changed which means we need to update the borders
|
||||||
v.resizeBorders();
|
v.resizeBorders();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue