Skip to content

Commit

Permalink
directvt#571 WIP: Minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Apr 19, 2024
1 parent c96cecc commit 6aeb8b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 13 additions & 2 deletions src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,14 @@ namespace netxs
{
return argb{ argb::gamma(c.chan.r),
argb::gamma(c.chan.g),
argb::gamma(c.chan.g), c.chan.a };
argb::gamma(c.chan.b), c.chan.a };
}
// argb: Premultiply alpha.
auto pma()
{
chan.r = (byte)((si32)chan.r * chan.a / 255);
chan.g = (byte)((si32)chan.g * chan.a / 255);
chan.b = (byte)((si32)chan.b * chan.a / 255);
}

template<si32 i>
Expand Down Expand Up @@ -2390,11 +2397,15 @@ namespace netxs
}
};

void fill(auto& canvas, auto block, auto fx) // gfx: Fill block.
void fill(auto&& canvas, auto block, auto fx) // gfx: Fill block.
{
block.normalize_itself();
netxs::onrect(canvas, block, fx);
}
void fill(auto&& canvas, auto fx) // gfx: Fill canvas area.
{
netxs::onrect(canvas, canvas.area(), fx);
}
void cage(auto& canvas, rect area, dent border, auto fx) // core: Draw the cage around specified area.
{
auto temp = area;
Expand Down
11 changes: 5 additions & 6 deletions src/netxs/desktopio/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ namespace netxs::gui
void display()
{
if (sync || !hdc) return;
//netxs::misc::fill(canvas(), [](argb& c){ c.pma(); });
static auto blend_props = BLENDFUNCTION{ .BlendOp = AC_SRC_OVER, .SourceConstantAlpha = 255, .AlphaFormat = AC_SRC_ALPHA };
auto scr_coor = POINT{};
auto old_size = SIZE{ prev.size.x, prev.size.y };
Expand Down Expand Up @@ -338,7 +339,7 @@ namespace netxs::gui
conf.reset();
}
constexpr explicit operator bool () const { return initialized; }
auto add(wins& layers, bool transparent, si32 owner_index = -1)
auto add(wins& layers, bool transparent, si32 owner_index = -1, window* host_ptr = nullptr)
{
auto window_proc = [](HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Expand Down Expand Up @@ -397,6 +398,7 @@ namespace netxs::gui
initialized = faux;
log("window creation error: ", ::GetLastError());
}
if (host_ptr) ::SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)host_ptr);
auto win_index = (si32)layers.size();
layers.emplace_back(conf, hWnd);
return win_index;
Expand Down Expand Up @@ -446,7 +448,6 @@ namespace netxs::gui

reng engine;
wins layers;
bool dx3d;
twod mouse_coord;
twod grid_size;
twod cell_size;
Expand All @@ -473,8 +474,7 @@ namespace netxs::gui
for (auto& w : layers) w.reset();
}
window(rect win_coor_px_size_cell, twod cell_size = { 10, 20 }, twod grip_cell = { 2, 1 })
: dx3d{ faux },
grid_size{ std::max(dot_11, win_coor_px_size_cell.size) },
: grid_size{ std::max(dot_11, win_coor_px_size_cell.size) },
cell_size{ cell_size },
grip_cell{ grip_cell },
grip_size{ grip_cell * cell_size },
Expand All @@ -487,14 +487,13 @@ namespace netxs::gui
shadow{ engine.add(layers, 0) },
header{ engine.add(layers, 0, shadow) },
footer{ engine.add(layers, 0, shadow) },
client{ engine.add(layers, 1, shadow) }
client{ engine.add(layers, 1, shadow, this) }
{
if (!engine) return;
layers[shadow].area = { inner_rect.coor - shadow_rastr.over / 2, inner_rect.size + shadow_rastr.over };
layers[client].area = inner_rect + outer_dent;
layers[header].area = rect{ inner_rect.coor, { inner_rect.size.x, -cell_size.y * ((header_para.size().x + grid_size.x - 1)/ grid_size.x) }}.normalize_itself();
layers[footer].area = rect{{ inner_rect.coor.x, inner_rect.coor.y + inner_rect.size.y }, { inner_rect.size.x, cell_size.y * ((footer_para.size().x + grid_size.x - 1)/ grid_size.x) }};
::SetWindowLongPtrW(layers[client].hWnd, GWLP_USERDATA, (LONG_PTR)this);
redraw();
initialized = true;
}
Expand Down

0 comments on commit 6aeb8b2

Please sign in to comment.