Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/WidgetData.zig
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ pub fn visible(self: *const WidgetData) bool {
pub fn borderAndBackground(self: *const WidgetData, opts: struct {
fill_color: ?Color = null,
ninepatch: ?*const Ninepatch = null,
/// If null, 0.0 if natural scale >= 2, otherwise 1.0
/// If null, 1.0 (0.0 when drawing a ninepatch, which already has its
/// own baked edges).
fade: ?f32 = null,
}) void {
if (!self.visible()) {
Expand Down Expand Up @@ -233,7 +234,7 @@ pub fn borderAndBackground(self: *const WidgetData, opts: struct {

var rs = self.borderRectScale();
if (!rs.r.empty()) {
const fade: f32 = opts.fade orelse (if (dvui.windowNaturalScale() >= 2.0) 0.0 else 1.0);
const fade: f32 = opts.fade orelse 1.0;
if (fade > 0) {
// if any border is zero, inset by half the fade so it doesn't bleed out
var inset: Rect.Physical = .{};
Expand All @@ -259,7 +260,7 @@ pub fn borderAndBackground(self: *const WidgetData, opts: struct {
const fill = opts.fill_color orelse self.options.color(.fill);
rs.r.fill(self.options.cornersGet().scale(rs.s, CornerRect.Physical), .{
.color = fill,
.fade = opts.fade orelse (if (ninepatch != null or dvui.windowNaturalScale() >= 2.0) 0.0 else 1.0),
.fade = opts.fade orelse (if (ninepatch != null) 0.0 else 1.0),
});
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/widgets/GridWidget.zig
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,7 @@ pub const CellWidget = struct {
const rs = self.data().backgroundRectScale();
if (!rs.r.empty()) {
const fill = (dvui.themeGet().text_select orelse dvui.themeGet().color(.highlight, .fill)).opacity(0.75);
rs.r.fill(self.data().options.cornersGet().scale(rs.s, dvui.CornerRect.Physical), .{
.color = fill,
.fade = if (dvui.windowNaturalScale() >= 2.0) 0.0 else 1.0,
});
rs.r.fill(self.data().options.cornersGet().scale(rs.s, dvui.CornerRect.Physical), .{ .color = fill });
}
}
}
Expand Down
Loading