From c1fd841ba3c201ccbc568f1bda5e51722eee4080 Mon Sep 17 00:00:00 2001 From: Dmitry Sapozhnikov <11535558+o-sdn-o@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:15:25 +0500 Subject: [PATCH] #400 WIP: Shaders (window menu) --- src/netxs/apps/term.hpp | 3 -- src/netxs/apps/tile.hpp | 42 +++++++++---------------- src/netxs/desktopio/application.hpp | 48 +++++++++-------------------- src/netxs/desktopio/canvas.hpp | 5 +-- src/netxs/desktopio/controls.hpp | 4 +++ 5 files changed, 35 insertions(+), 67 deletions(-) diff --git a/src/netxs/apps/term.hpp b/src/netxs/apps/term.hpp index 8916f75200..f9a0d3df58 100644 --- a/src/netxs/apps/term.hpp +++ b/src/netxs/apps/term.hpp @@ -177,8 +177,6 @@ namespace netxs::app::term { auto highlight_color = skin::color(tone::highlight); auto c3 = highlight_color; - auto x3 = cell{ c3 }.alpha(0x00); - auto p3 = std::pair{ x3, c3 }; config.cd("/config/term/", "/config/defapp/"); auto menudata = config.list("menu/item"); @@ -600,7 +598,6 @@ namespace netxs::app::term .notes = label->take(menu::attr::notes, defs.notes), .param = label->take(menu::attr::param, defs.param), .onkey = label->take(menu::attr::onkey, defs.onkey), - .brush = p3, }); } if (item.views.empty()) continue; // Menu item without label. diff --git a/src/netxs/apps/tile.hpp b/src/netxs/apps/tile.hpp index e7fc7598d8..491a5268bb 100644 --- a/src/netxs/apps/tile.hpp +++ b/src/netxs/apps/tile.hpp @@ -383,17 +383,13 @@ namespace netxs::app::tile auto highlight_color = skin::color(tone::highlight); auto danger_color = skin::color(tone::danger); auto c3 = highlight_color; - auto x3 = cell{ c3 }.alpha(0x00); auto c1 = danger_color; - auto x1 = cell{ c1 }.alpha(0x00); - auto p1 = std::pair{ x1, c1 }; - auto p3 = std::pair{ x3, c3 }; using namespace app::shared; auto [menu_block, cover, menu_data] = menu::mini(true, true, faux, 1, menu::list { - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "+", .notes = " New app ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "+", .notes = " New app " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -402,7 +398,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "│", .notes = " Split horizontally ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "│", .notes = " Split horizontally " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -411,7 +407,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "──", .notes = " Split vertically ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "──", .notes = " Split vertically " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -420,7 +416,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "×", .notes = " Delete pane ", .brush = p1 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "×", .notes = " Delete pane ", .hover = c1 }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -809,20 +805,10 @@ namespace netxs::app::tile auto cB = menu_white; auto highlight_color = skin::color(tone::highlight); auto danger_color = skin::color(tone::danger); - auto action_color = skin::color(tone::action); auto warning_color = skin::color(tone::warning); - auto c6 = action_color; - auto x6 = cell{ c6 }.alpha(0x00); auto c3 = highlight_color; - auto x3 = cell{ c3 }.alpha(0x00); auto c2 = warning_color; - auto x2 = cell{ c2 }.bga(0x00); auto c1 = danger_color; - auto x1 = cell{ c1 }.alpha(0x00); - auto p1 = std::pair{ x1, c1 }; - auto p2 = std::pair{ x2, c2 }; - auto p3 = std::pair{ x3, c3 }; - auto p6 = std::pair{ x6, c6 }; auto object = ui::fork::ctor(axis::Y) ->plugin() @@ -855,7 +841,7 @@ namespace netxs::app::tile // ┌────┐ ┌────┐ ┌─┬──┐ ┌────┐ ┌─┬──┐ ┌─┬──┐ ┌────┐ // ┌─┐ ┌─┬─┐ ┌─┬─┐ ┌─┬─┐ // │Exec│ ├─┐ │ │ H │ ├ V ─┤ │Swap│ │Fair│ │Shut│ // ├─┤ └─┴─┘ └<┴>┘ └>┴<┘ // └────┘ └─┴──┘ └─┴──┘ └────┘ └─┴──┘ └─┴──┘ └────┘ // └─┘ - //{ menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " ┐└ ", .notes = " Maximize/restore active pane ", .brush = p3 }}}, + //{ menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " ┐└ ", .notes = " Maximize/restore active pane " }}}, //[](auto& boss, auto& item) //{ // boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -865,7 +851,7 @@ namespace netxs::app::tile // gear.dismiss(true); // }; //}}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " + ", .notes = " Create and run a new app in active panes ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " + ", .notes = " Create and run a new app in active panes " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -874,7 +860,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = ":::", .notes = " Select all panes ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = ":::", .notes = " Select all panes " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -883,7 +869,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " │ ", .notes = " Split active panes horizontally ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " │ ", .notes = " Split active panes horizontally " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -892,7 +878,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "──", .notes = " Split active panes vertically ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "──", .notes = " Split active panes vertically " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -901,7 +887,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " ┌┘ ", .notes = " Change split orientation ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " ┌┘ ", .notes = " Change split orientation " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -910,7 +896,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "<->", .notes = " Swap two or more panes ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "<->", .notes = " Swap two or more panes " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -919,7 +905,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = ">|<", .notes = " Equalize split ratio ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = ">|<", .notes = " Equalize split ratio " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -928,7 +914,7 @@ namespace netxs::app::tile gear.dismiss(true); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "\"…\"", .notes = " Set tiling manager window title using clipboard data ", .brush = p3 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "\"…\"", .notes = " Set tiling manager window title using clipboard data " }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -936,7 +922,7 @@ namespace netxs::app::tile app::shared::set_title(boss, gear); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " × ", .notes = " Close active app or remove pane if there is no running app ", .brush = p1 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = " × ", .notes = " Close active app or remove pane if there is no running app ", .hover = c1 }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) diff --git a/src/netxs/desktopio/application.hpp b/src/netxs/desktopio/application.hpp index 8970f3d90e..c14007b061 100644 --- a/src/netxs/desktopio/application.hpp +++ b/src/netxs/desktopio/application.hpp @@ -161,13 +161,11 @@ namespace netxs::app::shared struct look { - using pair = std::pair; // Accented/idle. text label{}; text notes{}; text param{}; text onkey{}; si32 value{}; - pair brush{}; cell hover{}; cell focus{}; }; @@ -209,18 +207,10 @@ namespace netxs::app::shared auto action_color = skin::color(tone::action); auto warning_color = skin::color(tone::warning); auto c6 = action_color; - auto x6 = cell{ c6 }.alpha(0x00); auto c3 = highlight_color; auto x3 = cell{ c3 }.alpha(0x00); auto c2 = warning_color; - auto x2 = cell{ c2 }.bga(0x00); auto c1 = danger_color; - auto x1 = cell{ c1 }.alpha(0x00); - auto p1 = std::pair{ x1, c1 }; - auto p2 = std::pair{ x2, c2 }; - auto p3 = std::pair{ x3, c3 }; - auto p6 = std::pair{ x6, c6 }; - auto turntime = skin::globals().fader_time; auto macstyle = skin::globals().macstyle; auto menuveer = ui::veer::ctor(); @@ -232,24 +222,16 @@ namespace netxs::app::shared { auto& props = std::get<0>(config); auto& setup = std::get<1>(config); - auto& hover = props.alive; + auto& alive = props.alive; auto& label = props.views.front().label; auto& notes = props.views.front().notes; - auto& brush = props.views.front().brush; + auto& hover = props.views.front().hover; auto button = ui::item::ctor(label)->drawdots(); - //if (hover) button->template plugin(brush.first, brush.second, turntime); //todo template: GCC complains - //else button->colors(0,0); //todo for mouse tracking - button->active(); - if (hover) + button->active(); // Always active for tooltips. + if (alive) { - //if (brush.first.set()) - { - button->shader(cell::shaders::xlight, e2::form::state::mouse); - } - //else - { - - } + if (hover.set()) button->shader(cell::shaders::color(hover), e2::form::state::hover); + else button->shader(cell::shaders::xlight, e2::form::state::hover); } button->template plugin(notes) ->setpad({ 2,2,!slimsize,!slimsize }) @@ -280,7 +262,7 @@ namespace netxs::app::shared { auto control = std::vector { - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "—", .notes = " Minimize ", .brush = p2 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "—", .notes = " Minimize ", .hover = c2 }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -289,7 +271,7 @@ namespace netxs::app::shared gear.dismiss(); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "□", .notes = " Maximize ", .brush = p6 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "□", .notes = " Maximize ", .hover = c6 }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -298,7 +280,7 @@ namespace netxs::app::shared gear.dismiss(); }; }}, - { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "×", .notes = " Close ", .brush = p1 }}}, + { menu::item{ menu::item::type::Command, true, 0, std::vector{{ .label = "×", .notes = " Close ", .hover = c1 }}}, [](auto& boss, auto& item) { boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear) @@ -406,15 +388,13 @@ namespace netxs::app::shared { auto highlight_color = skin::color(tone::highlight); auto c3 = highlight_color; - auto x3 = cell{ c3 }.alpha(0x00); - auto p3 = std::pair{ x3, c3 }; auto items = list { - { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("F").nil().add("ile"), .notes = " File menu item ", .brush = p3 }}}, [&](auto& boss, auto& item){ }}, - { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("E").nil().add("dit"), .notes = " Edit menu item ", .brush = p3 }}}, [&](auto& boss, auto& item){ }}, - { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("V").nil().add("iew"), .notes = " View menu item ", .brush = p3 }}}, [&](auto& boss, auto& item){ }}, - { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("D").nil().add("ata"), .notes = " Data menu item ", .brush = p3 }}}, [&](auto& boss, auto& item){ }}, - { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("H").nil().add("elp"), .notes = " Help menu item ", .brush = p3 }}}, [&](auto& boss, auto& item){ }}, + { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("F").nil().add("ile"), .notes = " File menu item " }}}, [&](auto& boss, auto& item){ }}, + { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("E").nil().add("dit"), .notes = " Edit menu item " }}}, [&](auto& boss, auto& item){ }}, + { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("V").nil().add("iew"), .notes = " View menu item " }}}, [&](auto& boss, auto& item){ }}, + { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("D").nil().add("ata"), .notes = " Data menu item " }}}, [&](auto& boss, auto& item){ }}, + { item{ item::type::Command, true, 0, std::vector{{ .label = ansi::und(true).add("H").nil().add("elp"), .notes = " Help menu item " }}}, [&](auto& boss, auto& item){ }}, }; config.cd("/config/defapp/"); auto [menu, cover, menu_data] = create(config, items); diff --git a/src/netxs/desktopio/canvas.hpp b/src/netxs/desktopio/canvas.hpp index fa530e37e5..945dd52128 100644 --- a/src/netxs/desktopio/canvas.hpp +++ b/src/netxs/desktopio/canvas.hpp @@ -1702,8 +1702,9 @@ namespace netxs : colors{ colors }, factor{ factor } { } - constexpr color_t(cell const& brush) - : colors{ brush.uv } + constexpr color_t(cell const& brush, si32 factor = 1) + : colors{ brush.uv }, + factor{ factor } { } template inline auto operator [] (T param) const diff --git a/src/netxs/desktopio/controls.hpp b/src/netxs/desktopio/controls.hpp index 65aa6d9252..464d195543 100644 --- a/src/netxs/desktopio/controls.hpp +++ b/src/netxs/desktopio/controls.hpp @@ -1832,6 +1832,10 @@ namespace netxs::ui { state = rent; }; + boss.LISTEN(tier::request, e2::form::state::hover, state, memo) + { + state = rent; + }; boss.LISTEN(tier::release, e2::form::draggable::any, enabled, memo) { switch (auto deed = boss.bell::protos())