Repository navigation
[UI Feature 1] Change Parameters with the Mouse - #2717
mohamedAdhamc wants to merge 36 commits into
Conversation
|
Hey @ice0 , @rodolforg so I'm going through with the suggested implementation, and now I'm working on incrementing/decrementing the values. I believe there might be two ways to do this: 1- through getting the value base stored in the tree model and then going all the way back to its original type and then incrementing it. I think this would require more work but the advantage would be that its independent of the "view" columns implementation ( i mean the spin button). However I think it also might cause problems with the spin button maybe not updating etc...
now the questions are I will be spending Thanks! update: so far I think maybe 1 is better ? i'm curently working on finding a way to increment the valuebase. update 2: ok so I found that there is already a function in the ValueBase class called get() which is a "template to get the value of the class ta by casting the ValueBase". I think if I test it out and it works then the rest would be to increment/decrement and then finally set the new data (which I'm not sure how it will be done yet). update 3: using the get() method and passing the data as a parameter just gives out a segmentation error. so something is off update 4: get_string works fine for getting the value which can be converted to the appropriate type now Im looking into how to set the new data in the valuebase. update 5: get() would be the best as it would return the value right away with the correct type and there is also a get_type which could be used to get the type of the value to put as the argument for get(), however doing so the compiler complains that the "type" is private in the class Type. Also seems there is also a set() which would be implented the same way. but for now I have to see what the type class is about. update 6: ok so get returns a value of type synfig::type which is still not the c++ type (which im assuming would be some variation of a double/float). Again I have to see what the type class is about. |
Awesome! |
|
Ok so quick update here what I have now is What's left here is somehow to loop in the button press callback until the button is released. I dont quite know how that could be done yet as the event sent to the button press method isn't updated meaning i cant do something like check for when its type becomes GDK_BUTTON_RELEASE. I'm thinking maybe signals somehow, if anyone has an idea it would be appreciated :-) overall: |
Our (irritating) way to do it is: float data = value.get(float());I don't know if this is useful here (I'm sleepy now), but Ducks have |
Yes, actually I have managed to get and set using a class called Value, but this could -possibly- be a neater way to do it. will have to look into it at the end. |
|
Well, currently ctr+z undoes the change. The way its implemented is that the ValueBase itself of the parameter is changed. There might be something I'm missing here. Maybe you mean this should be done through the spin button? update:
I have found that gtk has two functions which help in doing this, namely gtk_events_pending(), and gtk_main_iteration(); . Tested the new implementation now the incrementation/decrementation continues until button release . I for a little thought that I would have had to do some multi-threading which would have been overkill xD. |
|
ok guys, so this is how its working so far Issues/things left/ways of improving 2- moving further right increases incrementation speed. this shouldnt be time consuming though. 3- increment by smalled amounts but faster (in the video it incremented by 1 every time). Also not time consuming but I 4- Oh and also I think the cursor should be diffrent xD. not the one I have now. Any suggestions ? p.s. I will be working on 2, and 3 then cleaning up the code a bit and then make a commit by today. update: now increases by smaller amount and does so faster |
there is still a slight bug with selection + history is polluted
|
I mean pressing the
Yes, this is the next step. |
|
Just tested. It should change the value only when you move the mouse. |
This all happens because you doing this wrong way. You should subscribe to I recommend you to write a simple Gtk application just to better understand how it works. |
|
Alright guys will be looking into these and updating you soon. |
@ice0 Just so I'm sure I understand you correctly here. You mean that even if the mouse is to the right of the initial clicking position, the parameter shouldn't increase. It should only increase while the mouse is moving right correct? update: now major things left are: Also are the signal_edited/cancelled etc.. proposed by @rodolforg related to switching over to using the cell editor widget or not because I dont quite get what is meant here. |
main changes 1- using motion notify instead of limitless loop 2- parameter changes only happen when the mouse is moving
|
@ice0 should I start with working on fixing history pollution first or moving to the cell editor widget instead of treeview ? p.s. until I get a response from you guys i will be workking onfixing history pollution more specifacaly first I will be trying to understand how the history works for the parameter layer values then seeing how it could be stopped while increasin with mouse. |
Yes, better to start from history. |
|
update: I got the history to stop making new actions using a flag, I will be trying to enhance it up a bit to be a bit more sophisticated and will be committing before the end of the day hopefully :-) |
now history dock only shows the final change when changing parameter value by mouse.
|
ok so as stated in the commit description. this commit makes only the final changed value appear in the history dock. There probably might be a more sophisticated way of doing this but I think this was the simplest approach I could think of. so a rough updated version of whats left: 2 shouldnt take much time it would just be capturing the escape press and canceling change. the main thing here is 1. |
There is an easy way to check if this is done right. As you already know, Synfig has a history pollution issue when choosing a color using the color wheel. A good and universal solution should solve both of these problems.
|
First please read about Gtk Inspector (this will help you a lot). In short, you need to set an environment variable before running the Now about cell editor. Here's how a standard Gtk::Grid should look like (I've hidden our custom widget here): This is how it looks with custom widget: Reduced opacity for better understanding: This is how this widget looks in widgets tree (you can see this Gtk Inspector): This widget was implemented using custom Gtk::CellRenderer (https://docs.gtk.org/gtk3/class.CellRenderer.html) |
ok, sounds good. I will be looking to do that but also I'm not sure how complex that could get and possibly divert us from the project at focus. However, it's a bit early to know that, I will first spend some time looking into that as yes a global solution for both would be perfect.
surprisingly in windows it was as simple as just typing out that command (^_^). great I think this will save time. |
|
update: but from reading in issue #451 it seems like @rodolforg solved a similar issue (with I think waypoints ?) but I cant seem to determine where exactly it is? if its possible here I could just have it done the same way o try and keep things more unified. Right now I have it done using a flag that is checked for in the function which makes the new row in the history tree view. |
|
I have added the same method of fixing history pollution used in the color wheel pollution fix and added the ability to press escape for cancelling. I will be testing it out a bit then cleaning up the code and pushing a comit when I'm done. |
|
ok, that took a while xD. But I tried my best to test every single case I could think of to make sure that everything in the parameters panel is working as it should be along with the feature. I tested when there were waypoints around and when not and made sure to my best that I checked everything also handling things when they showed up. I haven't cleaned up the code completely though, will do that tommorow first thing hopefully, and it shouldnt take long all the testing was done today. Looking forward to having you guys test and review it. |
| { | ||
|
|
||
| auto t_now = std::chrono::high_resolution_clock::now(); | ||
| double elapsed_time_ms = std::chrono::duration<double, std::milli>(t_now-t_start).count(); |
There was a problem hiding this comment.
Why are you trying to implement the click behavior yourself? Why not just use standard event listeners?
There was a problem hiding this comment.
I couldn't find anything in the standard listeners regarding the normal clicked event, closest I found was a long click gesture which I believe was also more geared toward touch devices. If there is one though? yes it would be much better.
There was a problem hiding this comment.
But then that gets executed right away on press. My understanding of a click is that there has to be a press followed by a release right away. Then after that it is a click and we enter edit mode. And if there is a press and the mouse is moving while the press is going on without the release then it's a drag.
There was a problem hiding this comment.
Ok, I need a time to make a test app to test this.
There was a problem hiding this comment.
Alright, sounds good.
making color change from wheel drag and color change from else where mutually exclusive.
|
I tested and you are just hiding history pollution on the History panel. But |
Oh yes I haven't updated the history pollution as I was waiting on the history pollution pr. However at the current state if updated the history pollution should work and the undo. |
-the new approach
|
Try to merge changes from color-wheel-history-pollution branch and check if it works. |
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, looks like ill have to clean up this branch a bit before seeing how it looks like here, as a previous way was implemented here which conflicts with the new "to be used" way |
|
ok @ice0 , i merged the changes and it seems like its working fine (exactly same way as in color wheel). while testing some things came into mind though. |







This is main feature number 1 in my project. it was asked for in #2528 .
The first commit is very preliminary (as in includes comments that I write for my self,etc...) it includes
1- switching the mouse cursor to "move" when pressing on the parameters row (will probably have to be a diffrent icon when its actually done). then switching it back to default when released.
2- storing the selected row and tree view selection object and then updating them when changed.
Main things left to do
1- Change the actual values. moving right increases, left decreases. I'm assuming this would most likely be done through the TreeView model.
2- Of course also optimization, clean ups, and changing the mouse cursor to a more suitable icon. Also probably oher things that come up in the way, this is probably one of the "longer" features.