Repository navigation
fix: fixing color wheel history pollution due to mouse drag - #2750
mohamedAdhamc wants to merge 27 commits into
Conversation
as suggested I solved color history issue using the same method. I will be then cherry picking this commit into anew branch with a new proposal then after its merged i can rebase this branch.
history-broken.mp4Now history is completely broken. |
| Gdk::RGBA newColor = hvsColorWidget->get_current_rgba(); | ||
| Color synfigColor( | ||
| Color synfigColor; | ||
| if(was_released){// if there was a release means drag is over and record this final color in history panel |
There was a problem hiding this comment.
Why don't you use the is_adjusting() method?
https://developer-old.gnome.org/gtkmm/3.24/classGtk_1_1ColorSelection.html#a46fdb5b6bee26afa711147b2be2b5bd8
There was a problem hiding this comment.
I think there was a reason there were some cases is_adjusting() wasn't handling them correctly (with regards to this feature) but I can't really remember. If this part is kept after addressing the other issues of this PR I will then look into it.
Oh, maybe I forgot something in the commit. It was working fine on my machine. I will look into it. |
|
@ice0 My.Project.mp4p.s. its a little glitichy because of the screen recorder. the windows screen recorder didnt record the new color dialog window. but yes there is something wrong with the undo I just checked. |
|
hey, @rodolforg do you think grouping these actions into one group is a good way of fixing this history pollution issue? I think this way makes the undo easier as it would just work normally im assuming. However, not really sure though how easy it would be to group them this is what I'm figuring out now :). update: I made the group and stored the actions in it but still undo isn't working as should be. Im thinking I probably initialized the handle for the action group in a wrong way but I honestly have no clue at this point xD. I will keep at it and will be commiting by the end of the day to get advice from you guys. I also noticed jump seems to be working correctly for the gorup. I mean jumping to previous action or action group does what undo should be doing which it is not. however jump in general also seems to be messed up. update: ok so while I still am not sure why the undo isn't working properly, I realized that the undo works as if there was the total number of actions done (with the group not being counted as one action). so for example if we have which leads me to the conclusion that the grouping just like the thing I did before (instead of grouping hiding the in between actions from rendering into rows) is not getting to the heart of the issue here. Although I had thought grouping would fix this by "grouping" these multiple actions into one single action. update: or maybe just I have to use synfigapp::Action::PassiveGrouper instead of synfigapp::Action::Group (* _ *) I will look into this |
I don't like the grouping solution because it doesn't solve the problem, it just hides it. |
yes, this is actually very understandable. I will be looking for a better solution tomorrow... I'm about to go to sleep in a bit. In the meanwhile, it would be great if you guys could give me suggestions on what I should be trying to do/ where i should be looking? update: ironically in the comments the same idea of a passive group was mentioned xD. However @rodolforg seems to have solved something similar in #982 however its a huge commit (^_^) so I willl probably start tommorow by seeing what he did there for inspiration. update again: I went through it quickly seems like it was also done using passive grouping. I think maybe if I am to group the actions into a pasive group then just not render all the child actions --(the rendering part shouldn't be difficult, it would just most likely be messing around with the history tree views update: currently im looking into synfig::App:PassiveGroup it does seem to be quite diffrent from the regular Group which can be update: seems I finally got to the root of the issue now, will be testing, then reviewing/optimizing and committing. quick summary: If anyone is reading this and wants a quick summary just read the last couple updates old ones are regularly being invalidated by newer ones. |
|
update: |
|
ok so a description of what happened. color history polution should now be fixed for the color wheel. As in dragging the wheel makes no pollution. However there are two cases I havent handled the pollution for I don't think one is necessary to me it felt really unnatural using the keys to adjust the color wheel. If it has to be handled though please let me know. Two I think wouldn't be related to this PR as these spin buttons arent part of the color wheel. So maybe I can fix them in another PR later if they should be fixed. But I'd rather continue with the issues I have for my project so as to not get carried away too much now during the project. p.s. i removed some unecessary thing and waiting or it to rebuild to make sure I didnt accidently mess up anything so I wil be comiiting in a couple minutes after it builds. update: there are 100 files to rebuild so thiis might take a bit :( |
|
Pressing color-wheel-esc.mp4Pressing color-wheel-esc2.mp4 |
Yes actually I didn't handle ESC for cancelling change will do it in a bit (just woke up) shouldn't take long. |
Is any progress here? |
Not really I was mainly caught up with the other features and reviews. I think to actually get to a fix that would be general enough for everything i'd have to really understand in detail the action system in place. I should get to it soon though (starting tomorrow if things go well with the things I'm supposed to address from reviews). |
I suggest to concentrate here, because without completing this PR we cannot continue with #2717 |
@ice0 , @rodolforg I tried doing what rodolf suggested which is for these actions to have the new one replace the old one in the undo_action_stack so theoretically we should end up with the very last action in the undo stack and then whichever is before it so for example: making a new circle layer (let say default color is black) here when I undo it only takes me back to the previous action but with the wrong color (slightly lighter blue) not black, it seems like the new circle actions "color parameter" is somehow changed so I actually wonder why that happens shouldn't each change only affect the action it is in ? the only time that seems to not happen is when the very first action in the color wheel is pushed onto the undo stack and not removed (to which I thought maybe then using the same logic not creating any more actions will alter this actions color parameter but unfortuantely it doesnt xd when I undo and redo the color changes). So right now I think maybe I could make a passive group with the very first and last action/actions (num_layers * 2) any ideas? update: seems like using a modified passive grouper so that it includes the very first and last action is the best way to go at it, it would be the safest and would solve the history pollution without having to change any key thing in the current action system. whether use the current PassiveGrouper as is with some modifications or creating a new similar grouper though I would still have to see how the rest of the implemetnation goes. |
|
ok so I went with rodolf's second suggestion which is using a passive group but modified ( because a passive group directly would just be hiding all the many actions not more). Now the passive group only includes the very first and last actions which are necessary for the undo process to work, and importantly it works for any selected number of layers. |
-the new approach
|
ok its not yet fully complete I will finish it first thing in the morning tommorow. |
|
Now the three points I mentioned should be done (there may be more cleaning needed though I will have to review the changes). Quick brief of what is reached so far:
p.s. note to self use sigc::track_obj in the lambdas |
| */ | ||
|
|
||
| public: | ||
| static bool repeated_action; |
There was a problem hiding this comment.
It's better to move this to private non-static variables.
Each file has its own ActionSystem. If we try to work with them in parallel (from different threads for example), in the case of static members, this will lead to undefined behavior.
There was a problem hiding this comment.
yes, I was initially thinking that because it probably isn't possible to have more than one of these "repeated actions" at the same time then a static variable would be enough to be used by each "repeated action". But yes I can see how this could get messy and possibly lead to some undefined behavior.
switched over to public non-static variables. As they need to be set and gotten from outside, however if its better to just keep them private and write setters and getters please let me know :)
|
@ice0 done |
|
Just tested. The first circle is a normal circle, the second circle has an exported color value. history-exported-issue.mp4 |
|
@ice0, I tried replicating but its not doing that. trying-to-replicate.mp4(here i set the color from the color wheel twice and it works fine, for some reason the windows screen recorder doesnt capture windows on top of windows xD but the point is shown i hope) However, I noticed something similar earlier but I don't think it's related to exported values. Sometimes an extra action is shown in addition to the change color action group, as shown in the video you sent there was the regular group but one it happens only fairly rarely though soI will keep on testing, and debugging to see why this happens sometimes. |
i was having the ation group deeted before the action being performed for the very last time which was a reason that once every couple times an axtra action was shn when the last action differs significantly which usually isnt the case
|
ok @ice0 I believe it should be fixed now :). p.s. connection is a bit low it might take a bit to upload |
|
I think there's room for improvement here, but it looks like the current implementation is leading to a dead end. What would like to be improved:
In order to make sure that this is possible, I have already made my own implementation. This is how the changes in This is how the history looks like: history-example.mp4I think maybe to leave this PR as it is, and try to implement the same thing from the scratch? |
Fair enough, this implementation relies on passive-groupers abilities to do certain things like handling undo history, etc.. so this is in fact very close to its dead end. Will start thinking of a new way that could be better. I.e. have the repeated actions replace each other smoothly without segmentation errors :). which would be a bit more complex especially with multiple layers being processed at the same time, as some type of sorting might be needed. But if theres already a simpler core idea please let me know :) |
|
ok I think i reached something here, and now i'll begin implementing and make a new PR. So the thing here is that we cant just push the first action into the undo stack as that will only make and undo possible and not redo, same for pushing last action only. so we need to push into the undo stack a group of the first and last action, and then that should make undo/redo work fine and regarding the history tree store we just show the action (first or last) normally without being in an expandable passive group as in the previous implementation. |
|
@ice0, here is what I reached So in order to fix history pollution and at the same time not compromise undo/redo there has to be some sort of group to be stored in the undo action list which contains the very first and very last action. Now we could make a whole new grouper, and call it something like "repeated grouper", or just expand the existing functionality of the passive grouper. Since there are not much core differences between this "repeated grouper" and the "passive grouper" I chose to Now up until now this is very similar to the last implementation, but with this new commit I have hopefully addressed the issues you mentioned 1- "Making it easier to work with preview from the point of view of the author of the new code ": Now to be able to use this all one has to do is 2 steps:
And also this implementation makes it very easy to add "escape/key to cancel" feature. Just make the escape/key pressed signal call App::get_selected_instance()->cancel_repeated_action() and destruct the group. ( This could all also be further enhanced by using only a variable and then when this variable is set to true while it was false we create the passive group under the hood and when its false we destruct it also and escape to cancel is kept the same way by just doing what is mentioned above. But I think this could make things messier, and also the concept of using something like a passive grouper shouldn't be too foreign for someone working on Synfig code so he just uses it as if he is making a regular passive group but just supplies its constructor one extra argument so that under the hood history pollution is taken care of ) 2- to not use a passive grouper: Here is a video of how it is working now: (at the end I was showing escape to cancel functionality. Also the software I use for recordidng make everything very laggy xd) I hope to have fully addresed the things mentioned :) if there is something that I have missed though please let me know. p.s. I originally was going to make a new pr as suggested but then due to things stated I found it makes sense to continue here. Anyways we can always revert this last commit and head over to a new PR if its needed :) |


Fixes #451
Using a flag to know when there are rapid repeated actions (as in here and in #2717 ) then if it's a rapid repeated action only showing in the history panel the very last value.
-For setting the color wheel using the mouse it works perfectly. also when setting with one key.
-However, if setting with multiple keys at the same time there appears a number of actions depending on the number of keys released. I tried implementing a counter variable which increments on signal key press and decrements on key release but it was behaving weirdly and also I dont thinks its much of an issue here if otherwise though please let me know.