Disable/enable buttons as selections change in TBTR main window.
This commit is contained in:
@@ -85,8 +85,7 @@ enum TemplateReplaceWindowWidgets {
|
|||||||
TRW_WIDGET_TMPL_BUTTONS_EDIT,
|
TRW_WIDGET_TMPL_BUTTONS_EDIT,
|
||||||
TRW_WIDGET_TMPL_BUTTONS_CLONE,
|
TRW_WIDGET_TMPL_BUTTONS_CLONE,
|
||||||
TRW_WIDGET_TMPL_BUTTONS_DELETE,
|
TRW_WIDGET_TMPL_BUTTONS_DELETE,
|
||||||
//TRW_WIDGET_TMPL_BUTTONS_RPLALL,
|
|
||||||
TRW_WIDGET_TMPL_BUTTON_FLUFF,
|
|
||||||
TRW_WIDGET_TMPL_BUTTONS_EDIT_RIGHTPANEL,
|
TRW_WIDGET_TMPL_BUTTONS_EDIT_RIGHTPANEL,
|
||||||
|
|
||||||
TRW_WIDGET_TITLE_INFO_GROUP,
|
TRW_WIDGET_TITLE_INFO_GROUP,
|
||||||
@@ -234,6 +233,8 @@ public:
|
|||||||
this->selected_template_index = -1;
|
this->selected_template_index = -1;
|
||||||
this->selected_group_index = -1;
|
this->selected_group_index = -1;
|
||||||
|
|
||||||
|
this->UpdateButtonState();
|
||||||
|
|
||||||
this->templateNotice = false;
|
this->templateNotice = false;
|
||||||
this->editInProgress = false;
|
this->editInProgress = false;
|
||||||
|
|
||||||
@@ -437,6 +438,7 @@ public:
|
|||||||
} else if (newindex < this->groups.Length()) {
|
} else if (newindex < this->groups.Length()) {
|
||||||
this->selected_group_index = newindex;
|
this->selected_group_index = newindex;
|
||||||
}
|
}
|
||||||
|
this->UpdateButtonState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TRW_WIDGET_BOTTOM_MATRIX: {
|
case TRW_WIDGET_BOTTOM_MATRIX: {
|
||||||
@@ -446,6 +448,7 @@ public:
|
|||||||
} else if (newindex < templates.Length()) {
|
} else if (newindex < templates.Length()) {
|
||||||
this->selected_template_index = newindex;
|
this->selected_template_index = newindex;
|
||||||
}
|
}
|
||||||
|
this->UpdateButtonState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TRW_WIDGET_START: {
|
case TRW_WIDGET_START: {
|
||||||
@@ -455,6 +458,7 @@ public:
|
|||||||
int current_group_index = (this->groups)[this->selected_group_index]->index;
|
int current_group_index = (this->groups)[this->selected_group_index]->index;
|
||||||
|
|
||||||
DoCommandP(0, current_group_index, tv_index, CMD_ISSUE_TEMPLATE_REPLACEMENT, NULL);
|
DoCommandP(0, current_group_index, tv_index, CMD_ISSUE_TEMPLATE_REPLACEMENT, NULL);
|
||||||
|
this->UpdateButtonState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -466,6 +470,7 @@ public:
|
|||||||
int current_group_index = (this->groups)[this->selected_group_index]->index;
|
int current_group_index = (this->groups)[this->selected_group_index]->index;
|
||||||
|
|
||||||
DoCommandP(0, current_group_index, 0, CMD_DELETE_TEMPLATE_REPLACEMENT, NULL);
|
DoCommandP(0, current_group_index, 0, CMD_DELETE_TEMPLATE_REPLACEMENT, NULL);
|
||||||
|
this->UpdateButtonState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
@@ -526,6 +531,7 @@ public:
|
|||||||
{
|
{
|
||||||
this->groups.ForceRebuild();
|
this->groups.ForceRebuild();
|
||||||
this->templates.ForceRebuild();
|
this->templates.ForceRebuild();
|
||||||
|
this->UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For a given group (id) find the template that is issued for template replacement for this group and return this template's index
|
/** For a given group (id) find the template that is issued for template replacement for this group and return this template's index
|
||||||
@@ -768,6 +774,27 @@ public:
|
|||||||
|
|
||||||
_cur_dpi = old_dpi;
|
_cur_dpi = old_dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateButtonState()
|
||||||
|
{
|
||||||
|
bool selected_ok = (this->selected_template_index >= 0) && (this->selected_template_index < (short)this->templates.Length());
|
||||||
|
bool group_ok = (this->selected_group_index >= 0) && (this->selected_group_index < (short)this->groups.Length());
|
||||||
|
|
||||||
|
short g_id = -1;
|
||||||
|
if (group_ok) {
|
||||||
|
const Group *g = (this->groups)[this->selected_group_index];
|
||||||
|
g_id = g->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_TMPL_BUTTONS_EDIT, !selected_ok);
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_TMPL_BUTTONS_DELETE, !selected_ok);
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REUSE, !selected_ok);
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_KEEP, !selected_ok);
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REFIT, !selected_ok);
|
||||||
|
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_START, !(selected_ok && group_ok && FindTemplateIndexForGroup(g_id) != this->selected_template_index));
|
||||||
|
this->SetWidgetDisabledState(TRW_WIDGET_STOP, !(group_ok && GetTemplateReplacementByGroupID(g_id) != NULL));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowTemplateReplaceWindow(byte dig, int step_h)
|
void ShowTemplateReplaceWindow(byte dig, int step_h)
|
||||||
|
Reference in New Issue
Block a user