Skip to content

Commit

Permalink
directvt#400 WIP: Shaders (kb focus)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Oct 25, 2023
1 parent 92954f2 commit 325ef0a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/netxs/apps/shop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ namespace netxs::app::shop
for (auto& body : appstore_body) items->attach(ui::post::ctor())
->upload(body)
->active()
->plugin<pro::focus>()
->plugin<pro::grade>()
->plugin<pro::fader>(x3, c3, 250ms);
->shader(cell::shaders::xlight, e2::form::state::hover)
->shader(cell::shaders::color(c3), e2::form::state::keybd::focus::count);
items->attach(ui::post::ctor())
->upload(desktopio_body)
->plugin<pro::grade>();
Expand Down
12 changes: 6 additions & 6 deletions src/netxs/apps/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,30 @@ namespace netxs::app::tile
->shader(cell::shaders::xlight, e2::form::state::hover)
->invoke([&](auto& boss)
{
auto update_focus = [](auto& boss, auto state)
auto update_focus = [](auto& boss, auto count)
{
auto highlight_color = skin::color(tone::highlight);
auto c3 = highlight_color;
auto x3 = cell{ c3 }.alpha(0x00);
boss.base::color(state ? 0xFF00ff00 : x3.fgc(), x3.bgc());
boss.base::color(count ? 0xFF00ff00 : x3.fgc(), x3.bgc());
};
auto data_shadow = ptr::shadow(data_src_sptr);
boss.LISTEN(tier::release, e2::form::upon::vtree::attached, parent, boss.tracker, (data_shadow))
{
if (auto data_ptr = data_shadow.lock())
{
data_ptr->RISEUP(tier::request, e2::form::state::keybd::focus::state, state, ());
update_focus(boss, state);
data_ptr->RISEUP(tier::request, e2::form::state::keybd::focus::count, count, ());
update_focus(boss, count);
parent->resize();
}
};
boss.LISTEN(tier::release, e2::form::upon::vtree::detached, parent, boss.tracker)
{
if (parent) parent->resize(); // Rebuild list.
};
data_src_sptr->LISTEN(tier::release, e2::form::state::keybd::focus::state, state, boss.tracker)
data_src_sptr->LISTEN(tier::release, e2::form::state::keybd::focus::count, count, boss.tracker)
{
update_focus(boss, state);
update_focus(boss, count);
};
data_src_sptr->LISTEN(tier::release, events::delist, object, boss.tracker)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ namespace netxs::events::userland
{
EVENT_XS( on , const id_t ),
EVENT_XS( off , const id_t ),
EVENT_XS( state , bool ),
EVENT_XS( count , si32 ),
};
};
};
Expand Down
26 changes: 11 additions & 15 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,9 @@ namespace netxs::ui
body{ position, dot_11 }, // Caret is always one cell size (see the term::scrollback definition).
step{ freq }
{
boss.LISTEN(tier::release, e2::form::state::keybd::focus::state, state, conf)
boss.LISTEN(tier::release, e2::form::state::keybd::focus::count, count, conf)
{
down = !state;
down = !count;
};
boss.LISTEN(tier::request, e2::config::caret::blink, req_step, conf)
{
Expand Down Expand Up @@ -1236,17 +1236,14 @@ namespace netxs::ui
//todo std::list<config>??? std::unordered_map is too expensive
std::unordered_map<id_t, config> gears;

template<bool On = true>
void signal_state()
{
if constexpr (On == faux)
auto count = 0;
for (auto& [gear_id, route] : gears)
{
for (auto& [gear_id, route] : gears)
{
if (gear_id != id_t{} && route.active) return;
}
if (gear_id != id_t{} && route.active) ++count;
}
boss.SIGNAL(tier::release, e2::form::state::keybd::focus::state, On);
boss.SIGNAL(tier::release, e2::form::state::keybd::focus::count, count);
}
auto add_route(id_t gear_id, config cfg = { .active = faux, .focused = faux })
{
Expand All @@ -1267,7 +1264,7 @@ namespace netxs::ui
route.active = faux;
gears[id_t{}] = std::move(route);
boss.SIGNAL(tier::release, e2::form::state::keybd::focus::off, gear.id);
signal_state<faux>();
signal_state();
}
boss.SIGNAL(tier::release, hids::events::die, gear);
gears.erase(iter);
Expand Down Expand Up @@ -1425,7 +1422,7 @@ namespace netxs::ui
{
route.active = faux;
boss.SIGNAL(tier::release, e2::form::state::keybd::focus::off, seed.id);
signal_state<faux>();
signal_state();
}
//if constexpr (debugmode) log(prompt::foci, text(seed.deep * 4, ' '), "bus::off gear:", seed.id, " hub:", boss.id);
};
Expand Down Expand Up @@ -1562,14 +1559,13 @@ namespace netxs::ui
if (gear_id != id_t{} && route.active) gear_id_list.push_back(gear_id);
}
};
boss.LISTEN(tier::request, e2::form::state::keybd::focus::state, state, memo)
boss.LISTEN(tier::request, e2::form::state::keybd::focus::count, count, memo)
{
//todo revise: same as e2::form::state::keybd::check
state = faux;
count = 0;
for (auto& [gear_id, route] : gears)
{
state |= gear_id != id_t{} && route.active;
if (state) return;
if (gear_id != id_t{} && route.active) ++count;
}
};
boss.LISTEN(tier::request, e2::form::state::keybd::find, gear_test, memo)
Expand Down
7 changes: 4 additions & 3 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,12 @@ namespace netxs::ui
: owner{ owner },
encod{ prot::w32 }
{
owner.LISTEN(tier::release, e2::form::state::keybd::focus::state, s, token)
owner.LISTEN(tier::release, e2::form::state::keybd::focus::count, count, token)
{
if (state(s))
auto focused = !!count;
if (state(focused))
{
owner.ipccon.focus(s, encod);
owner.ipccon.focus(focused, encod);
}
};
owner.SIGNAL(tier::request, e2::form::state::keybd::check, state.last);
Expand Down

0 comments on commit 325ef0a

Please sign in to comment.