Skip to content

Commit

Permalink
Features: scrolling when parameter arm selection (#406)
Browse files Browse the repository at this point in the history
* Features: scrolling when parameter arm selection

* Added option to disable automatic scrolling of parameter lists

* Using EnableParamAutoScroll and set default true
  • Loading branch information
r888800009 committed Sep 15, 2024
1 parent a5ce383 commit 34e4128
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
23 changes: 22 additions & 1 deletion source/creator/panels/parameters.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import std.algorithm.searching : countUntil;
import std.algorithm.sorting : sort;
import std.algorithm.mutation : remove;

enum ScrollUpdate {
None, Selected, Unselected
}

private {

ParameterBinding[][Node] cParamBindingEntries;
Expand All @@ -42,6 +46,10 @@ private {
Parameter cClipboardParameter = null;
bool selectedOnly = false;

// handle the parameter view scroll focus
ScrollUpdate scrollUpdate = ScrollUpdate.None;
float prevScrollY = 0;

void refreshBindingList(Parameter param, bool selectedOnly = false) {
// Filter selection to remove anything that went away
ParameterBinding[BindTarget] newSelectedBindings;
Expand Down Expand Up @@ -978,10 +986,12 @@ void incParameterView(bool armedParam=false)(size_t idx, Parameter param, string
if (incButtonColored(isArmed ? "" : "", ImVec2(24, 24), isArmed ? ImVec4(1f, 0f, 0f, 1f) : *igGetStyleColorVec4(ImGuiCol.Text))) {
if (incArmedParameter() == param) {
incDisarmParameter();
scrollUpdate = ScrollUpdate.Unselected;
} else {
param.value = param.getClosestKeypointValue();
paramPointChanged(param);
incArmParameter(idx, param);
scrollUpdate = ScrollUpdate.Selected;
}
}

Expand Down Expand Up @@ -1100,7 +1110,18 @@ protected:
igEndChild();

if (igBeginChild("ParametersList", ImVec2(0, -36))) {

// Scroll update, it allows us to scroll to the selected parameter.
if (incSettingsGet!bool("EnableParamAutoScroll", true) && scrollUpdate != ScrollUpdate.None) {
if (scrollUpdate == ScrollUpdate.Selected) {
prevScrollY = igGetScrollY();
igSetScrollY(0);
} else if (scrollUpdate == ScrollUpdate.Unselected) {
igSetScrollY(prevScrollY);
}

scrollUpdate = ScrollUpdate.None;
}

// Always render the currently armed parameter on top
if (incArmedParameter()) {
incParameterView!true(incArmedParameterIdx(), incArmedParameter(), &grabParam, false, parameters);
Expand Down
6 changes: 6 additions & 0 deletions source/creator/windows/settings.d
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ protected:
changesRequiresRestart = true;
}
incTooltip(_("Use the OpenDyslexic font for Latin text characters."));

bool paramAutoScroll = incSettingsGet!bool("EnableParamAutoScroll", true);
if (igCheckbox(__("Scroll to armed parameter"), &paramAutoScroll)) {
incSettingsSet("EnableParamAutoScroll", paramAutoScroll);
}
incTooltip(_("Enable automatic scrolling to the top of the parameters list."));
endSection();
break;
case SettingsPane.FileHandling:
Expand Down

0 comments on commit 34e4128

Please sign in to comment.