Skip to content

Commit

Permalink
directvt#430 Allow to change the tile manager window title by the '…'…
Browse files Browse the repository at this point in the history
… button (swap with clipboard)
  • Loading branch information
o-sdn-o committed Oct 8, 2023
1 parent 4a8c24e commit 7d5cd35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
18 changes: 1 addition & 17 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,7 @@ namespace netxs::app::shared
boss.RISEUP(tier::preview, e2::form::prop::zorder, zpos::backmost);
parent.LISTEN(tier::release, hids::events::mouse::button::click::right, gear)
{
boss.RISEUP(tier::request, e2::form::prop::ui::header, old_title, ());
gear.owner.RISEUP(tier::request, hids::events::clipbrd, gear);
auto& data = gear.board::cargo;

if (utf::is_plain(data.utf8)) // Reset aligning to the center if text is plain.
{
auto align = ansi::jet(bias::center);
boss.RISEUP(tier::preview, e2::form::prop::ui::header, align);
}
// Copy clipboard data to title.
boss.RISEUP(tier::preview, e2::form::prop::ui::header, title, (data.utf8));
gear.dismiss();

if (old_title.size()) // Copy old title to clipboard.
{
gear.set_clipboard(dot_00, old_title, mime::ansitext);
}
app::shared::set_title(boss, gear, bias::center);
};
};
});
Expand Down
8 changes: 8 additions & 0 deletions src/netxs/apps/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,14 @@ 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 }}},
[](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 }}},
[](auto& boss, auto& item)
{
Expand Down
18 changes: 18 additions & 0 deletions src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ namespace netxs::app::shared
auto vt = scroll_bars->attach(slot::_2, ui::grip<axis::Y>::ctor(master));
return scroll_bars;
};
const auto set_title = [](base& boss, input::hids& gear, bias alignment = bias::left)
{
boss.RISEUP(tier::request, e2::form::prop::ui::header, old_title, ());
gear.owner.RISEUP(tier::request, hids::events::clipbrd, gear);
auto& data = gear.board::cargo;
if (utf::is_plain(data.utf8) || alignment != bias::left) // Reset aligning to the center if text is plain.
{
auto align = ansi::jet(alignment);
boss.RISEUP(tier::preview, e2::form::prop::ui::header, align);
}
// Copy clipboard data to title.
boss.RISEUP(tier::preview, e2::form::prop::ui::header, title, (data.utf8));
gear.dismiss(true);
if (old_title.size()) // Copy old title to clipboard.
{
gear.set_clipboard(dot_00, old_title, mime::ansitext);
}
};

using builder_t = std::function<ui::sptr(text, text, xmls&, text)>;

Expand Down

0 comments on commit 7d5cd35

Please sign in to comment.