Skip to content

Commit

Permalink
Set wswitch 'index' variable private
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler committed Sep 2, 2024
1 parent f5a498a commit 1c354ea
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/gui/MItem_crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ constexpr size_t MI_CRASH_SENSITIVITY_XY::get_item_id_from_sensitivity(int32_t s
}

void MI_CRASH_SENSITIVITY_XY::OnChange([[maybe_unused]] size_t old_index) {
int32_t sensitivity = ITEMS[index].value;
int32_t sensitivity = ITEMS[this->GetIndex()].value;
xy_long_t se = crash_s.get_sensitivity();
se.x = sensitivity;
se.y = sensitivity;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MItem_experimental_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ MI_DIRECTION_X::MI_DIRECTION_X()
: WiSwitchDirection(has_wrong_x(), NOTRAN(label)) {}

void MI_DIRECTION_X::Store() {
index == 1 ? set_wrong_direction_x() : set_PRUSA_direction_x();
GetIndex() == 1 ? set_wrong_direction_x() : set_PRUSA_direction_x();
}

/*****************************************************************************/
Expand All @@ -120,7 +120,7 @@ MI_DIRECTION_Y::MI_DIRECTION_Y()
: WiSwitchDirection(has_wrong_y(), NOTRAN(label)) {}

void MI_DIRECTION_Y::Store() {
index == 1 ? set_wrong_direction_y() : set_PRUSA_direction_y();
GetIndex() == 1 ? set_wrong_direction_y() : set_PRUSA_direction_y();
}

/*****************************************************************************/
Expand All @@ -129,7 +129,7 @@ MI_DIRECTION_Z::MI_DIRECTION_Z()
: WiSwitchDirection(has_wrong_z(), NOTRAN(label)) {}

void MI_DIRECTION_Z::Store() {
index == 1 ? set_wrong_direction_z() : set_PRUSA_direction_z();
GetIndex() == 1 ? set_wrong_direction_z() : set_PRUSA_direction_z();
}

/*****************************************************************************/
Expand All @@ -138,7 +138,7 @@ MI_DIRECTION_E::MI_DIRECTION_E()
: WiSwitchDirection(has_wrong_e(), NOTRAN(label)) {}

void MI_DIRECTION_E::Store() {
index == 1 ? set_wrong_direction_e() : set_PRUSA_direction_e();
GetIndex() == 1 ? set_wrong_direction_e() : set_PRUSA_direction_e();
}

/*****************************************************************************/
Expand Down
12 changes: 6 additions & 6 deletions src/gui/MItem_hardware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ class MI_HARDWARE_CHECK_t : public WI_SWITCH_t<3> {
void OnChange([[maybe_unused]] size_t old_index) override {
switch (HWCheck) {
case HWCheckType::nozzle:
config_store().hw_check_nozzle.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_nozzle.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
case HWCheckType::model:
config_store().hw_check_model.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_model.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
case HWCheckType::firmware:
config_store().hw_check_firmware.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_firmware.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
case HWCheckType::gcode:
config_store().hw_check_gcode.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_gcode.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
case HWCheckType::gcode_compatibility:
config_store().hw_check_compatibility.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_compatibility.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
case HWCheckType::fan_compatibility:
config_store().hw_check_fan_compatibility.set(static_cast<HWCheckSeverity>(index));
config_store().hw_check_fan_compatibility.set(static_cast<HWCheckSeverity>(GetIndex()));
break;
default:
assert(false);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/MItem_mmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ MI_MMU_NEXTRUDER_REWORK::MI_MMU_NEXTRUDER_REWORK()
: WI_SWITCH_t(config_store().is_mmu_rework.get(), _(label), nullptr, is_enabled_t::yes, is_hidden_t::no, _(val_0), _(val_1)) {}

void MI_MMU_NEXTRUDER_REWORK::OnChange([[maybe_unused]] size_t old_index) {
if (!flip_mmu_rework(index == 0)) {
if (!flip_mmu_rework(GetIndex() == 0)) {
SetIndex(old_index); // revert the index change of the toggle in case the user aborted the dialog
return;
}

// Enabling MMU rework hides the FS_Autoload option from the menu - BFW-4290
// However the request was that the autoload "stays active"
// So we have to make sure that it's on when you activate the rework
if (index) {
if (GetIndex()) {
marlin_client::set_fs_autoload(true);
config_store().fs_autoload_enabled.set(true);
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MItem_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ MI_NET_INTERFACE_t::MI_NET_INTERFACE_t()
}

void MI_NET_INTERFACE_t::OnChange([[maybe_unused]] size_t old_index) {
netdev_set_active_id(this->index);
netdev_set_active_id(this->GetIndex());
}

MI_HOSTNAME::MI_HOSTNAME()
Expand Down Expand Up @@ -176,12 +176,12 @@ MI_NET_IP::MI_NET_IP(NetDeviceID device_id)
: WI_SWITCH_t(0, string_view_utf8::MakeCPUFLASH(label), nullptr, is_enabled_t::yes, is_hidden_t::no, string_view_utf8::MakeCPUFLASH(str_DHCP), string_view_utf8::MakeCPUFLASH(str_static))
, device_id(device_id) //
{
index = netdev_get_ip_obtained_type(this->device_id());
this->SetIndex(netdev_get_ip_obtained_type(this->device_id()));
}

void MI_NET_IP::OnChange([[maybe_unused]] size_t old_index) {
const auto dev_id = device_id();
if (index == NETDEV_STATIC) {
if (this->GetIndex() == NETDEV_STATIC) {
netdev_set_static(dev_id);
} else {
netdev_set_dhcp(dev_id);
Expand All @@ -190,7 +190,7 @@ void MI_NET_IP::OnChange([[maybe_unused]] size_t old_index) {

MI_NET_IP_VER_t::MI_NET_IP_VER_t()
: WI_SWITCH_t(0, _(label), nullptr, is_enabled_t::no, is_hidden_t::no, string_view_utf8::MakeCPUFLASH(str_v4), string_view_utf8::MakeCPUFLASH(str_v6)) {
this->index = 0;
this->SetIndex(0);
}

IMI_IP4_ADDR::IMI_IP4_ADDR(const char *label, NetDeviceID device_id, AddrType addr)
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MItem_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ MI_SOUND_MODE::MI_SOUND_MODE()
}

void MI_SOUND_MODE::OnChange(size_t /*old_index*/) {
Sound_SetMode(static_cast<eSOUND_MODE>(index));
Sound_SetMode(static_cast<eSOUND_MODE>(GetIndex()));
}

/*****************************************************************************/
Expand Down Expand Up @@ -465,7 +465,7 @@ MI_TIMEZONE_MIN::MI_TIMEZONE_MIN()
: WI_SWITCH_t<3>(static_cast<uint8_t>(config_store().timezone_minutes.get()), _(label), nullptr, is_enabled_t::yes, is_hidden_t::no, _(str_0min), _(str_30min), _(str_45min)) {}

void MI_TIMEZONE_MIN::OnChange([[maybe_unused]] size_t old_index) {
config_store().timezone_minutes.set(static_cast<time_tools::TimezoneOffsetMinutes>(index));
config_store().timezone_minutes.set(static_cast<time_tools::TimezoneOffsetMinutes>(GetIndex()));
}

/*****************************************************************************/
Expand All @@ -474,7 +474,7 @@ MI_TIMEZONE_SUMMER::MI_TIMEZONE_SUMMER()
: WI_ICON_SWITCH_OFF_ON_t(static_cast<uint8_t>(config_store().timezone_summer.get()), _(label), nullptr, is_enabled_t::yes, is_hidden_t::no) {}

void MI_TIMEZONE_SUMMER::OnChange([[maybe_unused]] size_t old_index) {
config_store().timezone_summer.set(static_cast<time_tools::TimezoneOffsetSummerTime>(index));
config_store().timezone_summer.set(static_cast<time_tools::TimezoneOffsetSummerTime>(GetIndex()));
}

/*****************************************************************************/
Expand All @@ -483,7 +483,7 @@ MI_TIME_FORMAT::MI_TIME_FORMAT()
: WI_SWITCH_t<2>(static_cast<uint8_t>(config_store().time_format.get()), _(label), nullptr, is_enabled_t::yes, is_hidden_t::no, _(str_12h), _(str_24h)) {}

void MI_TIME_FORMAT::OnChange([[maybe_unused]] size_t old_index) {
config_store().time_format.set(static_cast<time_tools::TimeFormat>(index));
config_store().time_format.set(static_cast<time_tools::TimeFormat>(GetIndex()));
}

/*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/gui/screen_menu_footer_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MI_LEFT_ALIGN_TEMP::MI_LEFT_ALIGN_TEMP()
string_view_utf8::MakeCPUFLASH((const uint8_t *)str_2)) {}

void MI_LEFT_ALIGN_TEMP::OnChange(size_t /*old_index*/) {
FooterItemHeater::SetDrawType(footer::ItemDrawType(index));
FooterItemHeater::SetDrawType(footer::ItemDrawType(GetIndex()));
}

MI_SHOW_ZERO_TEMP_TARGET::MI_SHOW_ZERO_TEMP_TARGET()
Expand Down
6 changes: 3 additions & 3 deletions src/gui/screen_menu_fw_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ MI_UPDATE::MI_UPDATE()
}

void MI_UPDATE::OnChange(size_t /*old_index*/) {
if (index == 1) {
if (GetIndex() == 1) {
data_exchange::fw_update_on_restart_enable();
sys_fw_update_disable();
} else if (index == 2) {
} else if (GetIndex() == 2) {
data_exchange::fw_update_on_restart_disable();
sys_fw_update_enable();
} else if (index == 0) {
} else if (GetIndex() == 0) {
data_exchange::fw_update_on_restart_disable();
sys_fw_update_disable();
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/screen_menu_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ MI_METRICS_ALLOW::MI_METRICS_ALLOW()
, warning_not_shown(config_store().metrics_allow.get() == MetricsAllow::None) {}

void MI_METRICS_ALLOW::OnChange(size_t old_index) {
if (old_index == ftrstd::to_underlying(MetricsAllow::None) && index != ftrstd::to_underlying(MetricsAllow::None)) { // Enable
if (old_index == ftrstd::to_underlying(MetricsAllow::None) && GetIndex() != ftrstd::to_underlying(MetricsAllow::None)) { // Enable
if (warning_not_shown && MsgBoxWarning(_(txt_confirm), Responses_YesNo, 1) != Response::Yes) {
index = ftrstd::to_underlying(MetricsAllow::None); // User changed his mind
SetIndex(ftrstd::to_underlying(MetricsAllow::None)); // User changed his mind
} else {
warning_not_shown = false;
}
}

config_store().metrics_allow.set(MetricsAllow(index));
config_store().metrics_allow.set(MetricsAllow(GetIndex()));

check_disable();
}
Expand Down
1 change: 1 addition & 0 deletions src/guiapi/include/WindowMenuSwitch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ class WI_SWITCH_t : public IWiSwitch {

private:
std::array<string_view_utf8, SZ> items_;
size_t index;
};

0 comments on commit 1c354ea

Please sign in to comment.