Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new feature - interactive adjust of numerical value in source code #1469

Merged
merged 10 commits into from
Nov 18, 2015

Conversation

josefpavlik
Copy link
Contributor

Added feature to allow adjusting numerical value in the source code and see the effect in real time.

When the cursor is on a number, you can increment or decrement it with Alt-Up or Alt-Down keys
and see the change of model in real time.
The Alt-Left and Alt-Right keys navigates to left or right within the number and allow you to change
the increment value. Navigating to right over the number, new decimal digits are added automatically.

When the update of preview is slow and you change the number quickly, the frame rate is limited, however when you stop to increment, the actual model is shown as soon as possible.

When the cursor is on number, you can increment or decrement it with Alt-Up or Alt-Down keys
and see the change of model in real time.
The Alt-Left and Alt-Right keys navigates to left or right within the number and allow you to change
the increment value. Navigating to right over the number, new decimal digits are added automatically.
When the update of preview is slow and you change the number quickly, the frame rate is limited, however
when you stop to increment, the actual model is shown as soon as possible.
@josefpavlik josefpavlik changed the title interactive number adjust new feature - interactive adjust of numerical value in source code Oct 30, 2015
@t-paul
Copy link
Member

t-paul commented Oct 31, 2015

Very cool. Works fine for me (on Linux).

@josefpavlik
Copy link
Contributor Author

note - works only with qscintilla editor and I've tested it only on Linux. Hopelessly my mac is old, no way to compile it for snow leopard...

@t-paul
Copy link
Member

t-paul commented Oct 31, 2015

Maybe the feature should be suppressed when the cursor is not placed at a number? Currently it inserts a 1 with ALT+UP if there's no number at all.

@josefpavlik
Copy link
Contributor Author

Yes, the idea was that the feature works only on a number, seems that there is a little bug. I'll fix it.

alt-up and alt-down now check if we are on a number

alt backspace (undo) when pressed immediately after interactive modify
without release the alt key invokes preview of model (simulates F5).
alt-backspace behavior is not changed during 'normal' work.
@josefpavlik
Copy link
Contributor Author

I've add the check if we are on number before incrementing it.
Also I've add new feature - when you press the alt-backspace (undo) immediately after interactive modify of number, without releasing the alt key, the undo invokes refresh of preview of the model. However, if you release the alt key, the alt-backspace works normally, without invoking the preview.

@kintel
Copy link
Member

kintel commented Nov 9, 2015

@josefpavlik Looks good. I fixed a mac issue - see your pull requests.
Also, I'm not sure about the alt-backspace function. Alt-Backspace isn't generally bound to Undo - that's just a convention on certain platforms. Usually, undo is Ctrl-Z.

@josefpavlik
Copy link
Contributor Author

the alt-backspace is assigned to undo on Ubuntu. The only change that I've made is, that after pressing the alt-backpace (immediately after alt-arrow), the refresh of preview is invoked. Changing the number and seeing the real time preview is natural, that when you strike backspace and the number under cursor changes, that the preview is refreshed. However if the alt-backspace is not bound to undo but is bound to anything else (or not bound at all), the only change is, that the preview is refreshed.
When you press alt-backspace without using alt-arrow feature immediately before, nothing changes respect original program.

@kintel
Copy link
Member

kintel commented Nov 10, 2015

The default keybinding on Mac uses Alt-Backspace to delete the previous word, so this feature needs to be aware of the current keybinding layout. Of course existing Alt-arrows are also already bound.
Perhaps we need to take a closer look at the keyboard layout situation.

@josefpavlik
Copy link
Contributor Author

so in this case, when you press alt-backspace immediately after alt-key, the previous word will be deleted and the preview of the model will be updated..

@kintel
Copy link
Member

kintel commented Nov 11, 2015

@josefpavlik That's correct. ..so I guess the right fix is to not look for alt-backspace, but look for the key-combo bound to undo, and use that one to trigger a refresh.

@josefpavlik
Copy link
Contributor Author

@kintel I've rewrote the undo/redo preview handling and I've improved the undo during interactive mode.

Undo now undoes all consecutive arrows during the same alt session. I.e. press alt, arrow, arrow, arrow arrow, depress alt will be undoed with one only ctrl-z or alt-backspace. Any key other than arrow breaks the group. Depress alt, press alt is sufficient to break the group.

When you invoke undo immediately after alt-arrows, preview will be automatically invoked after the undo is executed. You can make more undo or redo, the preview will be refreshed, but when you press any other key than undo or redo, the auto preview is disabled and will be enabled only with another alt-arrow-up/down on the number.

Does not matter the key assignment, this should work for any operating system and works also with alternative assignment, so works either with ctrl-z and alt-backspace on Linux. I'm testing the assigned command, not some fixed key combination.

kintel added a commit that referenced this pull request Nov 18, 2015
new feature - interactive adjust of numerical value in source code
@kintel kintel merged commit 16e8ca9 into openscad:master Nov 18, 2015
@kintel
Copy link
Member

kintel commented Nov 18, 2015

@josefpavlik Looks great - thanks for hanging in there!

@josefpavlik
Copy link
Contributor Author

Thank you for the comments and for the merging.

@t-paul
Copy link
Member

t-paul commented Nov 18, 2015

Very nice, I'll try to find a way for putting that into the documentation. A mini screencast would be cool, but I'm not sure Wikibooks supports that.

@t-paul
Copy link
Member

t-paul commented Nov 21, 2015

@josefpavlik
Copy link
Contributor Author

nice video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants