Skip to content

Commit

Permalink
directvt#571 WIP: Allow semitransparent desktop background, disable s…
Browse files Browse the repository at this point in the history
…hadows for text windows by default
  • Loading branch information
o-sdn-o committed Sep 11, 2024
1 parent 62f342f commit da180fd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/netxs/apps/desk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ namespace netxs::app::desk
auto background = [](auto appid, auto label, auto title)
{
auto highlight_color = skin::color(tone::highlight);
auto c8 = cell{}.bgc(0x00).fgc(highlight_color.bgc());
auto c8 = cell{}.bgc(argb::active_transparent).fgc(highlight_color.bgc());
auto ver_label = ui::item::ctor(utf::concat(app::shared::version))
->active(cell{}.fgc(whitedk))
->active(cell{}.fgc(whitedk).bgc(argb::active_transparent))
->shader(c8, e2::form::state::hover)
->limits({}, { -1, 1 })
->alignment({ snap::tail, snap::tail });
Expand Down
35 changes: 21 additions & 14 deletions src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ namespace netxs
chan.b = chan.b > 0xFF - k ? 0xFF : chan.b + k;
}
}
else if (chan.a == 0)
else if (chan.a < 2)
{
auto k = (byte)std::clamp(48 * factor, 0, 0xFF);
chan.r = 255;
chan.g = 255;
chan.b = 255;
chan.a = k;
chan.r = k;
chan.g = k;
chan.b = k;
chan.a = (byte)std::min(255, 2 * k);
}
else
{
Expand Down Expand Up @@ -469,13 +469,13 @@ namespace netxs
second.chan.b = second.chan.b > 0xFF - k ? 0xFF : second.chan.b + k;
}
}
else if (chan.a == 0)
else if (chan.a < 2)
{
auto k = (byte)std::clamp(48 * factor, 0, 0xFF);
chan.r = 255;
chan.g = 255;
chan.b = 255;
chan.a = k;
chan.r = k;
chan.g = k;
chan.b = k;
chan.a = (byte)std::min(255, 2 * k);
second.chan.r = second.chan.r > 0xFF - k ? 0xFF : second.chan.r + k;
second.chan.g = second.chan.g > 0xFF - k ? 0xFF : second.chan.g + k;
second.chan.b = second.chan.b > 0xFF - k ? 0xFF : second.chan.b + k;
Expand All @@ -491,7 +491,7 @@ namespace netxs
chan.r = chan.r < k ? 0x00 : chan.r - k;
chan.g = chan.g < k ? 0x00 : chan.g - k;
chan.b = chan.b < k ? 0x00 : chan.b - k;
chan.a = chan.a > 0xFF - k ? 0xFF : chan.a + k;
//chan.a = chan.a > 0xFF - k ? 0xFF : chan.a + k;
second.chan.r = second.chan.r < k ? 0x00 : second.chan.r - k;
second.chan.g = second.chan.g < k ? 0x00 : second.chan.g - k;
second.chan.b = second.chan.b < k ? 0x00 : second.chan.b - k;
Expand All @@ -502,7 +502,8 @@ namespace netxs
chan.r = chan.r > 0xFF - k ? 0xFF : chan.r + k;
chan.g = chan.g > 0xFF - k ? 0xFF : chan.g + k;
chan.b = chan.b > 0xFF - k ? 0xFF : chan.b + k;
chan.a = chan.a > 0xFF - k ? 0xFF : chan.a + k;
// xlight for 0x80'000000 is invisible on purewhite os desktop
//chan.a = chan.a > 0xFF - k ? 0xFF : chan.a + k;
second.chan.r = second.chan.r > 0xFF - k ? 0xFF : second.chan.r + k;
second.chan.g = second.chan.g > 0xFF - k ? 0xFF : second.chan.g + k;
second.chan.b = second.chan.b > 0xFF - k ? 0xFF : second.chan.b + k;
Expand Down Expand Up @@ -542,6 +543,7 @@ namespace netxs
}

static constexpr auto default_color = 0x00'FF'FF'FF;
static constexpr auto active_transparent = 0x01'000000;

template<si32 i>
static constexpr ui32 _vt16 = // Compile-time value assigning (sorted by enum).
Expand Down Expand Up @@ -2034,8 +2036,13 @@ namespace netxs
{
if (src.isnul()) return;
auto& fgc = src.fgc();
if (fgc.chan.a == 0x00) dst.fgc(invert(dst.bgc())).fusefull(src);
else dst.fusefull(src);
if (fgc.chan.a == 0x00)
{
auto& bgc = dst.bgc();
if (bgc.chan.a < 2) dst.fgc(0xFFffffff);
else dst.fgc(invert(bgc));
}
dst.fusefull(src);
}
};
struct lite_t : public brush_t<lite_t>
Expand Down
6 changes: 5 additions & 1 deletion src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ namespace netxs::ui
if (!alive) return;
auto area = canvas.full() + outer;
auto bord = outer - inner;
canvas.cage(area, bord, [&](cell& c){ c.link(boss.id); });
canvas.cage(area, bord, [&](cell& c)
{
c.link(boss.id);
if (c.bga() == 0) c.bga(1); // Active transparent.
});
items.foreach([&](auto& item)
{
item.draw(canvas, area, cell::shaders::xlight);
Expand Down
44 changes: 31 additions & 13 deletions src/netxs/desktopio/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,20 +1254,18 @@ namespace netxs::gui
auto target_ptr = &canvas;
if constexpr (std::is_same_v<std::decay_t<T>, noop>)
{
if (bgc.alpha()) netxs::onrect(canvas, placeholder, cell::shaders::full(bgc));
netxs::onrect(canvas, placeholder, cell::shaders::full(bgc));
}
else
{
if (c.blk())
{
target_ptr = &blink_canvas;
blink_canvas.clip(placeholder);
if (bgc.alpha()) // Fill the blinking layer's background to fix DWM that doesn't take gamma into account during layered window blending.
{
netxs::onclip(canvas, blink_canvas, [&](auto& dst, auto& src){ dst = bgc; src = bgc; });
}
// Fill the blinking layer's background to fix DWM that doesn't take gamma into account during layered window blending.
netxs::onclip(canvas, blink_canvas, [&](auto& dst, auto& src){ dst = bgc; src = bgc; });
}
else if (bgc.alpha()) netxs::onrect(canvas, placeholder, cell::shaders::full(bgc));
else netxs::onrect(canvas, placeholder, cell::shaders::full(bgc));
}
auto& target = *target_ptr;
if (auto u = c.und())
Expand Down Expand Up @@ -1352,12 +1350,32 @@ namespace netxs::gui
else return;
}
auto& glyph_mask = iter->second;
if (!glyph_mask.area) return;

auto [w, h, x, y] = c.whxy();
if (x == 0 || y == 0) return;
auto offset = placeholder.coor - twod{ cellsz.x * (x - 1), cellsz.y * (y - 1) };
draw_glyph(target, glyph_mask, offset, fgc);
if (glyph_mask.area)
{
auto [w, h, x, y] = c.whxy();
if (x != 0 && y != 0)
{
auto offset = placeholder.coor - twod{ cellsz.x * (x - 1), cellsz.y * (y - 1) };
//todo implement a contour or a shadow layer
//if (bgc.alpha() < 2 && fgc == argb{ purewhite })
//{
// auto blk = argb{ pureblack };
// draw_glyph(target, glyph_mask, offset - dot_10, blk);
// draw_glyph(target, glyph_mask, offset + dot_10, blk);
// draw_glyph(target, glyph_mask, offset - dot_01, blk);
// draw_glyph(target, glyph_mask, offset + dot_01, blk);
// draw_glyph(target, glyph_mask, offset - dot_11, blk);
// draw_glyph(target, glyph_mask, offset + dot_11, blk);
// draw_glyph(target, glyph_mask, offset - dot_01 + dot_10, blk);
// draw_glyph(target, glyph_mask, offset + dot_01 - dot_10, blk);
//}
draw_glyph(target, glyph_mask, offset, fgc);
}
}
if (bgc.alpha()< 2 && fgc == argb{ purewhite })
{
//edge
}
}
};

Expand Down Expand Up @@ -2313,7 +2331,7 @@ namespace netxs::gui
void draw_grips()
{
if (fsmode == state::maximized) return;
static auto trans = 0x01'00'00'00;
static auto trans = argb::active_transparent;
static auto shade = 0x5F'3f'3f'3f;
static auto black = 0x3F'00'00'00;
auto canvas = layer_get_bits(master);
Expand Down
4 changes: 2 additions & 2 deletions src/vtm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ R"==(
<kb_focus fgc=bluelt bgc=bluelt alpha=255/> <!-- Keyboard focus indicator. -->
<shadower bgc=0xB4202020/> <!-- Darklighter. -->
<shadow> <!-- Window shadow configuration. -->
<enabled=true/>
<enabled=0/>
<blur=3/> <!-- Blur radius (in cells). Default is 3. -->
<bias=0.37/> <!-- Shadow contour bias [0.0 - 1.0]. Default is 0.37 -->
<opacity=105.5/> <!-- Opacity level (alpha) [0.0 - 255.0]. Default is 105.5 -->
Expand Down Expand Up @@ -250,7 +250,7 @@ R"==(
<transparent = nocolor />
</set>
<client>
<background fgc=whitedk bgc=0xFF003040> <!-- Desktop background color. -->
<background fgc=whitedk bgc=0x80000000> <!-- Desktop background color. -->
<tile=""/> <!-- True color ANSI-art with gradients can be used here. -->
</background>
<clipboard>
Expand Down

0 comments on commit da180fd

Please sign in to comment.