Fix moving and resizing open/save dialog

* Fixed buffer overflow when resizing
* Stop hard drive thrashing when moving/resizing
1008-fix
melex750 2017-06-26 14:19:53 -04:00
parent 2d2990ff91
commit 86870167a6
2 changed files with 14 additions and 15 deletions

View File

@ -579,6 +579,8 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if (pw != nullptr) pw->ClearState(STATE_VISIBLE | STATE_ENABLE);
m_dialogPos = m_settings->GetIOPos();
m_dialogDim = m_settings->GetIODim();
m_windowPos = m_settings->GetWindowPos();
m_windowDim = m_settings->GetWindowDim();
m_bEditMaximized = m_settings->GetWindowMax();
@ -930,6 +932,8 @@ bool CStudio::StopEditScript(bool closeWithErrors)
m_main->SetEditLock(false, true);
m_camera->SetType(m_editCamera);
m_settings->SetIOPos(m_dialogPos);
m_settings->SetIODim(m_dialogDim);
m_settings->SetWindowPos(m_windowPos);
m_settings->SetWindowDim(m_windowDim);
m_settings->SetWindowMax(m_bEditMaximized);
@ -1272,8 +1276,8 @@ void CStudio::AdjustDialog()
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return;
wpos = pw->GetPos();
wdim = pw->GetDim();
m_dialogPos = wpos = pw->GetPos();
m_dialogDim = wdim = pw->GetDim();
pw->SetPos(wpos); // to move the buttons on the titlebar
if ( m_dialog == SD_OPEN ||
@ -1323,10 +1327,9 @@ void CStudio::AdjustDialog()
pe->SetPos(ppos);
pe->SetDim(ddim);
nch = static_cast< int >((ddim.x*640.0f-22.0f)/8.0f);
name = pe->GetText(100);
nch = static_cast< int >((ddim.x*640.0f-22.0f)/5.75f);
name = pe->GetText(nch); // truncates the text according to max
pe->SetMaxChar(nch);
name[nch] = 0; // truncates the text according to max
pe->SetText(name);
}
@ -1384,19 +1387,10 @@ void CStudio::AdjustDialog()
bool CStudio::EventDialog(const Event &event)
{
CWindow* pw;
Math::Point wpos, wdim;
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return false;
if ( event.type == EVENT_WINDOW9 ) // window is moved?
{
wpos = pw->GetPos();
wdim = pw->GetDim();
m_settings->SetIOPos(wpos);
m_settings->SetIODim(wdim);
AdjustDialog();
return true;
}
if ( m_dialog == SD_OPEN ||
@ -1441,6 +1435,9 @@ bool CStudio::EventDialog(const Event &event)
return true;
}
CWindow* pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return false;
if ( event.type == EVENT_DIALOG_CANCEL ||
(event.type == EVENT_KEY_DOWN && event.GetData<KeyEventData>()->key == KEY(ESCAPE)) ||
event.type == pw->GetEventTypeClose() )

View File

@ -110,6 +110,8 @@ protected:
Math::Point m_editFinalDim;
Math::Point m_windowPos;
Math::Point m_windowDim;
Math::Point m_dialogPos;
Math::Point m_dialogDim;
float m_time;
float m_fixInfoTextTime;