Skip to content

Commit

Permalink
directvt#400 WIP: Shaders (window menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Oct 24, 2023
1 parent 73246c8 commit c1fd841
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 67 deletions.
3 changes: 0 additions & 3 deletions src/netxs/apps/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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.
Expand Down
42 changes: 14 additions & 28 deletions src/netxs/apps/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<menu::item::look>{{ .label = "+", .notes = " New app ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "+", .notes = " New app " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -402,7 +398,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Split horizontally ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Split horizontally " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -411,7 +407,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "──", .notes = " Split vertically ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "──", .notes = " Split vertically " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -420,7 +416,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "×", .notes = " Delete pane ", .brush = p1 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "×", .notes = " Delete pane ", .hover = c1 }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand Down Expand Up @@ -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<items>()
Expand Down Expand Up @@ -855,7 +841,7 @@ namespace netxs::app::tile
// ┌────┐ ┌────┐ ┌─┬──┐ ┌────┐ ┌─┬──┐ ┌─┬──┐ ┌────┐ // ┌─┐ ┌─┬─┐ ┌─┬─┐ ┌─┬─┐
// │Exec│ ├─┐ │ │ H │ ├ V ─┤ │Swap│ │Fair│ │Shut│ // ├─┤ └─┴─┘ └<┴>┘ └>┴<┘
// └────┘ └─┴──┘ └─┴──┘ └────┘ └─┴──┘ └─┴──┘ └────┘ // └─┘
//{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = " ┐└ ", .notes = " Maximize/restore active pane ", .brush = p3 }}},
//{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = " ┐└ ", .notes = " Maximize/restore active pane " }}},
//[](auto& boss, auto& item)
//{
// boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -865,7 +851,7 @@ namespace netxs::app::tile
// gear.dismiss(true);
// };
//}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = " + ", .notes = " Create and run a new app in active panes ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .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)
Expand All @@ -874,7 +860,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = ":::", .notes = " Select all panes ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = ":::", .notes = " Select all panes " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -883,7 +869,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Split active panes horizontally ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Split active panes horizontally " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -892,7 +878,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "──", .notes = " Split active panes vertically ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "──", .notes = " Split active panes vertically " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -901,7 +887,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = " ┌┘ ", .notes = " Change split orientation ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = " ┌┘ ", .notes = " Change split orientation " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -910,7 +896,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "<->", .notes = " Swap two or more panes ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "<->", .notes = " Swap two or more panes " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -919,7 +905,7 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = ">|<", .notes = " Equalize split ratio ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = ">|<", .notes = " Equalize split ratio " }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -928,15 +914,15 @@ namespace netxs::app::tile
gear.dismiss(true);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "\"\"", .notes = " Set tiling manager window title using clipboard data ", .brush = p3 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .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)
{
app::shared::set_title(boss, gear);
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .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<menu::item::look>{{ .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)
Expand Down
48 changes: 14 additions & 34 deletions src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ namespace netxs::app::shared

struct look
{
using pair = std::pair<cell, cell>; // Accented/idle.
text label{};
text notes{};
text param{};
text onkey{};
si32 value{};
pair brush{};
cell hover{};
cell focus{};
};
Expand Down Expand Up @@ -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();
Expand All @@ -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<pro::fader>(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<pro::notes>(notes)
->setpad({ 2,2,!slimsize,!slimsize })
Expand Down Expand Up @@ -280,7 +262,7 @@ namespace netxs::app::shared
{
auto control = std::vector<link>
{
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Minimize ", .brush = p2 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Minimize ", .hover = c2 }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -289,7 +271,7 @@ namespace netxs::app::shared
gear.dismiss();
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Maximize ", .brush = p6 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "", .notes = " Maximize ", .hover = c6 }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand All @@ -298,7 +280,7 @@ namespace netxs::app::shared
gear.dismiss();
};
}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "×", .notes = " Close ", .brush = p1 }}},
{ menu::item{ menu::item::type::Command, true, 0, std::vector<menu::item::look>{{ .label = "×", .notes = " Close ", .hover = c1 }}},
[](auto& boss, auto& item)
{
boss.LISTEN(tier::release, hids::events::mouse::button::click::left, gear)
Expand Down Expand Up @@ -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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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<item::look>{{ .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);
Expand Down
5 changes: 3 additions & 2 deletions src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<class T>
inline auto operator [] (T param) const
Expand Down
4 changes: 4 additions & 0 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<tier::release>())
Expand Down

0 comments on commit c1fd841

Please sign in to comment.