Refactoring member variable names for my classes to match our coding style.

This commit is contained in:
tamasmeszaros
2018-09-19 14:54:37 +02:00
parent 1a0b72de2c
commit 3f0968fb02
9 changed files with 236 additions and 250 deletions

View File

@@ -14,31 +14,31 @@ public:
using CancelFn = std::function<void(void)>; // Cancel function signature.
private:
float state_ = .0f, max_ = 1.f, step_;
CancelFn cancelfunc_ = [](){};
float m_state = .0f, m_max = 1.f, m_step;
CancelFn m_cancelfunc = [](){};
public:
inline virtual ~ProgressIndicator() {}
/// Get the maximum of the progress range.
float max() const { return max_; }
float max() const { return m_max; }
/// Get the current progress state
float state() const { return state_; }
float state() const { return m_state; }
/// Set the maximum of the progress range
virtual void max(float maxval) { max_ = maxval; }
virtual void max(float maxval) { m_max = maxval; }
/// Set the current state of the progress.
virtual void state(float val) { state_ = val; }
virtual void state(float val) { m_state = val; }
/**
* @brief Number of states int the progress. Can be used instead of giving a
* maximum value.
*/
virtual void states(unsigned statenum) {
step_ = max_ / statenum;
m_step = m_max / statenum;
}
/// Message shown on the next status update.
@@ -51,13 +51,13 @@ public:
virtual void message_fmt(const std::string& fmt, ...);
/// Set up a cancel callback for the operation if feasible.
virtual void on_cancel(CancelFn func = CancelFn()) { cancelfunc_ = func; }
virtual void on_cancel(CancelFn func = CancelFn()) { m_cancelfunc = func; }
/**
* Explicitly shut down the progress indicator and call the associated
* callback.
*/
virtual void cancel() { cancelfunc_(); }
virtual void cancel() { m_cancelfunc(); }
/// Convenience function to call message and status update in one function.
void update(float st, const std::string& msg) {

View File

@@ -14,117 +14,117 @@ namespace Slic3r {
ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id):
self(new wxStatusBar(parent ? parent : GUI::get_main_frame(),
id == -1? wxID_ANY : id)),
timer_(new wxTimer(self)),
prog_ (new wxGauge(self,
m_timer(new wxTimer(self)),
m_prog (new wxGauge(self,
wxGA_HORIZONTAL,
100,
wxDefaultPosition,
wxDefaultSize)),
cancelbutton_(new wxButton(self,
m_cancelbutton(new wxButton(self,
-1,
"Cancel",
wxDefaultPosition,
wxDefaultSize))
{
prog_->Hide();
cancelbutton_->Hide();
m_prog->Hide();
m_cancelbutton->Hide();
self->SetFieldsCount(3);
int w[] = {-1, 150, 155};
self->SetStatusWidths(3, w);
self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) {
if (prog_->IsShown()) timer_->Stop();
if(is_busy()) prog_->Pulse();
if (m_prog->IsShown()) m_timer->Stop();
if(is_busy()) m_prog->Pulse();
});
self->Bind(wxEVT_SIZE, [this](wxSizeEvent& event){
wxRect rect;
self->GetFieldRect(1, rect);
auto offset = 0;
cancelbutton_->Move(rect.GetX() + offset, rect.GetY() + offset);
cancelbutton_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
m_cancelbutton->Move(rect.GetX() + offset, rect.GetY() + offset);
m_cancelbutton->SetSize(rect.GetWidth() - offset, rect.GetHeight());
self->GetFieldRect(2, rect);
prog_->Move(rect.GetX() + offset, rect.GetY() + offset);
prog_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
m_prog->Move(rect.GetX() + offset, rect.GetY() + offset);
m_prog->SetSize(rect.GetWidth() - offset, rect.GetHeight());
event.Skip();
});
cancelbutton_->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
if(cancel_cb_) cancel_cb_();
m_cancelbutton->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
if(m_cancel_cb) m_cancel_cb();
m_perl_cancel_callback.call();
cancelbutton_->Hide();
m_cancelbutton->Hide();
});
}
ProgressStatusBar::~ProgressStatusBar() {
if(timer_->IsRunning()) timer_->Stop();
if(m_timer->IsRunning()) m_timer->Stop();
}
int ProgressStatusBar::get_progress() const
{
return prog_->GetValue();
return m_prog->GetValue();
}
void ProgressStatusBar::set_progress(int val)
{
if(!prog_->IsShown()) show_progress(true);
if(!m_prog->IsShown()) show_progress(true);
if(val == prog_->GetRange()) {
prog_->SetValue(0);
if(val == m_prog->GetRange()) {
m_prog->SetValue(0);
show_progress(false);
} else {
prog_->SetValue(val);
m_prog->SetValue(val);
}
}
int ProgressStatusBar::get_range() const
{
return prog_->GetRange();
return m_prog->GetRange();
}
void ProgressStatusBar::set_range(int val)
{
if(val != prog_->GetRange()) {
prog_->SetRange(val);
if(val != m_prog->GetRange()) {
m_prog->SetRange(val);
}
}
void ProgressStatusBar::show_progress(bool show)
{
prog_->Show(show);
prog_->Pulse();
m_prog->Show(show);
m_prog->Pulse();
}
void ProgressStatusBar::start_busy(int rate)
{
busy_ = true;
m_busy = true;
show_progress(true);
if (!timer_->IsRunning()) {
timer_->Start(rate);
if (!m_timer->IsRunning()) {
m_timer->Start(rate);
}
}
void ProgressStatusBar::stop_busy()
{
timer_->Stop();
m_timer->Stop();
show_progress(false);
prog_->SetValue(0);
busy_ = false;
m_prog->SetValue(0);
m_busy = false;
}
void ProgressStatusBar::set_cancel_callback(ProgressStatusBar::CancelFn ccb) {
cancel_cb_ = ccb;
if(ccb) cancelbutton_->Show();
else cancelbutton_->Hide();
m_cancel_cb = ccb;
if(ccb) m_cancelbutton->Show();
else m_cancelbutton->Hide();
}
void ProgressStatusBar::run(int rate)
{
if(!timer_->IsRunning()) {
timer_->Start(rate);
if(!m_timer->IsRunning()) {
m_timer->Start(rate);
}
}
@@ -141,12 +141,12 @@ void ProgressStatusBar::set_status_text(const wxString& txt)
void ProgressStatusBar::show_cancel_button()
{
cancelbutton_->Show();
m_cancelbutton->Show();
}
void ProgressStatusBar::hide_cancel_button()
{
cancelbutton_->Hide();
m_cancelbutton->Hide();
}
}

View File

@@ -24,9 +24,9 @@ namespace Slic3r {
*/
class ProgressStatusBar {
wxStatusBar *self; // we cheat! It should be the base class but: perl!
wxTimer *timer_;
wxGauge *prog_;
wxButton *cancelbutton_;
wxTimer *m_timer;
wxGauge *m_prog;
wxButton *m_cancelbutton;
public:
/// Cancel callback function type
@@ -42,7 +42,7 @@ public:
void show_progress(bool);
void start_busy(int = 100);
void stop_busy();
inline bool is_busy() const { return busy_; }
inline bool is_busy() const { return m_busy; }
void set_cancel_callback(CancelFn = CancelFn());
inline void remove_cancel_callback() { set_cancel_callback(); }
void run(int rate);
@@ -55,8 +55,8 @@ public:
PerlCallback m_perl_cancel_callback;
private:
bool busy_ = false;
CancelFn cancel_cb_;
bool m_busy = false;
CancelFn m_cancel_cb;
};
namespace GUI {