Skip to content

Commit

Permalink
directvt#400 WIP: Highlighting for mouse hover and kb focus
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Oct 23, 2023
1 parent b0030f7 commit 41b54f5
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 56 deletions.
1 change: 0 additions & 1 deletion doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ Note: The full defaut config is at [src/vtm.xml](../src/vtm.xml).
<viewport coor=0,0 />
<mouse dblclick=500ms />
<tooltips timeout=2000ms enabled=true fgc=pureblack bgc=purewhite />
<glowfx=true /> <!-- Show glow effect around selected item. -->
<debug overlay=off toggle="🐞" /> <!-- Display console debug info. -->
<regions enabled=0 /> <!-- Highlight UI objects boundaries. -->
</client>
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/calc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ R"==(
<viewport coor=0,0/>
<mouse dblclick=500ms/>
<tooltips timeout=2000ms enabled=true fgc=pureblack bgc=purewhite/>
<glowfx=true/> <!-- Show glow effect around selected item. -->
<debug overlay=0 toggle="🐞"/> <!-- Display console debug info. -->
<regions enabled=0/> <!-- Highlight UI objects boundaries. -->
</client>
Expand Down
53 changes: 26 additions & 27 deletions src/netxs/apps/desk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ namespace netxs::app::desk
auto tall = si32{ skin::globals().menuwide };
auto danger_color = skin::globals().danger;
auto highlight_color = skin::globals().highlight;
auto c4 = cell{}.bgc(highlight_color.bgc());
auto x4 = cell{ c4 }.bga(0x00);
auto c5 = danger_color;
auto x5 = cell{ c5 }.alpha(0x00);
auto fastfader = skin::globals().fader_fast;
auto fader = skin::globals().fader_time;
auto item_area = ui::fork::ctor()
->plugin<pro::fader>(x4, c4, fastfader)
->active()
->shader(cell::shaders::xlight, e2::form::state::mouse)
->plugin<pro::notes>(" Application window: \n"
" Left click to go to the window \n"
" Right click to pull the window ")
Expand Down Expand Up @@ -145,7 +143,8 @@ namespace netxs::app::desk
->flexible()
->drawdots();
auto app_close = item_area->attach(slot::_2, ui::item::ctor("×"))
->template plugin<pro::fader>(x5, c5, fader)
->active()
->shader(cell::shaders::color(c5), e2::form::state::mouse)
->template plugin<pro::notes>(" Close application window ")
->setpad({ 2, 2, tall, tall })
->invoke([&](auto& boss)
Expand Down Expand Up @@ -182,12 +181,9 @@ namespace netxs::app::desk
auto danger_color = skin::globals().danger;
auto c3 = highlight_color;
auto c9 = selected_color;
auto x3 = cell{ c3 }.alpha(0x00);
auto cA = inactive_color;
auto c6 = action_color;
auto x6 = cell{ c6 }.alpha(0x00);
auto c1 = danger_color;
auto x1 = cell{ c1 }.bga(0x00);

auto apps = ui::list::ctor()
->invoke([&](auto& boss)
Expand Down Expand Up @@ -219,14 +215,15 @@ namespace netxs::app::desk
auto item_area = apps->attach(ui::item::ctor(obj_desc))
->flexible()
->accented()
->setpad({ 0, 0, tall, tall },{ 0, 0, -tall, 0 })
->colors(cA.fgc(), cA.bgc())
->shader(cell::shaders::color(cA))
->setpad({ 0, 0, tall, tall }, { 0, 0, -tall, 0 })
->template plugin<pro::notes>(obj_note);
continue;
}
auto head_fork = ui::fork::ctor(axis::X, 0, 1, 0);
auto block = apps->attach(ui::list::ctor())
->template plugin<pro::fader>(x3, c3, skin::globals().fader_fast, head_fork)
->active()
->shader(cell::shaders::xlight, e2::form::state::mouse, head_fork)
->setpad({ 0, 0, 0, 0 }, { 0, 0, -tall, 0 });
if (!state) block->depend_on_collection(inst_ptr_list); // Remove not pinned apps, like Info/About.
block->attach(head_fork)
Expand Down Expand Up @@ -296,7 +293,8 @@ namespace netxs::app::desk
auto& isfolded = conf.folded;
auto fold_bttn = bttn_fork->attach(slot::_1, ui::item::ctor(isfolded ? "" : "<"))
->setpad({ 2, 2, tall, tall })
->template plugin<pro::fader>(x6, c6, skin::globals().fader_time)
->active()
->shader(cell::shaders::color(c6), e2::form::state::mouse)
->template plugin<pro::notes>(" Hide active window list. \n"
" Use mouse wheel to switch it to close. ")
->invoke([&](auto& boss)
Expand All @@ -317,7 +315,8 @@ namespace netxs::app::desk
});
auto drop_bttn = bttn_fork->attach(slot::_2, ui::item::ctor("×"))
->setpad({ 2, 2, tall, tall })
->template plugin<pro::fader>(x1, c1, skin::globals().fader_time)
->active()
->shader(cell::shaders::color(c1), e2::form::state::mouse)
->template plugin<pro::notes>(" Close all open windows in the group ")
->invoke([&](auto& boss)
{
Expand Down Expand Up @@ -371,9 +370,9 @@ namespace netxs::app::desk
{
auto highlight_color = skin::color(tone::highlight);
auto c8 = cell{}.bgc(0x00).fgc(highlight_color.bgc());
auto x8 = cell{ c8 }.alpha(0x00);
auto ver_label = ui::item::ctor(utf::concat(app::shared::version))
->plugin<pro::fader>(x8, c8, 0ms)
->active()
->shader(cell::shaders::color(c8), e2::form::state::mouse)
->limits({}, { -1, 1 })
->alignment({ snap::tail, snap::tail });
return ui::cake::ctor()
Expand Down Expand Up @@ -436,13 +435,9 @@ namespace netxs::app::desk
auto danger_color = skin::globals().danger;
auto cA = inactive_color;
auto c3 = highlight_color;
auto x3 = cell{ c3 }.alpha(0x00);
auto c6 = action_color;
auto x6 = cell{ c6 }.alpha(0x00);
auto c2 = warning_color;
auto x2 = cell{ c2 }.bga(0x00);
auto c1 = danger_color;
auto x1 = cell{ c1 }.bga(0x00);

auto menu_bg_color = config.take("/config/menu/color", cell{}.fgc(whitedk).bgc(0x60202020));
auto menu_min_size = config.take("/config/menu/width/folded", si32{ 4 });
Expand Down Expand Up @@ -499,7 +494,8 @@ namespace netxs::app::desk
.fgx(data_src->id == my_id ? rgba::vt256[whitelt] : 0x00).add(utf8).nil())
->flexible()
->setpad({ 1, 0, tall, tall }, { 0, 0, -tall, 0 })
->template plugin<pro::fader>(x3, c3, skin::globals().fader_time)
->active()
->shader(cell::shaders::xlight, e2::form::state::mouse)
->template plugin<pro::notes>(" Connected user ");
return user;
};
Expand Down Expand Up @@ -567,13 +563,13 @@ namespace netxs::app::desk
};
});
auto taskbar_park = taskbar_viewport->attach(slot::_1, ui::cake::ctor())
->colors(menu_bg_color.fgc(), menu_bg_color.bgc())
->active()
->limits({ menu_min_size, -1 }, { menu_min_size, -1 })
->plugin<pro::notes>(" LeftDrag to adjust the taskbar width \n"
" Ctrl+LeftDrag to adjust the folded taskbar width \n"
" RightDrag or scroll wheel to slide the taskbar menu up/down ")
->plugin<pro::timer>()
->plugin<pro::acryl>()
->plugin<pro::acryl>(menu_bg_color)
->plugin<pro::cache>()
->invoke([&](auto& boss)
{
Expand Down Expand Up @@ -668,12 +664,13 @@ namespace netxs::app::desk
auto label = label_bttn->attach(slot::_1, ui::item::ctor("users"))
->flexible()
->accented()
->shader(cell::shaders::color(cA))
->setpad({ 0, 0, tall, tall })
->limits({ 5, -1 })
->colors(cA.fgc(), cA.bgc());
->limits({ 5, -1 });
auto userlist_hidden = true;
auto bttn = label_bttn->attach(slot::_2, ui::item::ctor(userlist_hidden ? "" : "<"))
->plugin<pro::fader>(x6, c6, skin::globals().fader_time)
->active()
->shader(cell::shaders::color(c6), e2::form::state::mouse)
->plugin<pro::notes>(" Show/hide user list ")
->setpad({ 2, 2, tall, tall });
auto userlist_area = users_area->attach(ui::cake::ctor())
Expand Down Expand Up @@ -712,7 +709,8 @@ namespace netxs::app::desk
auto bttns = bttns_area->attach(ui::fork::ctor(axis::X))
->limits(bttn_min_size, bttn_max_size);
auto disconnect_park = bttns->attach(slot::_1, ui::cake::ctor())
->plugin<pro::fader>(x2, c2, skin::globals().fader_time)
->active()
->shader(cell::shaders::color(c2), e2::form::state::mouse)
->plugin<pro::notes>(" Leave current session ")
->invoke([&, name = text{ username_view }](auto& boss)
{
Expand All @@ -726,7 +724,8 @@ namespace netxs::app::desk
auto disconnect_area = disconnect_park->attach(ui::pads::ctor(dent{ 2, 3, tall, tall })->alignment({ snap::head, snap::center }));
auto disconnect = disconnect_area->attach(ui::item::ctor("× Disconnect"));
auto shutdown_park = bttns->attach(slot::_2, ui::cake::ctor())
->plugin<pro::fader>(x1, c1, skin::globals().fader_time)
->active()
->shader(cell::shaders::color(c1), e2::form::state::mouse)
->plugin<pro::notes>(" Disconnect all users and shutdown ")
->invoke([&](auto& boss)
{
Expand Down
1 change: 0 additions & 1 deletion src/netxs/apps/term.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ R"==(
<viewport coor=0,0/>
<mouse dblclick=500ms/>
<tooltips timeout=2000ms enabled=true fgc=pureblack bgc=purewhite/>
<glowfx=true/> <!-- Show glow effect around selected item. -->
<debug overlay=0 toggle="🐞"/> <!-- Display console debug info. -->
<regions enabled=0/> <!-- Highlight UI objects boundaries. -->
</client>
Expand Down
18 changes: 16 additions & 2 deletions src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ namespace netxs::app::shared
text onkey{};
si32 value{};
pair brush{};
cell hover{};
cell focus{};
};

using imap = std::unordered_map<si32, si32>;
Expand Down Expand Up @@ -235,8 +237,20 @@ namespace netxs::app::shared
auto& notes = props.views.front().notes;
auto& brush = props.views.front().brush;
auto button = ui::item::ctor(label)->drawdots();
if (hover) button->template plugin<pro::fader>(brush.first, brush.second, turntime); //todo template: GCC complains
else button->colors(0,0); //todo for mouse tracking
//if (hover) button->template plugin<pro::fader>(brush.first, brush.second, turntime); //todo template: GCC complains
//else button->colors(0,0); //todo for mouse tracking
button->active();
if (hover)
{
//if (brush.first.set())
{
button->shader(cell::shaders::xlight, e2::form::state::mouse);
}
//else
{

}
}
button->template plugin<pro::notes>(notes)
->setpad({ 2,2,!slimsize,!slimsize })
->invoke([&](auto& boss) // Store shared ptr to the menu item config.
Expand Down
14 changes: 7 additions & 7 deletions src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,13 @@ namespace netxs::ui
if (parent_ptr) parent_ptr->base::reflow(); //todo too expensive. ? accumulate deferred reflow? or make it when stated?
};
//todo deprecated
LISTEN(tier::release, e2::render::any, parent_canvas)
{
if (base::filler.wdt() && !base::hidden)
{
parent_canvas.fill([&](cell& c) { c.fusefull(base::filler); });
}
};
//LISTEN(tier::release, e2::render::any, parent_canvas)
//{
// if (base::filler.wdt() && !base::hidden)
// {
// parent_canvas.fill([&](cell& c) { c.fusefull(base::filler); });
// }
//};
}
};
}
16 changes: 15 additions & 1 deletion src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,20 @@ namespace netxs
// rgba: Shift color.
void xlight()
{
if (luma() > 140)
//todo unify
if (chan.a == 0)
{
chan.a = 42;
chan.r = 0xFF;
chan.g = 0xFF;
chan.b = 0xFF;
}
else if (chan.a != 0xFF)
{
auto k = 42;
chan.a = chan.a > 0xFF - k ? 0xFF : chan.a + k;
}
else if (luma() > 140)
{
auto k = 64;
chan.r = chan.r < k ? 0x00 : chan.r - k;
Expand Down Expand Up @@ -1486,6 +1499,7 @@ namespace netxs
auto txt() const { return gc.get(); } // cell: Return Grapheme cluster.
auto& egc() { return gc; } // cell: Get Grapheme cluster token.
auto& egc() const { return gc; } // cell: Get Grapheme cluster token.
auto set() const { return uv.bg || uv.fg;} // cell: Return true if color set.
auto bga() const { return uv.bg.chan.a; } // cell: Return Background alpha/transparency.
auto fga() const { return uv.fg.chan.a; } // cell: Return Foreground alpha/transparency.
auto& bgc() { return uv.bg; } // cell: Return Background color.
Expand Down
3 changes: 0 additions & 3 deletions src/netxs/desktopio/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ namespace netxs::ui
span tooltip_timeout; // conf: Timeout for tooltip.
cell tooltip_colors; // conf: Tooltip rendering colors.
bool tooltip_enabled; // conf: Enable tooltips.
bool glow_fx; // conf: Enable glow effect in main menu.
bool debug_overlay; // conf: Enable to show debug overlay.
text debug_toggle; // conf: Debug toggle shortcut.
bool show_regions; // conf: Highlight region ownership.
Expand Down Expand Up @@ -443,13 +442,11 @@ namespace netxs::ui
background_image.size(block.limits());
background_image.output(block);
}
glow_fx = config.take("glowfx", true);
simple = faux;
}
else
{
simple = !(legacy_mode & ui::console::direct);
glow_fx = faux;
title = "";
}
vtmode = legacy_mode & ui::console::nt16 ? svga::nt16
Expand Down
Loading

0 comments on commit 41b54f5

Please sign in to comment.