buttonLabelAndIcon
Parameters
- src:std.builtin.SourceLocation
- std.builtin.SourceLocation
- combined_opts:ButtonLabelAndIconOptions
- ButtonLabelAndIconOptions
- opts:Options
- Options
Source
Implementation
pub fn buttonLabelAndIcon(src: std.builtin.SourceLocation, combined_opts: ButtonLabelAndIconOptions, opts: Options) bool {
// initialize widget and get rectangle from parent and make ourselves the new parent
var bw: ButtonWidget = undefined;
bw.init(src, combined_opts.button_opts, opts);
// process events (mouse and keyboard)
bw.processEvents();
const options = opts.strip().override(bw.style()).override(.{ .gravity_y = 0.5 });
// draw background/border
bw.drawBackground();
{
var outer_hbox = box(src, .{ .dir = .horizontal }, .{ .expand = .horizontal });
defer outer_hbox.deinit();
icon(@src(), combined_opts.icon_label orelse combined_opts.label, combined_opts.tvg_bytes, .{}, options.strip().override(.{ .gravity_x = if (combined_opts.icon_first) 0.0 else 1.0, .color_text = opts.color_text }));
labelEx(@src(), "{s}", .{combined_opts.label}, .{ .align_x = 0.5 }, options.strip().override(.{ .expand = .both }));
}
const click = bw.clicked();
bw.drawFocus();
bw.deinit();
return click;
}