mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-28 14:16:29 +08:00
We can select in every directions
This commit is contained in:
parent
70b32fe523
commit
c1c6afc0ba
@ -72,9 +72,10 @@ int main() {
|
||||
});
|
||||
|
||||
// TODO: Make the textToCopy a callback called every times the selected text change
|
||||
// TODO: Is there a way for me to embedd the catchEvent in the selected decorator?
|
||||
// TODO: Implement the double click on word to select the word
|
||||
// TODO: Implement the double click and drag to select word by word (optional)
|
||||
// TODO: Is there a way for me to embedd the catchEvent in the selected decorator?
|
||||
// TODO: Add a "selectable" flag in the pixel class and take it into account when selecting things
|
||||
|
||||
renderer |= CatchEvent([&](Event event) {
|
||||
if (event.is_mouse()) {
|
||||
@ -85,7 +86,7 @@ int main() {
|
||||
{
|
||||
selection.startx = mouse.x;
|
||||
selection.starty = mouse.y;
|
||||
selection.endx = mouse.x-1;
|
||||
selection.endx = mouse.x;
|
||||
selection.endy = mouse.y;
|
||||
}
|
||||
else if (mouse.motion == Mouse::Released)
|
||||
@ -95,7 +96,7 @@ int main() {
|
||||
}
|
||||
else if (mouse.motion == Mouse::Moved)
|
||||
{
|
||||
selection.endx = mouse.x-1;
|
||||
selection.endx = mouse.x;
|
||||
selection.endy = mouse.y;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ class Selected : public NodeDecorator {
|
||||
void Render(Screen& screen) override {
|
||||
Node::Render(screen);
|
||||
destination_ = "";
|
||||
for (int y = selection_.starty; y <= selection_.endy; ++y) {
|
||||
for (int x = selection_.startx; x <= selection_.endx; ++x) {
|
||||
for (int y = std::min(selection_.starty, selection_.endy); y <= std::max(selection_.starty, selection_.endy); ++y) {
|
||||
for (int x = std::min(selection_.startx, selection_.endx); x <= std::max(selection_.startx, selection_.endx)-1; ++x) {
|
||||
screen.PixelAt(x, y).inverted ^= true;
|
||||
destination_ += screen.PixelAt(x, y).character;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user