Open qindapao opened 12 months ago
@nkh
https://github.com/qindapao/P5-App-Asciio/tree/mouse_polygon_selec
I made a polygonal mouse selection and I gave it the shortcut Shift + right mouse button
. The basic idea is that an element is selected when all its points are within the polygonal selection box.
@qindapao ohhhhh! very nice.
not 100% sure about the binding but we can have that till we find something better.
@nkh
I originally wanted to use shift + left mouse button
. But I see that you have reserved it to the expand selection
, although it has not been implemented yet.
@qindapao yes it isn't implemented because I never found time to write it.
Normally, in GUI apps, shift-click and shift+drag are for expanding selections.
I have implemented the normal selection box and you have implemented a fancy drag polygon; none of them supports selection expansion.
When, and if, we implement selection expansion, we can look at the bindings again, so for now Mouse polygon selection can use 00S- button-press-1.
One thing that I would like you to do is that when you add a functionality that's bound to a key, you also add it in the vim bindings files, even if it doesn't work in vim. open both default_bindings and vim_bindings in your text editor and you'll see that I have refactored them to be synchronized.
Would you like 'Mouse polygon selection' to be merged ?
@nkh Yes, I want it to be merged.
I need to change the shortcut keys and add the same content in vim_binding, right?
@qindapao right, and rebase on the latest
@qindapao here's an implementation for the eraser
'<< eraser leader >>' =>
{
SHORTCUTS => '00S-E',
ESCAPE_KEY => '000-Escape',
'Eraser motion' => [ '000-motion_notify',
sub
{
my ($self, $event) = @_ ;
my ($x, $y) = @{$event->{COORDINATES}}[0, 1] ;
if($self->{PREVIOUS_X} != $x || $self->{PREVIOUS_Y} != $y)
{
my @elements = grep { $self->is_over_element($_, $x, $y) } reverse @{$self->{ELEMENTS}} ;
if(@elements)
{
$self->create_undo_snapshot() ;
$self->delete_elements(@elements) ;
$self->update_display();
}
}
App::Asciio::Actions::Mouse::mouse_motion($self, $event) ;
}
],
},
@nkh OK, let me take a look. After reading this, I am ready to go to bed.
@qindapao I tested it again but it didn't merge the polygon select for the following reasons
@nkh
At present, it is true that it can only be included clockwise or counterclockwise, and there is no visual feedback. Let's continue to optimize.
If we want to support complex polygons, the algorithm may be more complicated.
@nkh currently it only recognizes closed polygons
@nkh The eraser works great. We now need a visual feedback. It would be nice if the mouse pointer could be displayed as a circle or something.Let the user know that this is the eraser, not the normal state.
@qindapao I'll create a new branch for it and will try to have some feedback too.
@nkh
Okay, this eraser gave me another idea. Line selection, corresponding to small elements with a single character, may be more useful than polygon selection.Move the mouse over all captured elements to select them, similar to an eraser. Eraser is for erasing, this is for selection. Two manifestations of one function.
@nkh Polygon and rectangular selections require that all points must be contained within the shape. Line selection selects elements as long as the line touches them.
@qindapao added eraser in 0ff9f34
Here's another way to select and deselect while moving the mouse; code below the screencast.
note I'm using package App::Asciio::Actions just because I was too lazy to create a new package for just a test.
000-r puts you in selection mode, 000-r also escapes the selection mode 000-f flips the mode from select to deselect
I didn't bother changing the cursor but it would be te same as for the eraser
'<< selection leader >>' =>
{
SHORTCUTS => '000-r',
ESCAPE_KEY => '000-r',
'flip deselect' => [ '000-f', sub { $App::Asciio::Actions::Eraser::select_type ^= 1 } ],
'select motion' => [ '000-motion_notify',
sub
{
my ($self, $event) = @_ ;
my ($x, $y) = @{$event->{COORDINATES}}[0, 1] ;
if($self->{PREVIOUS_X} != $x || $self->{PREVIOUS_Y} != $y)
{
my @elements = grep { $self->is_over_element($_, $x, $y) } reverse @{$self->{ELEMENTS}} ;
if(@elements)
{
$self->create_undo_snapshot() ;
$self->select_elements($App::Asciio::Actions::Eraser::select_type, @elements) ;
$self->update_display();
}
}
App::Asciio::Actions::Mouse::mouse_motion($self, $event) ;
}
],
},
@nkh
https://github.com/qindapao/P5-App-Asciio/tree/element_trans
I integrated this function, but found that there would be a problem if SHORTCUTS and ESCAPE_KEY use the same key, making it impossible to enter and exit after entering.So I modified the shortcut keys. See if there is any problem here. Or you may have a more convenient method of operation over there. I also added the mouse pointer for selection mode. Maybe we can ask your daughter what kind of pointers are clear to users and let them know what they are doing through style.
In addition, I have also finished writing the code for element conversion in ascii art drawing mode, please review it.
We can now use small boxes to create ascii art, and then save it as a large box after completing the work.
@qindapao
We can also have a "pen" mode where elements of one character are added, etc ...
As you see we are can fix code pretty easily but it what it's going to be used for and how that we need to think about and particularly what bindings to use. It also may be necessary to have some tool box or popup menu entries.
I propose we hold with the integration till the UX part is clearer.
now two questions
why would we use the same key to enter and escape a mode when we can use any key to enter (apart from escape), and escape to escape?
the stock cursors are very ugly and boring, shall we have a look at custom cursors?
@nkh
(1). That's not what I meant. The code you gave me yesterday was to use the same key to enter and the same key to exit. I'm just asking if that was your original intention?
(2). I'm looking for the open circle, but can't find it. Well, we can think about it.
@nkh
This is the code you gave me, I thought this is what you planned.
@nkh I thought about pen
mode, but I can only draw one type of character at a time, so how to change the characters becomes another problem.Our clone mode is similar to pen mode, except that we have to click the left mouse button each time. Changing characters requires copying a new character element.
@nkh once we enter the "pen" mode we can change the character with any key binding we want.
the clone mode already works like that, if you have a selection it clones the selection, otherwise it offers to clone a box but you can, while in clone mode, press on a-A-b-t to change what you're cloning, the same can be done in "pen" mode.
'<< clone leader >>' =>
{
SHORTCUTS => '000-c',
ENTER_GROUP => \&App::Asciio::Actions::Clone::clone_enter,
ESCAPE_KEY => '000-Escape',
'clone escape' => [ '000-Escape', \&App::Asciio::Actions::Clone::clone_escape ],
'clone motion' => [ '000-motion_notify', \&App::Asciio::Actions::Clone::clone_mouse_motion ],
'clone insert' => [ '000-button-press-1', \&App::Asciio::Actions::Clone::clone_add_element ],
'clone insert2' => [ '000-Return', \&App::Asciio::Actions::Clone::clone_add_element ],
'clone arrow' => [ '000-a', \&App::Asciio::Actions::Clone::clone_set_overlay, ['Asciio/wirl_arrow', 0] ],
'clone angled arrow' => [ '00S-A', \&App::Asciio::Actions::Clone::clone_set_overlay, ['Asciio/angled_arrow', 0] ],
'clone box' => [ '000-b', \&App::Asciio::Actions::Clone::clone_set_overlay, ['Asciio/box', 0] ],
'clone text' => [ '000-t', \&App::Asciio::Actions::Clone::clone_set_overlay, ['Asciio/text', 0] ],
'clone flip hint lines' => [ '000-h', \&App::Asciio::Actions::Unsorted::flip_hint_lines ],
'clone left' => ['000-Left', \&App::Asciio::Actions::ElementsManipulation::move_selection_left ],
'clone right' => ['000-Right', \&App::Asciio::Actions::ElementsManipulation::move_selection_right ],
'clone up' => ['000-Up', \&App::Asciio::Actions::ElementsManipulation::move_selection_up ],
'clone down' => ['000-Down', \&App::Asciio::Actions::ElementsManipulation::move_selection_down ],
'clone emulation left' => ['C00-Left', \&App::Asciio::Actions::Mouse::mouse_move, [-1, 0] ],
'clone emulation right' => ['C00-Right', \&App::Asciio::Actions::Mouse::mouse_move, [ 1, 0] ],
'clone emulation up' => ['C00-Up', \&App::Asciio::Actions::Mouse::mouse_move, [ 0, -1] ],
'clone emulation down' => ['C00-Down', \&App::Asciio::Actions::Mouse::mouse_move, [ 0, 1] ],
},
The code I showed yesterday, with 000-r to enter and escape the "selection" mode works, what kind of problem did you have with it?
@nkh I'm having a problem and can't get in. Or I can test it again.
@qindapao weird, it worked when I posted it but now it doesn't let me have a quick look
@nkh I tested it, but it still didn't work. I was bound to s
, but I couldn't exit.
@qindapao it was very late when I wrote the code :) I'm debugging it right now; I want it to be possible to get in and out of a group with the same key, for some mode it means not moving the fingers around and I think it's a good thing.
@nkh Yes, I hope so, too. It's very good that one key goes in and out together.
@nkh Pay attention to rest.My wife and children are coming back. I don't have time to write code.
٩(^ᴗ^)
@qindapao fixed in #171
@nkh
Thank you, these functions are really great.I really like it.
@nkh
https://github.com/qindapao/P5-App-Asciio/tree/mouse_polygon_selc
I added selection feedback for polygon selection. But I didn't add the expanded selection to add selection. Because this selection is for screening and precise selection, not for selecting more, the better. Only elements inside the polygon can be selected. You can see that as the polygon changes, the element switches between selected and unselected states.
@qindapao I'm OK to integrate the polygon selection code, we just need a good binding.
I've just changed the bindings, I noticed that 000-s was free so it can be used to enter the different selection modes.
'<< selection leader >>' =>
{
SHORTCUTS => '000-s',
ENTER_GROUP => \&App::Asciio::Actions::Selection::selection_enter,
ESCAPE_KEYS => [ '000-s', '000-Escape' ],
'Selection escape' => [ '000-s', \&App::Asciio::Actions::Selection::selection_escape ],
'Selection escape2' => [ '000-Escape', \&App::Asciio::Actions::Selection::selection_escape ],
'select flip mode' => [ '000-e', \&App::Asciio::Actions::Selection::selection_mode_flip ],
'select motion' => [ '000-motion_notify', \&App::Asciio::Actions::Selection::select_elements ],
},
It looks like this on my keyboard (drawn with Asciio)
You should chose a binding that's one othe the keys that are unused.
*000-e' goes into "deselect mode" (e for erase selection), it also goes from "deselect mode" to "select mode".
000-x' may be a good binding for the polygone selection, pressing 000-x* should bring it back in "select mode"
@nkh
Do you mean to put polygon selection into selection mode? Last time you said I could use shift+left mouse button.
@qindapao You can do that too in your own bindings, you have custom bindings right?
I wan to start freeing the bindings that use mouse-buttons, they are many and not very standard. By having the functionality in the specific groups we can put some orders in them, and we can still have custom bindings.
@nkh Okay, I'll change it, I understand.I encountered some problems after changing the shortcut keys. I will let you know after I fix them.
@nkh
https://github.com/qindapao/P5-App-Asciio/tree/mouse_polygon_selc
In selection mode, use the x
key to start polygon selection and exit selection.
@qindapao please stop putting bulk code in already existing module, create a new module and call functions there.
@nkh Ok, pay attention next time.I'll revise it tomorrow.
@nkh Should I put the code in Selection.pm? Or re-creating a module is called Polygonselection.pm?
@qindapao Selection.pm is OK, if the function start with poly_ then it would be clear what they belong to.
@nkh Can I put the code of the GTK drawing part in expose_event ?
They are all related to drawing.If it is placed in an independent module, the separation of the core and GTK will cause problems.
The code in the module should not contain GTK drawing part, am I right?
@qindapao it's OK if the module contains GTK drawing code.
Best is to put the drawing code in your module and call it from GTK::Asciio.
@nkh But if it is put in my module, if TUI has similar functions, then the installation will have to install GTK dependency.Aren't we planning to split up later?
By the way, it's morning here, and it should be very late at your place.
@qindapao the function that update the display in GTK::Asciio is specific to asciio, tasciio function that updtes the display is in Text::Asciio; if you function is called in GTK::Asciio then the module that contins it will not be part of the text asciio distribution.
But you have a point, the your_selection.pm should be in GTK/your_selection.pm
@qindapao for example, the drag and drop module I'm working on is "lib/App/Asciio/GTK/Asciio/DnD.pm" because I'm not planning to have drag an drop in tasciio (although now I think about it, it may be possible but using X11 directly rather than GTK provided functions)
@nkh I'd better write it in selection.pm After all, it is only a sub-pattern of the selection mode. It's weird to get a separate file.What do you think?
@nkh I put the drawn code in export_event and the rest in selection.pm
main target
... ...other functions may be needed