Skip to content

Commit

Permalink
Fix parameter empty name, grabbing logic, save button behavior (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
r888800009 authored Sep 24, 2024
1 parent be89ec2 commit 834a8bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/creator/panels/parameters.d
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ void incParameterView(bool armedParam=false)(size_t idx, Parameter param, string
if (*grabParam == null)
*grabParam = param.name;
} else {
*grabParam = "";
*grabParam = null;
}
}
if (igIsItemClicked(ImGuiMouseButton.Right)) {
Expand Down Expand Up @@ -1030,7 +1030,7 @@ void incParameterView(bool armedParam=false)(size_t idx, Parameter param, string
class ParametersPanel : Panel {
private:
string filter;
string grabParam = "";
string grabParam = null;
protected:
override
void onUpdate() {
Expand Down
6 changes: 3 additions & 3 deletions source/creator/widgets/controller.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct EditableAxisPoint {
/**
A Parameter controller
*/
bool incController(string strId, ref Parameter param, ImVec2 size, bool forceSnap = false, string grabParam = "") {
bool incController(string strId, ref Parameter param, ImVec2 size, bool forceSnap = false, string grabParam = null) {
ImGuiWindow* window = igGetCurrentWindow();
if (window.SkipItems) return false;

Expand Down Expand Up @@ -74,7 +74,7 @@ bool incController(string strId, ref Parameter param, ImVec2 size, bool forceSna
if (hovered && igIsMouseDown(ImGuiMouseButton.Right)) {
held = true;
}
if ((grabParam == param.name) || (hovered && held)) {
if ((grabParam !is null && grabParam == param.name) || (hovered && held)) {
igGetMousePos(&mPos);
ImVec2 vCursorPos = ImVec2(mPos.x - oRect.Min.x, mPos.y - oRect.Min.y);

Expand Down Expand Up @@ -238,7 +238,7 @@ bool incController(string strId, ref Parameter param, ImVec2 size, bool forceSna
if (hovered && igIsMouseDown(ImGuiMouseButton.Right)) {
held = true;
}
if ((grabParam == param.name) || (hovered && held)) {
if ((grabParam !is null && grabParam == param.name) || (hovered && held)) {
igGetMousePos(&mPos);
ImVec2 vCursorPos = ImVec2(mPos.x - oRect.Min.x, mPos.y - oRect.Min.y);

Expand Down
9 changes: 8 additions & 1 deletion source/creator/windows/paramprop.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ private:
string paramName;
vec2 min;
vec2 max;
bool markSave = false;

bool isValidName() {
if (paramName == "") return false;

Parameter fparam = (cast(ExPuppet)incActivePuppet()).findParameter(paramName);
return fparam is null || fparam.uuid == param.uuid;
}
Expand Down Expand Up @@ -102,8 +105,10 @@ protected:
if (igButton(__("Save"), ImVec2(64, 24))) {

if (!isValidName) {
incDialog(__("Error"), _("Name is already taken"));
incDialog(__("Error"), _("Name is already taken or empty"));
markSave = false;
} else {
markSave = true;
this.close();
}
}
Expand All @@ -115,6 +120,8 @@ protected:

override
void onClose() {
if (!markSave) return;

param.name = paramName;
param.makeIndexable();

Expand Down

0 comments on commit 834a8bc

Please sign in to comment.