assdraw: strip trailing whitespace from files

Originally committed to SVN as r6866.
This commit is contained in:
Thomas Goyne 2012-05-24 01:56:30 +00:00
parent 8c6d047115
commit c3aa3cbe00
10 changed files with 238 additions and 238 deletions

View file

@ -5,20 +5,20 @@
// Contact: mcseem@antigrain.com // Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com // mcseemagg@yahoo.com
// http://antigrain.com // http://antigrain.com
// //
// AGG is free software; you can redistribute it and/or // AGG is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
// //
// AGG is distributed in the hope that it will be useful, // AGG is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with AGG; if not, write to the Free Software // along with AGG; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA. // MA 02110-1301, USA.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -58,7 +58,7 @@ namespace agg
init(num, x, y); init(num, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void bcspline::init(int max) void bcspline::init(int max)
{ {
@ -92,12 +92,12 @@ namespace agg
if(m_num > 2) if(m_num > 2)
{ {
int i, k, n1; int i, k, n1;
double* temp; double* temp;
double* r; double* r;
double* s; double* s;
double h, p, d, f, e; double h, p, d, f, e;
for(k = 0; k < m_num; k++) for(k = 0; k < m_num; k++)
{ {
m_am[k] = 0.0; m_am[k] = 0.0;
} }
@ -107,7 +107,7 @@ namespace agg
pod_array<double> al(n1); pod_array<double> al(n1);
temp = &al[0]; temp = &al[0];
for(k = 0; k < n1; k++) for(k = 0; k < n1; k++)
{ {
temp[k] = 0.0; temp[k] = 0.0;
} }
@ -119,7 +119,7 @@ namespace agg
d = m_x[1] - m_x[0]; d = m_x[1] - m_x[0];
e = (m_y[1] - m_y[0]) / d; e = (m_y[1] - m_y[0]) / d;
for(k = 1; k < n1; k++) for(k = 1; k < n1; k++)
{ {
h = d; h = d;
d = m_x[k + 1] - m_x[k]; d = m_x[k + 1] - m_x[k];
@ -130,18 +130,18 @@ namespace agg
s[k] = 6.0 * (e - f) / (h + d); s[k] = 6.0 * (e - f) / (h + d);
} }
for(k = 1; k < n1; k++) for(k = 1; k < n1; k++)
{ {
p = 1.0 / (r[k] * al[k - 1] + 2.0); p = 1.0 / (r[k] * al[k - 1] + 2.0);
al[k] *= -p; al[k] *= -p;
s[k] = (s[k] - r[k] * s[k - 1]) * p; s[k] = (s[k] - r[k] * s[k - 1]) * p;
} }
m_am[n1] = 0.0; m_am[n1] = 0.0;
al[n1 - 1] = s[n1 - 1]; al[n1 - 1] = s[n1 - 1];
m_am[n1 - 1] = al[n1 - 1]; m_am[n1 - 1] = al[n1 - 1];
for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--) for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
{ {
al[k] = al[k] * al[k + 1] + s[k]; al[k] = al[k] * al[k + 1] + s[k];
m_am[k] = al[k]; m_am[k] = al[k];
@ -170,14 +170,14 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void bcspline::bsearch(int n, const double *x, double x0, int *i) void bcspline::bsearch(int n, const double *x, double x0, int *i)
{ {
int j = n - 1; int j = n - 1;
int k; int k;
for(*i = 0; (j - *i) > 1; ) for(*i = 0; (j - *i) > 1; )
{ {
if(x0 < x[k = (*i + j) >> 1]) j = k; if(x0 < x[k = (*i + j) >> 1]) j = k;
else *i = k; else *i = k;
} }
} }
@ -201,8 +201,8 @@ namespace agg
double bcspline::extrapolation_left(double x) const double bcspline::extrapolation_left(double x) const
{ {
double d = m_x[1] - m_x[0]; double d = m_x[1] - m_x[0];
return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) * return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
(x - m_x[0]) + (x - m_x[0]) +
m_y[0]; m_y[0];
} }
@ -210,8 +210,8 @@ namespace agg
double bcspline::extrapolation_right(double x) const double bcspline::extrapolation_right(double x) const
{ {
double d = m_x[m_num - 1] - m_x[m_num - 2]; double d = m_x[m_num - 1] - m_x[m_num - 2];
return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) * return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
(x - m_x[m_num - 1]) + (x - m_x[m_num - 1]) +
m_y[m_num - 1]; m_y[m_num - 1];
} }
@ -253,15 +253,15 @@ namespace agg
if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1]) if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
{ {
// Check if x between next points (most probably) // Check if x between next points (most probably)
if(m_last_idx < m_num - 2 && if(m_last_idx < m_num - 2 &&
x >= m_x[m_last_idx + 1] && x >= m_x[m_last_idx + 1] &&
x <= m_x[m_last_idx + 2]) x <= m_x[m_last_idx + 2])
{ {
++m_last_idx; ++m_last_idx;
} }
else else
if(m_last_idx > 0 && if(m_last_idx > 0 &&
x >= m_x[m_last_idx - 1] && x >= m_x[m_last_idx - 1] &&
x <= m_x[m_last_idx]) x <= m_x[m_last_idx])
{ {
// x is between pevious points // x is between pevious points

View file

@ -5,20 +5,20 @@
// Contact: mcseem@antigrain.com // Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com // mcseemagg@yahoo.com
// http://antigrain.com // http://antigrain.com
// //
// AGG is free software; you can redistribute it and/or // AGG is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
// //
// AGG is distributed in the hope that it will be useful, // AGG is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with AGG; if not, write to the Free Software // along with AGG; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA. // MA 02110-1301, USA.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View file

@ -75,7 +75,7 @@ BEGIN_EVENT_TABLE(ASSDrawFrame, wxFrame)
EVT_TOOL(TB_TRANSFORM, ASSDrawFrame::OnSelect_Transform) EVT_TOOL(TB_TRANSFORM, ASSDrawFrame::OnSelect_Transform)
EVT_TOOL_RANGE(MODE_ARR, MODE_DEL, ASSDrawFrame::OnChoose_Mode) EVT_TOOL_RANGE(MODE_ARR, MODE_DEL, ASSDrawFrame::OnChoose_Mode)
EVT_TOOL_RCLICKED(wxID_ANY, ASSDrawFrame::OnToolRClick) EVT_TOOL_RCLICKED(wxID_ANY, ASSDrawFrame::OnToolRClick)
EVT_COMMAND(wxID_ANY, wxEVT_SETTINGS_CHANGED, ASSDrawFrame::OnSettingsChanged) EVT_COMMAND(wxID_ANY, wxEVT_SETTINGS_CHANGED, ASSDrawFrame::OnSettingsChanged)
EVT_MENU_RANGE(MENU_TB_ALL, MENU_TB_BGIMG, ASSDrawFrame::OnChoose_TBarRClickMenu) EVT_MENU_RANGE(MENU_TB_ALL, MENU_TB_BGIMG, ASSDrawFrame::OnChoose_TBarRClickMenu)
EVT_MENU(MENU_CLEAR, ASSDrawFrame::OnSelect_Clear) EVT_MENU(MENU_CLEAR, ASSDrawFrame::OnSelect_Clear)
EVT_MENU(MENU_PREVIEW, ASSDrawFrame::OnSelect_Preview) EVT_MENU(MENU_PREVIEW, ASSDrawFrame::OnSelect_Preview)
@ -130,15 +130,15 @@ ASSDrawFrame::ASSDrawFrame( wxApp *app, const wxString& title, const wxPoint& po
// set the frame icon // set the frame icon
SetIcon(wxICON(appico)); SetIcon(wxICON(appico));
// Create status bar for the frame // Create status bar for the frame
CreateStatusBar(3); CreateStatusBar(3);
int statwidths[] = { 64, -1, 64 }; int statwidths[] = { 64, -1, 64 };
GetStatusBar()->SetStatusWidths(3, statwidths); GetStatusBar()->SetStatusWidths(3, statwidths);
SetStatusBarPane(1); SetStatusBarPane(1);
InitializeDefaultSettings(); InitializeDefaultSettings();
// load config // load config
configfile = wxFileName(::wxGetCwd(), _T("ASSDraw3.cfg")).GetFullPath(); configfile = wxFileName(::wxGetCwd(), _T("ASSDraw3.cfg")).GetFullPath();
if (!::wxFileExists(configfile)) if (!::wxFileExists(configfile))
@ -170,7 +170,7 @@ ASSDrawFrame::ASSDrawFrame( wxApp *app, const wxString& title, const wxPoint& po
// settings // settings
settingsdlg = new ASSDrawSettingsDialog(this, this); settingsdlg = new ASSDrawSettingsDialog(this, this);
settingsdlg->Init(); settingsdlg->Init();
SetMenus(); SetMenus();
SetToolBars(); SetToolBars();
SetPanes(); SetPanes();
@ -195,14 +195,14 @@ ASSDrawFrame::ASSDrawFrame( wxApp *app, const wxString& title, const wxPoint& po
{ {
wxString libcmds; wxString libcmds;
config->Read(wxString::Format(_T("%d"),i), &libcmds); config->Read(wxString::Format(_T("%d"),i), &libcmds);
shapelib->AddShapePreview(libcmds); shapelib->AddShapePreview(libcmds);
} }
config->SetPath(_T("..")); config->SetPath(_T(".."));
m_mgr.Update(); m_mgr.Update();
m_canvas->SetFocus(); m_canvas->SetFocus();
m_canvas->Show(); m_canvas->Show();
wxSize clientsize = m_canvas->GetClientSize(); wxSize clientsize = m_canvas->GetClientSize();
m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2)); m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2));
m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2); m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2);
@ -268,7 +268,7 @@ void ASSDrawFrame::SetToolBars()
m_mgr.AddPane(bgimgtbar, wxAuiPaneInfo().Name(_T("bgimgtbar")).Caption(TBNAME_BGIMG). m_mgr.AddPane(bgimgtbar, wxAuiPaneInfo().Name(_T("bgimgtbar")).Caption(TBNAME_BGIMG).
ToolbarPane().Top().Position(2).Dockable(true).LeftDockable(false).RightDockable(false)); ToolbarPane().Top().Position(2).Dockable(true).LeftDockable(false).RightDockable(false));
} }
void ASSDrawFrame::SetMenus() void ASSDrawFrame::SetMenus()
@ -358,7 +358,7 @@ void ASSDrawFrame::SetPanes()
m_mgr.AddPane(srctxtctrl, wxAuiPaneInfo().Name(_T("commands")).Caption(_T("Drawing commands")). m_mgr.AddPane(srctxtctrl, wxAuiPaneInfo().Name(_T("commands")).Caption(_T("Drawing commands")).
Bottom().Layer(1).CloseButton(false).BestSize(wxSize(320, 48))); Bottom().Layer(1).CloseButton(false).BestSize(wxSize(320, 48)));
if (settingsdlg) if (settingsdlg)
m_mgr.AddPane(settingsdlg, wxAuiPaneInfo().Name(_T("settings")).Caption(_T("Settings")). m_mgr.AddPane(settingsdlg, wxAuiPaneInfo().Name(_T("settings")).Caption(_T("Settings")).
Right().Layer(3).Position(0).CloseButton(true).BestSize(wxSize(240, 480)).MinSize(wxSize(200, 200)).Show(false)); Right().Layer(3).Position(0).CloseButton(true).BestSize(wxSize(240, 480)).MinSize(wxSize(200, 200)).Show(false));
@ -372,7 +372,7 @@ ASSDrawFrame::~ASSDrawFrame()
config->SetPath(_T("..")); config->SetPath(_T(".."));
SaveSettings(); SaveSettings();
config->SetPath(_T("perspective")); config->SetPath(_T("perspective"));
config->Write(_T("perspective"), m_mgr.SavePerspective()); config->Write(_T("perspective"), m_mgr.SavePerspective());
config->SetPath(_T("..")); config->SetPath(_T(".."));
@ -390,7 +390,7 @@ ASSDrawFrame::~ASSDrawFrame()
wxFileOutputStream cfgf(configfile); wxFileOutputStream cfgf(configfile);
config->Save(cfgf); config->Save(cfgf);
delete config; delete config;
if (settingsdlg) settingsdlg->Destroy(); // we need this since wxPropertyGrid must be Clear()ed before deleting if (settingsdlg) settingsdlg->Destroy(); // we need this since wxPropertyGrid must be Clear()ed before deleting
m_mgr.UnInit(); m_mgr.UnInit();
@ -398,7 +398,7 @@ ASSDrawFrame::~ASSDrawFrame()
void ASSDrawFrame::_Clear() void ASSDrawFrame::_Clear()
{ {
wxMessageDialog msgb(this, _T("Clear the canvas and create a new drawing?"), wxMessageDialog msgb(this, _T("Clear the canvas and create a new drawing?"),
_T("Confirmation"), wxOK | wxCANCEL | wxICON_QUESTION ); _T("Confirmation"), wxOK | wxCANCEL | wxICON_QUESTION );
if (msgb.ShowModal() == wxID_OK) if (msgb.ShowModal() == wxID_OK)
{ {
@ -521,7 +521,7 @@ void ASSDrawFrame::OnChoose_RecenterToBG(wxCommandEvent& event)
int lx = (int)disp.x, ty = (int)disp.y; int lx = (int)disp.x, ty = (int)disp.y;
int rx = lx + (int)(w * scale); int rx = lx + (int)(w * scale);
int by = ty + (int)(h * scale); int by = ty + (int)(h * scale);
switch (event.GetId()) switch (event.GetId())
{ {
case MENU_REPOS_BGTOPLEFT: x = lx, y = ty; break; case MENU_REPOS_BGTOPLEFT: x = lx, y = ty; break;
@ -530,7 +530,7 @@ void ASSDrawFrame::OnChoose_RecenterToBG(wxCommandEvent& event)
case MENU_REPOS_BGBOTLEFT: x = lx, y = by; break; case MENU_REPOS_BGBOTLEFT: x = lx, y = by; break;
case MENU_REPOS_BGBOTRIGHT: x = rx, y = by; break; case MENU_REPOS_BGBOTRIGHT: x = rx, y = by; break;
} }
m_canvas->MoveCanvasDrawing(x - m_canvas->GetOriginX(), y - m_canvas->GetOriginY()); m_canvas->MoveCanvasDrawing(x - m_canvas->GetOriginX(), y - m_canvas->GetOriginY());
m_canvas->RefreshDisplay(); m_canvas->RefreshDisplay();
} }
@ -592,31 +592,31 @@ void ASSDrawFrame::OnChoose_TBarRClickMenu(wxCommandEvent& event)
bool dock[2] = { false, true }; bool dock[2] = { false, true };
switch (id) switch (id)
{ {
case MENU_TB_ALL: case MENU_TB_ALL:
tb[0] = true, tb[1] = true, tb[2] = true; tb[0] = true, tb[1] = true, tb[2] = true;
show[0] = true, show[1] = true; show[0] = true, show[1] = true;
break; break;
case MENU_TB_NONE: case MENU_TB_NONE:
tb[0] = true, tb[1] = true, tb[2] = true; tb[0] = true, tb[1] = true, tb[2] = true;
show[0] = true, show[1] = false; show[0] = true, show[1] = false;
break; break;
case MENU_TB_DOCK: case MENU_TB_DOCK:
tb[0] = true, tb[1] = true, tb[2] = true; tb[0] = true, tb[1] = true, tb[2] = true;
dock[0] = true, dock[1] = true; dock[0] = true, dock[1] = true;
break; break;
case MENU_TB_UNDOCK: case MENU_TB_UNDOCK:
tb[0] = true, tb[1] = true, tb[2] = true; tb[0] = true, tb[1] = true, tb[2] = true;
dock[0] = true, dock[1] = false; dock[0] = true, dock[1] = false;
break; break;
case MENU_TB_DRAW: case MENU_TB_DRAW:
tb[0] = true; tb[0] = true;
show[0] = true, show[1] = !m_mgr.GetPane(tbar[0]).IsShown(); show[0] = true, show[1] = !m_mgr.GetPane(tbar[0]).IsShown();
break; break;
case MENU_TB_MODE: case MENU_TB_MODE:
tb[1] = true; tb[1] = true;
show[0] = true, show[1] = !m_mgr.GetPane(tbar[1]).IsShown(); show[0] = true, show[1] = !m_mgr.GetPane(tbar[1]).IsShown();
break; break;
case MENU_TB_BGIMG: case MENU_TB_BGIMG:
tb[2] = true; tb[2] = true;
show[0] = true, show[1] = !m_mgr.GetPane(tbar[2]).IsShown(); show[0] = true, show[1] = !m_mgr.GetPane(tbar[2]).IsShown();
break; break;
@ -730,10 +730,10 @@ void ASSDrawFrame::OnClose(wxCloseEvent &event)
if (event.CanVeto() && behaviors.confirmquit) if (event.CanVeto() && behaviors.confirmquit)
{ {
if (wxMessageDialog(this, _T("Do you want to close ASSDraw3 now?"), _T("Confirmation"), wxOK | wxCANCEL).ShowModal() == wxID_OK) if (wxMessageDialog(this, _T("Do you want to close ASSDraw3 now?"), _T("Confirmation"), wxOK | wxCANCEL).ShowModal() == wxID_OK)
Destroy(); Destroy();
else else
event.Veto(); event.Veto();
} }
else else
Destroy(); Destroy();
} }

View file

@ -96,7 +96,7 @@ void ASSDrawFrame::ApplySettings()
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
wxColourToAggRGBA(colors.library_shape, shapes[i]->rgba_shape); wxColourToAggRGBA(colors.library_shape, shapes[i]->rgba_shape);
shapelib->libarea->Refresh(); shapelib->libarea->Refresh();
m_canvas->SetDrawCmdSet(behaviors.parse_spc? _T("m n l b s p c _"):_T("m n l b _")); m_canvas->SetDrawCmdSet(behaviors.parse_spc? _T("m n l b s p c _"):_T("m n l b _"));
UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS()); UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS());

View file

@ -92,7 +92,7 @@ ASSDrawCanvas::ASSDrawCanvas(wxWindow *parent, ASSDrawFrame *frame, int extrafla
bgimg.bgimg = NULL; bgimg.bgimg = NULL;
bgimg.alpha = 0.5; bgimg.alpha = 0.5;
rectbound2upd = -1, rectbound2upd2 = -1; rectbound2upd = -1, rectbound2upd2 = -1;
rgba_shape_normal = agg::rgba(0,0,1,0.5); rgba_shape_normal = agg::rgba(0,0,1,0.5);
rgba_outline = agg::rgba(0,0,0); rgba_outline = agg::rgba(0,0,0);
rgba_guideline = agg::rgba(0.5,0.5,0.5); rgba_guideline = agg::rgba(0.5,0.5,0.5);
@ -115,7 +115,7 @@ ASSDrawCanvas::ASSDrawCanvas(wxWindow *parent, ASSDrawFrame *frame, int extrafla
bgimg.bgimg = NULL; bgimg.bgimg = NULL;
// drag image background file // drag image background file
SetDropTarget(new ASSDrawFileDropTarget(this)); SetDropTarget(new ASSDrawFileDropTarget(this));
hasStatusBar = m_frame->GetStatusBar() != NULL; hasStatusBar = m_frame->GetStatusBar() != NULL;
// cursor = crosshair // cursor = crosshair
@ -132,7 +132,7 @@ ASSDrawCanvas::ASSDrawCanvas(wxWindow *parent, ASSDrawFrame *frame, int extrafla
bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this); bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
bgimg.alpha_slider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this); bgimg.alpha_slider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
bgimg.alpha_slider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this); bgimg.alpha_slider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
RefreshUndocmds(); RefreshUndocmds();
} }
@ -188,8 +188,8 @@ void ASSDrawCanvas::SetPreviewMode(bool mode)
} }
// (Re)draw canvas // (Re)draw canvas
void ASSDrawCanvas::RefreshDisplay() void ASSDrawCanvas::RefreshDisplay()
{ {
ASSDrawEngine::RefreshDisplay(); ASSDrawEngine::RefreshDisplay();
wxString asscmds = GenerateASS(); wxString asscmds = GenerateASS();
if (oldasscmds != asscmds) if (oldasscmds != asscmds)
@ -199,9 +199,9 @@ void ASSDrawCanvas::RefreshDisplay()
} }
} }
void ASSDrawCanvas::SetDrawMode( MODE mode ) void ASSDrawCanvas::SetDrawMode( MODE mode )
{ {
draw_mode = mode; draw_mode = mode;
if (!selected_points.empty()) if (!selected_points.empty())
ClearPointsSelection(); ClearPointsSelection();
@ -211,7 +211,7 @@ void ASSDrawCanvas::SetDrawMode( MODE mode )
if (IsTransformMode()) if (IsTransformMode())
{ {
isshapetransformable = cmds.size() > 1; isshapetransformable = cmds.size() > 1;
if (isshapetransformable) if (isshapetransformable)
{ {
@ -226,9 +226,9 @@ void ASSDrawCanvas::SetDrawMode( MODE mode )
backupcmds.move_to(pp.x, pp.y); backupcmds.move_to(pp.x, pp.y);
} }
wxPoint pp = (*iterate)->m_point->ToWxPoint(); wxPoint pp = (*iterate)->m_point->ToWxPoint();
backupcmds.move_to(pp.x, pp.y); backupcmds.move_to(pp.x, pp.y);
} }
// calculate bounding rectangle // calculate bounding rectangle
agg::trans_affine mtx; agg::trans_affine mtx;
trans_path *rm, *rb; trans_path *rm, *rb;
@ -241,28 +241,28 @@ void ASSDrawCanvas::SetDrawMode( MODE mode )
delete rc; delete rc;
int minx = rasterizer.min_x(), miny = rasterizer.min_y(); int minx = rasterizer.min_x(), miny = rasterizer.min_y();
int maxx = rasterizer.max_x(), maxy = rasterizer.max_y(); int maxx = rasterizer.max_x(), maxy = rasterizer.max_y();
rectbound[0] = wxRealPoint(minx, miny); rectbound[0] = wxRealPoint(minx, miny);
rectbound[1] = wxRealPoint(maxx, miny); rectbound[1] = wxRealPoint(maxx, miny);
rectbound[2] = wxRealPoint(maxx, maxy); rectbound[2] = wxRealPoint(maxx, maxy);
rectbound[3] = wxRealPoint(minx, maxy); rectbound[3] = wxRealPoint(minx, maxy);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
rectbound2[i] = rectbound[i]; rectbound2[i] = rectbound[i];
rectbound2upd = -1; rectbound2upd = -1;
rectbound2upd2 = -1; rectbound2upd2 = -1;
backupowner = NONE; backupowner = NONE;
InitiateDraggingIfTransformMode(); InitiateDraggingIfTransformMode();
if (maxx - minx < 5 || maxy - miny < 5) if (maxx - minx < 5 || maxy - miny < 5)
isshapetransformable = false; isshapetransformable = false;
} }
} }
RefreshUndocmds(); RefreshUndocmds();
m_frame->UpdateFrameUI(); m_frame->UpdateFrameUI();
} }
void ASSDrawCanvas::SetDragMode( DRAGMODE mode ) void ASSDrawCanvas::SetDragMode( DRAGMODE mode )
@ -271,8 +271,8 @@ void ASSDrawCanvas::SetDragMode( DRAGMODE mode )
} }
bool ASSDrawCanvas::IsTransformMode() bool ASSDrawCanvas::IsTransformMode()
{ {
return draw_mode == MODE_NUT_BILINEAR || draw_mode == MODE_SCALEROTATE; return draw_mode == MODE_NUT_BILINEAR || draw_mode == MODE_SCALEROTATE;
} }
bool ASSDrawCanvas::CanZoom() bool ASSDrawCanvas::CanZoom()
@ -319,14 +319,14 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
if (rectbound2upd2 == -1) //only one vertex dragged if (rectbound2upd2 == -1) //only one vertex dragged
{ {
int adjacent[2] = { (rectbound2upd + 3) % 4, (rectbound2upd + 1) % 4 }; int adjacent[2] = { (rectbound2upd + 3) % 4, (rectbound2upd + 1) % 4 };
int opposite = (rectbound2upd + 2) % 4; int opposite = (rectbound2upd + 2) % 4;
wxRealPoint newpoint = backup[rectbound2upd] + rdiff; wxRealPoint newpoint = backup[rectbound2upd] + rdiff;
//wxPoint newadjacent[2]; //wxPoint newadjacent[2];
double nx, ny; double nx, ny;
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
bool isect = agg::calc_intersection( bool isect = agg::calc_intersection(
backup[opposite].x, backup[opposite].y, backup[opposite].x, backup[opposite].y,
backup[adjacent[i]].x, backup[adjacent[i]].y, backup[adjacent[i]].x, backup[adjacent[i]].y,
newpoint.x, newpoint.y, newpoint.x, newpoint.y,
backup[adjacent[i]].x + diff.x, backup[adjacent[i]].y + diff.y, backup[adjacent[i]].x + diff.x, backup[adjacent[i]].y + diff.y,
@ -334,9 +334,9 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
if (isect && !(fabs(nx - backup[opposite].x) < 10 && fabs(ny - backup[opposite].y) < 10)) if (isect && !(fabs(nx - backup[opposite].x) < 10 && fabs(ny - backup[opposite].y) < 10))
rectbound2[adjacent[i]] = wxRealPoint(nx, ny); rectbound2[adjacent[i]] = wxRealPoint(nx, ny);
} }
GetThe4thPoint(backup[opposite].x, backup[opposite].y, GetThe4thPoint(backup[opposite].x, backup[opposite].y,
rectbound2[adjacent[0]].x, rectbound2[adjacent[0]].y, rectbound2[adjacent[0]].x, rectbound2[adjacent[0]].y,
rectbound2[adjacent[1]].x, rectbound2[adjacent[1]].y, rectbound2[adjacent[1]].x, rectbound2[adjacent[1]].y,
&rectbound2[rectbound2upd].x, &rectbound2[rectbound2upd].y); &rectbound2[rectbound2upd].x, &rectbound2[rectbound2upd].y);
if (event.ShiftDown()) // shift down = maintain aspect ratio (damn so complicated) if (event.ShiftDown()) // shift down = maintain aspect ratio (damn so complicated)
{ {
@ -406,7 +406,7 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
undodesc = _T("Scale"); undodesc = _T("Scale");
break; break;
} }
// update points // update points
UpdateNonUniformTransformation(); UpdateNonUniformTransformation();
RefreshDisplay(); RefreshDisplay();
@ -416,21 +416,21 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
{ {
// point left-dragged // point left-dragged
if (mousedownAt_point != NULL && mousedownAt_point->isselected) if (mousedownAt_point != NULL && mousedownAt_point->isselected)
{ {
if (!mousedownAt_point->IsAt( wx, wy )) if (!mousedownAt_point->IsAt( wx, wy ))
{ {
if (draw_mode == MODE_ARR) { if (draw_mode == MODE_ARR) {
int movex = wx - mousedownAt_point->x(), movey = wy - mousedownAt_point->y(); int movex = wx - mousedownAt_point->x(), movey = wy - mousedownAt_point->y();
PointSet::iterator iter = selected_points.begin(); PointSet::iterator iter = selected_points.begin();
for (; iter != selected_points.end(); iter++) for (; iter != selected_points.end(); iter++)
(*iter)->setXY( (*iter)->x() + movex, (*iter)->y() + movey ); (*iter)->setXY( (*iter)->x() + movex, (*iter)->y() + movey );
} }
else else
mousedownAt_point->setXY( wx, wy ); mousedownAt_point->setXY( wx, wy );
EnforceC1Continuity (mousedownAt_point->cmd_main, mousedownAt_point); EnforceC1Continuity (mousedownAt_point->cmd_main, mousedownAt_point);
RefreshDisplay(); RefreshDisplay();
if (undodesc == _T("")) if (undodesc == _T(""))
{ {
@ -440,9 +440,9 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
undodesc = _T("Drag control point"); undodesc = _T("Drag control point");
} }
} }
} }
// origin left-dragged // origin left-dragged
else if (dragOrigin) else if (dragOrigin)
{ {
if (wx != 0 || wy != 0) if (wx != 0 || wy != 0)
{ {
@ -452,7 +452,7 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
pointsys->originy = wxp.y; pointsys->originy = wxp.y;
RefreshDisplay(); RefreshDisplay();
undodesc = _T("Move origin"); undodesc = _T("Move origin");
} }
} }
else if (dragAnchor_left != NULL) else if (dragAnchor_left != NULL)
{ {
@ -500,15 +500,15 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
undodesc = _T("Rotate"); undodesc = _T("Rotate");
} }
} }
else if (CanMove()) else if (CanMove())
{ {
MoveCanvas(xx - dragAnchor_right->x, yy - dragAnchor_right->y); MoveCanvas(xx - dragAnchor_right->x, yy - dragAnchor_right->y);
dragAnchor_right->x = xx; dragAnchor_right->x = xx;
dragAnchor_right->y = yy; dragAnchor_right->y = yy;
RefreshDisplay(); RefreshDisplay();
} }
} }
} }
else if (!preview_mode)// not dragging and not preview mode else if (!preview_mode)// not dragging and not preview mode
{ {
if (IsTransformMode()) if (IsTransformMode())
@ -539,7 +539,7 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
mouse_point.x - pointsys->scale, mouse_point.y, mouse_point.x - pointsys->scale, mouse_point.y,
mouse_point.x + pointsys->scale, mouse_point.y, &ix, &iy); mouse_point.x + pointsys->scale, mouse_point.y, &ix, &iy);
intersect &= fabs(mouse_point.x - ix) <= pointsys->scale; intersect &= fabs(mouse_point.x - ix) <= pointsys->scale;
intersect &= (pj.y > pi.y? intersect &= (pj.y > pi.y?
pj.y - dy3 > iy && iy > pi.y + dy3: pj.y - dy3 > iy && iy > pi.y + dy3:
pj.y + dy3 < iy && iy < pi.y - dy3); pj.y + dy3 < iy && iy < pi.y - dy3);
} }
@ -550,7 +550,7 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
mouse_point.x, mouse_point.y - pointsys->scale, mouse_point.x, mouse_point.y - pointsys->scale,
mouse_point.x, mouse_point.y + pointsys->scale, &ix, &iy); mouse_point.x, mouse_point.y + pointsys->scale, &ix, &iy);
intersect &= fabs(mouse_point.y - iy) <= pointsys->scale; intersect &= fabs(mouse_point.y - iy) <= pointsys->scale;
intersect &= (pj.x > pi.x? intersect &= (pj.x > pi.x?
pj.x - dx3 > ix && ix > pi.x + dx3: pj.x - dx3 > ix && ix > pi.x + dx3:
pj.x + dx3 < ix && ix < pi.x - dx3); pj.x + dx3 < ix && ix < pi.x - dx3);
} }
@ -569,14 +569,14 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
we need not do this for dragging since this same block has set we need not do this for dragging since this same block has set
the related variables before the user starts to hold the button the related variables before the user starts to hold the button
(well, before you can drag something you have to move the pointer (well, before you can drag something you have to move the pointer
over that thing first, right?) and we don't want to mess with those over that thing first, right?) and we don't want to mess with those
when it's dragging when it's dragging
*/ */
// check if mouse points on any control point first // check if mouse points on any control point first
Point* last_pointedAt_point = pointedAt_point; Point* last_pointedAt_point = pointedAt_point;
ControlAt( wx, wy, pointedAt_point ); ControlAt( wx, wy, pointedAt_point );
// then check if mouse points on any m_points // then check if mouse points on any m_points
// override any control point set to pointedAt_point above // override any control point set to pointedAt_point above
DrawCmd* p = PointAt( wx, wy ); DrawCmd* p = PointAt( wx, wy );
@ -584,7 +584,7 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
{ {
pointedAt_point = p->m_point; pointedAt_point = p->m_point;
} }
if (pointedAt_point != last_pointedAt_point) if (pointedAt_point != last_pointedAt_point)
{ {
if (pointedAt_point != NULL) if (pointedAt_point != NULL)
@ -600,9 +600,9 @@ void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
// oh yeah, we need to set the status bar just for fun // oh yeah, we need to set the status bar just for fun
if (hasStatusBar) if (hasStatusBar)
{ {
m_frame->SetStatusText( m_frame->SetStatusText(
wxString::Format( _T("%5d %5d"), (int)wx, (int)wy ), 0 ); wxString::Format( _T("%5d %5d"), (int)wx, (int)wy ), 0 );
if (pointedAt_point == NULL || if (pointedAt_point == NULL ||
(newcommand != NULL && !newcommand->initialized) ) (newcommand != NULL && !newcommand->initialized) )
m_frame->SetStatusText( _T(""), 1 ); m_frame->SetStatusText( _T(""), 1 );
else else
@ -621,9 +621,9 @@ void ASSDrawCanvas::OnMouseLeftUp(wxMouseEvent& event)
void ASSDrawCanvas::ProcessOnMouseLeftUp() void ASSDrawCanvas::ProcessOnMouseLeftUp()
{ {
if (!capturemouse_left) return; if (!capturemouse_left) return;
// draw mode // draw mode
if (newcommand != NULL) if (newcommand != NULL)
{ {
newcommand->Init(); newcommand->Init();
switch (newcommand->type) switch (newcommand->type)
@ -668,8 +668,8 @@ void ASSDrawCanvas::ProcessOnMouseLeftUp()
else else
{ {
RefreshDisplay(); // redraw before showing the error box RefreshDisplay(); // redraw before showing the error box
wxMessageDialog msgb(m_frame, wxMessageDialog msgb(m_frame,
_T("You must delete that command/point last"), _T("You must delete that command/point last"),
_T("Error"), wxOK | wxICON_EXCLAMATION ); _T("Error"), wxOK | wxICON_EXCLAMATION );
msgb.ShowModal(); msgb.ShowModal();
} }
@ -678,11 +678,11 @@ void ASSDrawCanvas::ProcessOnMouseLeftUp()
{ {
if (lastDrag_left && dragAnchor_left != lastDrag_left) if (lastDrag_left && dragAnchor_left != lastDrag_left)
delete lastDrag_left; delete lastDrag_left;
delete dragAnchor_left; delete dragAnchor_left;
lastDrag_left = NULL; lastDrag_left = NULL;
dragAnchor_left = NULL; dragAnchor_left = NULL;
} }
if (dragOrigin) if (dragOrigin)
{ {
dragOrigin = false; dragOrigin = false;
@ -705,7 +705,7 @@ void ASSDrawCanvas::ProcessOnMouseLeftUp()
if (HasCapture()) if (HasCapture())
ReleaseMouse(); ReleaseMouse();
capturemouse_left = false; capturemouse_left = false;
RefreshDisplay(); RefreshDisplay();
} }
@ -722,7 +722,7 @@ void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent& event)
// wxPoint to Point // wxPoint to Point
int px, py; int px, py;
pointsys->FromWxPoint(q, px, py); pointsys->FromWxPoint(q, px, py);
// create new cmd if in draw mode / or delete point if del tool selected // create new cmd if in draw mode / or delete point if del tool selected
switch (draw_mode) switch (draw_mode)
{ {
@ -748,11 +748,11 @@ void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent& event)
delete newcommand; delete newcommand;
newcommand = NULL; newcommand = NULL;
} }
else else
{ {
// first set to drag the new command no matter what // first set to drag the new command no matter what
mousedownAt_point = newcommand->m_point; mousedownAt_point = newcommand->m_point;
// if user drags from existing point, insert the new command // if user drags from existing point, insert the new command
// else append the new command // else append the new command
if (pointedAt_point != NULL) if (pointedAt_point != NULL)
@ -765,10 +765,10 @@ void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent& event)
} }
pointedAt_point = mousedownAt_point; pointedAt_point = mousedownAt_point;
//highlight it //highlight it
SetHighlighted( newcommand, newcommand->m_point ); SetHighlighted( newcommand, newcommand->m_point );
} }
} }
// we already calculated pointedAt_point in OnMouseMove() so just use it // we already calculated pointedAt_point in OnMouseMove() so just use it
@ -802,7 +802,7 @@ void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent& event)
if (InitiateDraggingIfTransformMode()) if (InitiateDraggingIfTransformMode())
backupowner = LEFT; backupowner = LEFT;
CaptureMouse(); CaptureMouse();
capturemouse_left = true; capturemouse_left = true;
RefreshDisplay(); RefreshDisplay();
@ -882,7 +882,7 @@ void ASSDrawCanvas::OnMouseRightDClick(wxMouseEvent& event)
f.SetWeight(wxFONTWEIGHT_BOLD); f.SetWeight(wxFONTWEIGHT_BOLD);
cmdmenuitem->SetFont(f); cmdmenuitem->SetFont(f);
#endif #endif
menu->Append(cmdmenuitem); menu->Append(cmdmenuitem);
menu->Enable(MENU_DUMMY, false); menu->Enable(MENU_DUMMY, false);
switch (dblclicked_point_right->cmd_main->type) switch (dblclicked_point_right->cmd_main->type)
{ {
@ -944,9 +944,9 @@ void ASSDrawCanvas::UpdateTranformModeRectCenter()
double cx, cy; double cx, cy;
if (agg::calc_intersection(rectbound2[0].x, rectbound2[0].y, rectbound2[2].x, rectbound2[2].y, if (agg::calc_intersection(rectbound2[0].x, rectbound2[0].y, rectbound2[2].x, rectbound2[2].y,
rectbound2[1].x, rectbound2[1].y, rectbound2[3].x, rectbound2[3].y, &cx, &cy)) rectbound2[1].x, rectbound2[1].y, rectbound2[3].x, rectbound2[3].y, &cx, &cy))
{ {
rectcenter = wxRealPoint(cx, cy); rectcenter = wxRealPoint(cx, cy);
} }
} }
bool ASSDrawCanvas::GetThe4thPoint(double ox, double oy, double a1x, double a1y, double a2x, double a2y, double *x, double *y) bool ASSDrawCanvas::GetThe4thPoint(double ox, double oy, double a1x, double a1y, double a2x, double a2y, double *x, double *y)
@ -959,7 +959,7 @@ bool ASSDrawCanvas::GetThe4thPoint(double ox, double oy, double a1x, double a1y,
a1x + a2x - ox, a1x + a2x - ox,
a1y + a2y - oy, a1y + a2y - oy,
x, y); //*/ x, y); //*/
*x = a1x + a2x - ox; *x = a1x + a2x - ox;
*y = a1y + a2y - oy; *y = a1y + a2y - oy;
return true; return true;
@ -991,7 +991,7 @@ void ASSDrawCanvas::ChangeZoomLevel( double amount, wxPoint bgzoomctr )
case DRAG_BOTH: case DRAG_BOTH:
ChangeDrawingZoomLevel( amount ); ChangeDrawingZoomLevel( amount );
ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale, ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale,
wxRealPoint(pointsys->originx, pointsys->originy)); wxRealPoint(pointsys->originx, pointsys->originy));
break; break;
@ -1000,7 +1000,7 @@ void ASSDrawCanvas::ChangeZoomLevel( double amount, wxPoint bgzoomctr )
break; break;
} }
*/ */
if (CanZoom() && drag_mode.drawing) if (CanZoom() && drag_mode.drawing)
ChangeDrawingZoomLevel( amount ); ChangeDrawingZoomLevel( amount );
@ -1009,7 +1009,7 @@ void ASSDrawCanvas::ChangeZoomLevel( double amount, wxPoint bgzoomctr )
ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale, wxRealPoint(pointsys->originx, pointsys->originy)); ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale, wxRealPoint(pointsys->originx, pointsys->originy));
else else
ChangeBackgroundZoomLevel(bgimg.scale + amount / 10.0, wxRealPoint(bgzoomctr.x, bgzoomctr.y)); ChangeBackgroundZoomLevel(bgimg.scale + amount / 10.0, wxRealPoint(bgzoomctr.x, bgzoomctr.y));
RefreshDisplay(); RefreshDisplay();
} }
@ -1022,7 +1022,7 @@ void ASSDrawCanvas::ChangeDrawingZoomLevel( double scrollamount )
if (zoom < 1.0) zoom = 1.0; if (zoom < 1.0) zoom = 1.0;
pointsys->scale = zoom; pointsys->scale = zoom;
} }
m_frame->UpdateFrameUI(); m_frame->UpdateFrameUI();
} }
@ -1031,7 +1031,7 @@ void ASSDrawCanvas::ChangeBackgroundZoomLevel(double zoom, wxRealPoint newcenter
bgimg.new_scale = zoom; bgimg.new_scale = zoom;
bgimg.new_center = newcenter; bgimg.new_center = newcenter;
if (bgimg.new_scale < 0.01) bgimg.new_scale = 0.01; if (bgimg.new_scale < 0.01) bgimg.new_scale = 0.01;
UpdateBackgroundImgScalePosition(); UpdateBackgroundImgScalePosition();
} }
void ASSDrawCanvas::MoveCanvasOriginTo(double originx, double originy) void ASSDrawCanvas::MoveCanvasOriginTo(double originx, double originy)
@ -1057,7 +1057,7 @@ void ASSDrawCanvas::MoveCanvasDrawing(double xamount, double yamount)
{ {
if (!CanMove()) return; if (!CanMove()) return;
pointsys->originx += xamount; pointsys->originx += xamount;
pointsys->originy += yamount; pointsys->originy += yamount;
if (IsTransformMode()) if (IsTransformMode())
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -1082,14 +1082,14 @@ void ASSDrawCanvas::MoveCanvasBackground(double xamount, double yamount)
//bgimg.new_center.x += xamount, bgimg.new_center.y += yamount; //bgimg.new_center.x += xamount, bgimg.new_center.y += yamount;
bgimg.new_disp.x += xamount; bgimg.new_disp.x += xamount;
bgimg.new_disp.y += yamount; bgimg.new_disp.y += yamount;
UpdateBackgroundImgScalePosition(); UpdateBackgroundImgScalePosition();
} }
void ASSDrawCanvas::OnSelect_ConvertLineToBezier(wxCommandEvent& WXUNUSED(event)) void ASSDrawCanvas::OnSelect_ConvertLineToBezier(wxCommandEvent& WXUNUSED(event))
{ {
if (!dblclicked_point_right) return; if (!dblclicked_point_right) return;
AddUndo( _T("Convert Line to Bezier") ); AddUndo( _T("Convert Line to Bezier") );
DrawCmd_B *newB = new DrawCmd_B(dblclicked_point_right->x(), dblclicked_point_right->y(), DrawCmd_B *newB = new DrawCmd_B(dblclicked_point_right->x(), dblclicked_point_right->y(),
pointsys, dblclicked_point_right->cmd_main); pointsys, dblclicked_point_right->cmd_main);
InsertCmd ( newB, dblclicked_point_right->cmd_main ); InsertCmd ( newB, dblclicked_point_right->cmd_main );
ClearPointsSelection(); ClearPointsSelection();
@ -1168,7 +1168,7 @@ void ASSDrawCanvas::EnforceC1Continuity (DrawCmd* cmd, Point* pnt)
{ {
DrawCmd_B *thisb = static_cast< DrawCmd_B* >(cmd); DrawCmd_B *thisb = static_cast< DrawCmd_B* >(cmd);
if (!thisb->C1Cont) return; if (!thisb->C1Cont) return;
theotherpoint = *(cmd->m_point->cmd_next->controlpoints.begin()); theotherpoint = *(cmd->m_point->cmd_next->controlpoints.begin());
mainpoint = thisb->m_point; mainpoint = thisb->m_point;
} }
else else
@ -1178,7 +1178,7 @@ void ASSDrawCanvas::EnforceC1Continuity (DrawCmd* cmd, Point* pnt)
} }
// Undo/Redo system // Undo/Redo system
void ASSDrawCanvas::AddUndo( wxString desc ) void ASSDrawCanvas::AddUndo( wxString desc )
{ {
PrepareUndoRedo(_undo, false, _T(""), desc); PrepareUndoRedo(_undo, false, _T(""), desc);
undos.push_back( _undo ); undos.push_back( _undo );
@ -1198,7 +1198,7 @@ bool ASSDrawCanvas::UndoOrRedo(bool isundo)
UndoRedo r = main->back(); UndoRedo r = main->back();
// push into sub // push into sub
UndoRedo nr(r); UndoRedo nr(r);
PrepareUndoRedo(nr, true, GenerateASS(), r.desc); PrepareUndoRedo(nr, true, GenerateASS(), r.desc);
//PrepareUndoRedo(nr, false, _T(""), r.desc); //PrepareUndoRedo(nr, false, _T(""), r.desc);
sub->push_back( nr ); sub->push_back( nr );
// parse // parse
@ -1249,10 +1249,10 @@ void ASSDrawCanvas::RefreshUndocmds()
_undo.Import(this, true, GenerateASS()); _undo.Import(this, true, GenerateASS());
} }
void ASSDrawCanvas::PrepareUndoRedo(UndoRedo& ur, bool prestage, wxString cmds, wxString desc) void ASSDrawCanvas::PrepareUndoRedo(UndoRedo& ur, bool prestage, wxString cmds, wxString desc)
{ {
ur.Import(this, prestage, cmds); ur.Import(this, prestage, cmds);
ur.desc = desc; ur.desc = desc;
} }
// set command and point to highlight // set command and point to highlight
@ -1290,7 +1290,7 @@ int ASSDrawCanvas::SelectPointsWithin( int lx, int rx, int ty, int by, SELECTMOD
(*pnt_iterator)->isselected = (smode != DEL); (*pnt_iterator)->isselected = (smode != DEL);
else else
(*pnt_iterator)->isselected &= (smode != NEW); (*pnt_iterator)->isselected &= (smode != NEW);
if ((*pnt_iterator)->isselected) if ((*pnt_iterator)->isselected)
selected_points.insert(*pnt_iterator); selected_points.insert(*pnt_iterator);
else else
@ -1331,7 +1331,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
int ww, hh; GetClientSize(&ww, &hh); int ww, hh; GetClientSize(&ww, &hh);
if (bgimg.bgbmp) if (bgimg.bgbmp)
{ {
rasterizer.reset(); rasterizer.reset();
interpolator_type interpolator(bgimg.img_mtx); interpolator_type interpolator(bgimg.img_mtx);
PixelFormat::AGGType ipixfmt(bgimg.ibuf); PixelFormat::AGGType ipixfmt(bgimg.ibuf);
@ -1344,7 +1344,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
} }
ASSDrawEngine::Draw_Draw( rbase, rprim, rsolid, mtx, preview_mode? rgba_shape:rgba_shape_normal ); ASSDrawEngine::Draw_Draw( rbase, rprim, rsolid, mtx, preview_mode? rgba_shape:rgba_shape_normal );
if (!preview_mode) if (!preview_mode)
{ {
// [0, 0] // [0, 0]
@ -1395,14 +1395,14 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rasterizer.add_path(chstroke); rasterizer.add_path(chstroke);
if (rectbound2upd != -1) if (rectbound2upd != -1)
{ {
agg::ellipse circ(rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y, agg::ellipse circ(rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y,
pointsys->scale, pointsys->scale); pointsys->scale, pointsys->scale);
agg::conv_contour< agg::ellipse > c(circ); agg::conv_contour< agg::ellipse > c(circ);
rasterizer.add_path(c); rasterizer.add_path(c);
} }
if (rectbound2upd2 != -1) if (rectbound2upd2 != -1)
{ {
agg::ellipse circ(rectbound2[rectbound2upd2].x, rectbound2[rectbound2upd2].y, agg::ellipse circ(rectbound2[rectbound2upd2].x, rectbound2[rectbound2upd2].y,
pointsys->scale, pointsys->scale); pointsys->scale, pointsys->scale);
agg::conv_contour< agg::ellipse > c(circ); agg::conv_contour< agg::ellipse > c(circ);
rasterizer.add_path(c); rasterizer.add_path(c);
@ -1417,13 +1417,13 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rsolid.color(rgba_guideline); rsolid.color(rgba_guideline);
rasterizer.add_path(bguidestroke); rasterizer.add_path(bguidestroke);
render_scanlines(rsolid); render_scanlines(rsolid);
agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage > > > stroke(*rm_curve); agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage > > > stroke(*rm_curve);
stroke.width(1); stroke.width(1);
rsolid.color(rgba_outline); rsolid.color(rgba_outline);
rasterizer.add_path(stroke); rasterizer.add_path(stroke);
render_scanlines(rsolid); render_scanlines(rsolid);
double diameter = pointsys->scale; double diameter = pointsys->scale;
double radius = diameter / 2.0; double radius = diameter / 2.0;
// hilite // hilite
@ -1442,7 +1442,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rasterizer.add_path(stroke); rasterizer.add_path(stroke);
render_scanlines(rsolid); render_scanlines(rsolid);
} }
// m_point // m_point
rasterizer.reset(); rasterizer.reset();
DrawCmdList::iterator ci = cmds.begin(); DrawCmdList::iterator ci = cmds.begin();
@ -1456,7 +1456,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
ci++; ci++;
} }
render_scanlines_aa_solid(rbase, rgba_mainpoint); render_scanlines_aa_solid(rbase, rgba_mainpoint);
// control_points // control_points
rasterizer.reset(); rasterizer.reset();
ci = cmds.begin(); ci = cmds.begin();
@ -1465,7 +1465,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
PointList::iterator pi = (*ci)->controlpoints.begin(); PointList::iterator pi = (*ci)->controlpoints.begin();
while (pi != (*ci)->controlpoints.end()) while (pi != (*ci)->controlpoints.end())
{ {
agg::ellipse circ((*pi)->x() * pointsys->scale + pointsys->originx, agg::ellipse circ((*pi)->x() * pointsys->scale + pointsys->originx,
(*pi)->y() * pointsys->scale + pointsys->originy, radius, radius); (*pi)->y() * pointsys->scale + pointsys->originy, radius, radius);
agg::conv_contour< agg::ellipse > c(circ); agg::conv_contour< agg::ellipse > c(circ);
rasterizer.add_path(c); rasterizer.add_path(c);
@ -1474,31 +1474,31 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
ci++; ci++;
} }
render_scanlines_aa_solid(rbase, rgba_controlpoint); render_scanlines_aa_solid(rbase, rgba_controlpoint);
// selection // selection
rasterizer.reset(); rasterizer.reset();
PointSet::iterator si = selected_points.begin(); PointSet::iterator si = selected_points.begin();
while (si != selected_points.end()) while (si != selected_points.end())
{ {
agg::ellipse circ((*si)->x() * pointsys->scale + pointsys->originx, agg::ellipse circ((*si)->x() * pointsys->scale + pointsys->originx,
(*si)->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3); (*si)->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
agg::conv_stroke< agg::ellipse > s(circ); agg::conv_stroke< agg::ellipse > s(circ);
rasterizer.add_path(s); rasterizer.add_path(s);
si++; si++;
} }
render_scanlines_aa_solid(rbase, rgba_selectpoint); render_scanlines_aa_solid(rbase, rgba_selectpoint);
// hover // hover
if (hilite_point) if (hilite_point)
{ {
rasterizer.reset(); rasterizer.reset();
agg::ellipse circ(hilite_point->x() * pointsys->scale + pointsys->originx, agg::ellipse circ(hilite_point->x() * pointsys->scale + pointsys->originx,
hilite_point->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3); hilite_point->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
agg::conv_stroke< agg::ellipse > s(circ); agg::conv_stroke< agg::ellipse > s(circ);
s.width(2); s.width(2);
rasterizer.add_path(s); rasterizer.add_path(s);
render_scanlines_aa_solid(rbase, rgba_selectpoint); render_scanlines_aa_solid(rbase, rgba_selectpoint);
rasterizer.reset(); rasterizer.reset();
agg::gsv_text t; agg::gsv_text t;
t.flip(true); t.flip(true);
@ -1513,7 +1513,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rasterizer.add_path(pt); rasterizer.add_path(pt);
rsolid.color(agg::rgba(0,0,0)); rsolid.color(agg::rgba(0,0,0));
render_scanlines(rsolid, false); render_scanlines(rsolid, false);
rasterizer.reset(); rasterizer.reset();
agg::path_storage sb_path; agg::path_storage sb_path;
sb_path.move_to(pxy.x, 0); sb_path.move_to(pxy.x, 0);
@ -1529,7 +1529,7 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rasterizer.add_path(stroke); rasterizer.add_path(stroke);
render_scanlines(rsolid); render_scanlines(rsolid);
} }
// selection box // selection box
if (lastDrag_left) if (lastDrag_left)
{ {
@ -1551,9 +1551,9 @@ void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, Rend
rasterizer.add_path(stroke); rasterizer.add_path(stroke);
render_scanlines(rsolid); render_scanlines(rsolid);
} }
} }
} }
// ruler // ruler
int w, h; int w, h;
GetClientSize( &w, &h ); GetClientSize( &w, &h );
@ -1688,7 +1688,7 @@ void ASSDrawCanvas::AskUserForBackgroundAlpha()
bgimg.alpha_dlg->Show(); bgimg.alpha_dlg->Show();
SetFocus(); SetFocus();
} }
void ASSDrawCanvas::PrepareBackgroundBitmap(double alpha) void ASSDrawCanvas::PrepareBackgroundBitmap(double alpha)
{ {
if (alpha >= 0.0 && alpha <= 1.0) bgimg.alpha = alpha; if (alpha >= 0.0 && alpha <= 1.0) bgimg.alpha = alpha;
@ -1701,7 +1701,7 @@ void ASSDrawCanvas::PrepareBackgroundBitmap(double alpha)
if (stride < 0) if (stride < 0)
pd += (data.GetHeight() - 1) * stride; pd += (data.GetHeight() - 1) * stride;
bgimg.ibuf.attach(pd, data.GetWidth(), data.GetHeight(), stride); bgimg.ibuf.attach(pd, data.GetWidth(), data.GetHeight(), stride);
// apply alpha // apply alpha
rasterizer.reset(); rasterizer.reset();
unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight(); unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
@ -1791,7 +1791,7 @@ void ASSDrawCanvas::UpdateNonUniformTransformation()
agg::path_storage trans; agg::path_storage trans;
unsigned vertices = backupcmds.total_vertices(); unsigned vertices = backupcmds.total_vertices();
double x, y; double x, y;
//if (draw_mode == MODE_NUT_BILINEAR) //if (draw_mode == MODE_NUT_BILINEAR)
//{ //{
agg::trans_bilinear trans_b(rectbound[0].x, rectbound[0].y, rectbound[2].x, rectbound[2].y, bound); agg::trans_bilinear trans_b(rectbound[0].x, rectbound[0].y, rectbound[2].x, rectbound[2].y, bound);
@ -1833,14 +1833,14 @@ void ASSDrawCanvas::UpdateNonUniformTransformation()
pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy ); pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy );
(*iterate)->m_point->setXY(wx, wy); (*iterate)->m_point->setXY(wx, wy);
} }
} }
void ASSDrawCanvas::CustomOnKeyDown(wxKeyEvent &event) void ASSDrawCanvas::CustomOnKeyDown(wxKeyEvent &event)
{ {
int keycode = event.GetKeyCode(); int keycode = event.GetKeyCode();
//m_frame->SetStatusText(wxString::Format(_T("Key: %d"), keycode)); //m_frame->SetStatusText(wxString::Format(_T("Key: %d"), keycode));
double scrollamount = (event.GetModifiers() == wxMOD_CMD? 10.0:1.0); double scrollamount = (event.GetModifiers() == wxMOD_CMD? 10.0:1.0);
if (event.GetModifiers() == wxMOD_SHIFT) if (event.GetModifiers() == wxMOD_SHIFT)
{ {
MODE d_mode = GetDrawMode(); MODE d_mode = GetDrawMode();
@ -1874,7 +1874,7 @@ void ASSDrawCanvas::CustomOnKeyDown(wxKeyEvent &event)
case WXK_LEFT: case WXK_LEFT:
MoveCanvas(-scrollamount, 0.0); MoveCanvas(-scrollamount, 0.0);
RefreshDisplay(); RefreshDisplay();
break; break;
case WXK_RIGHT: case WXK_RIGHT:
MoveCanvas(scrollamount, 0.0); MoveCanvas(scrollamount, 0.0);
RefreshDisplay(); RefreshDisplay();
@ -1905,8 +1905,8 @@ void ASSDrawCanvas::CustomOnKeyDown(wxKeyEvent &event)
{ {
nearest = (*it2); nearest = (*it2);
dist = distance; dist = distance;
} }
it2++; it2++;
} }
it++; it++;
} }
@ -1999,7 +1999,7 @@ void UndoRedo::Import(ASSDrawCanvas *canvas, bool prestage, wxString cmds)
this->originx = canvas->pointsys->originx; this->originx = canvas->pointsys->originx;
this->originy = canvas->pointsys->originy; this->originy = canvas->pointsys->originy;
this->scale = canvas->pointsys->scale; this->scale = canvas->pointsys->scale;
this->bgimgfile = canvas->bgimg.bgimgfile; this->bgimgfile = canvas->bgimg.bgimgfile;
this->bgdisp = canvas->bgimg.disp; this->bgdisp = canvas->bgimg.disp;
this->bgcenter = canvas->bgimg.center; this->bgcenter = canvas->bgimg.center;
@ -2038,8 +2038,8 @@ void UndoRedo::Export(ASSDrawCanvas *canvas)
canvas->bgimg.new_disp = this->bgdisp; canvas->bgimg.new_disp = this->bgdisp;
canvas->bgimg.alpha = this->bgalpha; canvas->bgimg.alpha = this->bgalpha;
canvas->UpdateBackgroundImgScalePosition(); canvas->UpdateBackgroundImgScalePosition();
} }
//canvas->SetDrawMode(this->draw_mode); //canvas->SetDrawMode(this->draw_mode);
canvas->draw_mode = this->draw_mode; canvas->draw_mode = this->draw_mode;

View file

@ -40,8 +40,8 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constructor // constructor
DrawCmd_M::DrawCmd_M ( int x, int y, PointSystem *ps, DrawCmd *prev ) DrawCmd_M::DrawCmd_M ( int x, int y, PointSystem *ps, DrawCmd *prev )
: DrawCmd ( x, y, ps, prev ) : DrawCmd ( x, y, ps, prev )
{ {
type = M; type = M;
} }
@ -59,8 +59,8 @@ wxString DrawCmd_M::ToString()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constructor // constructor
DrawCmd_L::DrawCmd_L ( int x, int y, PointSystem *ps, DrawCmd *prev ) DrawCmd_L::DrawCmd_L ( int x, int y, PointSystem *ps, DrawCmd *prev )
: DrawCmd ( x, y, ps, prev ) : DrawCmd ( x, y, ps, prev )
{ {
type = L; type = L;
} }
@ -78,9 +78,9 @@ wxString DrawCmd_L::ToString()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constructor // constructor
DrawCmd_B::DrawCmd_B DrawCmd_B::DrawCmd_B
( int x, int y, int x1, int y1, int x2, int y2, PointSystem *ps, DrawCmd *prev ) ( int x, int y, int x1, int y1, int x2, int y2, PointSystem *ps, DrawCmd *prev )
: DrawCmd ( x, y, ps, prev ) : DrawCmd ( x, y, ps, prev )
{ {
type = B; type = B;
controlpoints.push_back( new Point(x1, y1, ps, CP, this, 1) ); controlpoints.push_back( new Point(x1, y1, ps, CP, this, 1) );
@ -90,8 +90,8 @@ DrawCmd_B::DrawCmd_B
} }
// constructor // constructor
DrawCmd_B::DrawCmd_B ( int x, int y, PointSystem *ps, DrawCmd *prev ) DrawCmd_B::DrawCmd_B ( int x, int y, PointSystem *ps, DrawCmd *prev )
: DrawCmd ( x, y, ps, prev ) : DrawCmd ( x, y, ps, prev )
{ {
type = B; type = B;
initialized = false; initialized = false;
@ -106,8 +106,8 @@ void DrawCmd_B::Init ( unsigned n )
wxPoint wx0 = prev->m_point->ToWxPoint(); wxPoint wx0 = prev->m_point->ToWxPoint();
wxPoint wx1 = m_point->ToWxPoint(); wxPoint wx1 = m_point->ToWxPoint();
int xdiff = (wx1.x - wx0.x) / 3; int xdiff = (wx1.x - wx0.x) / 3;
int ydiff = (wx1.y - wx0.y) / 3; int ydiff = (wx1.y - wx0.y) / 3;
int xg, yg; int xg, yg;
// first control // first control
@ -119,7 +119,7 @@ void DrawCmd_B::Init ( unsigned n )
controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) ); controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) );
initialized = true; initialized = true;
} }
// to ASS drawing command // to ASS drawing command
@ -203,7 +203,7 @@ wxString DrawCmd_S::ToString()
for (; iterate != controlpoints.end(); iterate++) for (; iterate != controlpoints.end(); iterate++)
{ {
if (initialized) if (initialized)
assout = wxString::Format(_T("%s %d %d"), assout.c_str(), (*iterate)->x(), (*iterate)->y()); assout = wxString::Format(_T("%s %d %d"), assout.c_str(), (*iterate)->x(), (*iterate)->y());
else else
assout = wxString::Format(_T("%s ? ?"), assout.c_str()); assout = wxString::Format(_T("%s ? ?"), assout.c_str());
} }

View file

@ -74,7 +74,7 @@ void ASSDrawSrcTxtCtrl::CustomOnChar(wxKeyEvent &event)
//m_frame->SetTitle(wxString::Format(_T("Key: %d"), event.GetKeyCode())); //m_frame->SetTitle(wxString::Format(_T("Key: %d"), event.GetKeyCode()));
event.Skip(true); event.Skip(true);
} }
//SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE); //SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE);
} }
@ -257,13 +257,13 @@ Control points for Bezier curves are generated once you release the mouse button
</ul> \ </ul> \
<p>ai-chan recommends Aegisub for all your subtitle and typesetting needs! \ <p>ai-chan recommends Aegisub for all your subtitle and typesetting needs! \
</body></html>") </body></html>")
); );
htmlwin->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(ASSDrawAboutDlg::OnURL), NULL, this); htmlwin->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(ASSDrawAboutDlg::OnURL), NULL, this);
wxFlexGridSizer *sizer = new wxFlexGridSizer(1); wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
sizer->AddGrowableCol(0); sizer->AddGrowableCol(0);
//sizer->AddGrowableRow(1); //sizer->AddGrowableRow(1);
sizer->Add(new BigStaticBitmapCtrl(this, wxBITMAP(assdraw3_), *wxWHITE, this), 1, wxEXPAND); sizer->Add(new BigStaticBitmapCtrl(this, wxBITMAP(assdraw3_), *wxWHITE, this), 1, wxEXPAND);
sizer->Add(htmlwin, 1, wxLEFT | wxRIGHT, 2); sizer->Add(htmlwin, 1, wxLEFT | wxRIGHT, 2);
sizer->Add(new wxStaticText(this, wxID_ANY, wxString::Format(_T("Version: %s"), VERSION)), 1, wxEXPAND | wxALL, 2); sizer->Add(new wxStaticText(this, wxID_ANY, wxString::Format(_T("Version: %s"), VERSION)), 1, wxEXPAND | wxALL, 2);
@ -271,10 +271,10 @@ Control points for Bezier curves are generated once you release the mouse button
SetSizer(sizer); SetSizer(sizer);
sizer->Layout(); sizer->Layout();
sizer->Fit(this); sizer->Fit(this);
Center(); Center();
//if (CanSetTransparent()) SetTransparent(0xCC); //if (CanSetTransparent()) SetTransparent(0xCC);
timer.SetOwner(this); timer.SetOwner(this);
Connect(wxEVT_TIMER, wxTimerEventHandler(ASSDrawAboutDlg::OnTimeout)); Connect(wxEVT_TIMER, wxTimerEventHandler(ASSDrawAboutDlg::OnTimeout));
Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(ASSDrawAboutDlg::OnMouseEnterWindow)); Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(ASSDrawAboutDlg::OnMouseEnterWindow));
@ -282,7 +282,7 @@ Control points for Bezier curves are generated once you release the mouse button
ASSDrawAboutDlg::~ASSDrawAboutDlg() ASSDrawAboutDlg::~ASSDrawAboutDlg()
{ {
timer.Stop(); timer.Stop();
} }
int ASSDrawAboutDlg::ShowModal() int ASSDrawAboutDlg::ShowModal()
@ -311,7 +311,7 @@ void ASSDrawAboutDlg::OnMouseEnterWindow(wxMouseEvent& event)
{ {
// if mouse enters this dialog, stop the timout timer // if mouse enters this dialog, stop the timout timer
// and dialog will only close through user input // and dialog will only close through user input
timer.Stop(); timer.Stop();
} }
BEGIN_EVENT_TABLE(BigStaticBitmapCtrl, wxPanel) BEGIN_EVENT_TABLE(BigStaticBitmapCtrl, wxPanel)
@ -332,7 +332,7 @@ BigStaticBitmapCtrl::BigStaticBitmapCtrl(wxWindow *parent, wxBitmap bmap, wxColo
} }
BigStaticBitmapCtrl::~BigStaticBitmapCtrl() BigStaticBitmapCtrl::~BigStaticBitmapCtrl()
{ {
} }
void BigStaticBitmapCtrl::OnPaint(wxPaintEvent& event) void BigStaticBitmapCtrl::OnPaint(wxPaintEvent& event)
@ -354,7 +354,7 @@ void BigStaticBitmapCtrl::OnMouseLeftDown(wxMouseEvent &event)
void BigStaticBitmapCtrl::OnMouseLeftUp(wxMouseEvent &event) void BigStaticBitmapCtrl::OnMouseLeftUp(wxMouseEvent &event)
{ {
ReleaseMouse(); ReleaseMouse();
} }
void BigStaticBitmapCtrl::OnMouseMove(wxMouseEvent &event) void BigStaticBitmapCtrl::OnMouseMove(wxMouseEvent &event)

View file

@ -40,24 +40,24 @@
#include <stdio.h> #include <stdio.h>
#include <algorithm> #include <algorithm>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Point // Point
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constructor // constructor
Point::Point ( int _x, int _y, PointSystem* ps, POINTTYPE t, DrawCmd* cmd, unsigned n ) Point::Point ( int _x, int _y, PointSystem* ps, POINTTYPE t, DrawCmd* cmd, unsigned n )
{ {
x_ = _x; x_ = _x;
y_ = _y; y_ = _y;
pointsys = ps; pointsys = ps;
cmd_main = cmd; cmd_main = cmd;
cmd_next = NULL; cmd_next = NULL;
type = t; type = t;
isselected = false; isselected = false;
num = n; num = n;
} }
// setters // setters
void Point::setXY( int _x, int _y) void Point::setXY( int _x, int _y)
@ -67,11 +67,11 @@ void Point::setXY( int _x, int _y)
} }
// simply returns true if px and py are the coordinate values // simply returns true if px and py are the coordinate values
bool Point::IsAt( int px, int py ) bool Point::IsAt( int px, int py )
{ {
return (x_ == px && y_ == py ); return (x_ == px && y_ == py );
} }
// convert this point to wxPoint using scale and originx, originy // convert this point to wxPoint using scale and originx, originy
wxPoint Point::ToWxPoint ( bool useorigin ) wxPoint Point::ToWxPoint ( bool useorigin )
{ {
@ -80,9 +80,9 @@ wxPoint Point::ToWxPoint ( bool useorigin )
else else
return *(new wxPoint(x_ * (int) pointsys->scale, y_ * (int) pointsys->scale )); return *(new wxPoint(x_ * (int) pointsys->scale, y_ * (int) pointsys->scale ));
} }
// check if wxpoint is nearby this point // check if wxpoint is nearby this point
bool Point::CheckWxPoint ( wxPoint wxpoint ) bool Point::CheckWxPoint ( wxPoint wxpoint )
{ {
wxPoint p = ToWxPoint(); wxPoint p = ToWxPoint();
int cx, cy; int cx, cy;
@ -90,7 +90,7 @@ bool Point::CheckWxPoint ( wxPoint wxpoint )
//delete &p; //delete &p;
return (x_ == cx && y_ == cy ); return (x_ == cx && y_ == cy );
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -98,14 +98,14 @@ bool Point::CheckWxPoint ( wxPoint wxpoint )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constructor // constructor
DrawCmd::DrawCmd ( int x, int y, PointSystem *ps, DrawCmd *pv ) DrawCmd::DrawCmd ( int x, int y, PointSystem *ps, DrawCmd *pv )
{ {
m_point = new Point ( x, y, ps, MP, this ); m_point = new Point ( x, y, ps, MP, this );
m_point->cmd_main = this; m_point->cmd_main = this;
prev = pv; prev = pv;
dobreak = false; dobreak = false;
invisible = false; invisible = false;
} }
// destructor // destructor
DrawCmd::~DrawCmd ( ) DrawCmd::~DrawCmd ( )
@ -115,7 +115,7 @@ DrawCmd::~DrawCmd ( )
for (PointList::iterator iter_cpoint = controlpoints.begin(); for (PointList::iterator iter_cpoint = controlpoints.begin();
iter_cpoint != controlpoints.end(); iter_cpoint++) iter_cpoint != controlpoints.end(); iter_cpoint++)
delete (*iter_cpoint); delete (*iter_cpoint);
} }
@ -163,22 +163,22 @@ int ASSDrawEngine::ParseASS ( wxString str )
std::vector<int> val; std::vector<int> val;
wxString token; wxString token;
long tmp_int; long tmp_int;
bool n_collected = false; bool n_collected = false;
DrawCmd_S *s_command = NULL; DrawCmd_S *s_command = NULL;
wxPoint tmp_n_pnt; wxPoint tmp_n_pnt;
while ( tkz.HasMoreTokens() ) while ( tkz.HasMoreTokens() )
{ {
token = tkz.GetNextToken(); token = tkz.GetNextToken();
if ( drawcmdset.Find(token) > -1 ) if ( drawcmdset.Find(token) > -1 )
{ {
bool done; bool done;
do { do {
done = true; done = true;
// N // N
if (currcmd.IsSameAs(_T("n")) && val.size() >= 2) if (currcmd.IsSameAs(_T("n")) && val.size() >= 2)
{ {
@ -190,7 +190,7 @@ int ASSDrawEngine::ParseASS ( wxString str )
AppendCmd ( L, tmp_n_pnt.x, tmp_n_pnt.y ); AppendCmd ( L, tmp_n_pnt.x, tmp_n_pnt.y );
n_collected = false; n_collected = false;
} }
if (s_command != NULL) if (s_command != NULL)
{ {
bool ends = true; bool ends = true;
@ -208,14 +208,14 @@ int ASSDrawEngine::ParseASS ( wxString str )
if (ends) if (ends)
{ {
AppendCmd(s_command); AppendCmd(s_command);
s_command = NULL; s_command = NULL;
} }
} }
// M // M
if (currcmd.IsSameAs(_T("m")) && val.size() >= 2) if (currcmd.IsSameAs(_T("m")) && val.size() >= 2)
AppendCmd ( M, val[0], val[1] ); AppendCmd ( M, val[0], val[1] );
// L // L
if (currcmd.IsSameAs(_T("l")) && val.size() >= 2) if (currcmd.IsSameAs(_T("l")) && val.size() >= 2)
{ {
@ -225,7 +225,7 @@ int ASSDrawEngine::ParseASS ( wxString str )
if (val.size() >= 2) if (val.size() >= 2)
done = false; done = false;
} }
// B // B
if (currcmd.IsSameAs(_T("b")) && val.size() >= 6) if (currcmd.IsSameAs(_T("b")) && val.size() >= 6)
{ {
@ -236,7 +236,7 @@ int ASSDrawEngine::ParseASS ( wxString str )
if (val.size() >= 6) if (val.size() >= 6)
done = false; done = false;
} }
// S // S
if (currcmd.IsSameAs(_T("s")) && val.size() >= 6) if (currcmd.IsSameAs(_T("s")) && val.size() >= 6)
{ {
@ -250,16 +250,16 @@ int ASSDrawEngine::ParseASS ( wxString str )
} }
// more to come later // more to come later
} while (!done); } while (!done);
val.clear(); val.clear();
currcmd = token; currcmd = token;
} }
else if (token.ToLong( &tmp_int )) else if (token.ToLong( &tmp_int ))
{ {
val.push_back( (int) tmp_int ); val.push_back( (int) tmp_int );
} }
} }
return (int) cmds.size(); return (int) cmds.size();
} }
@ -408,7 +408,7 @@ void ASSDrawEngine::MovePoints ( int x, int y )
for (; iterate != cmds.end(); iterate++) for (; iterate != cmds.end(); iterate++)
{ {
(*iterate)->m_point->setXY( (*iterate)->m_point->x() + x, (*iterate)->m_point->y() + y ); (*iterate)->m_point->setXY( (*iterate)->m_point->x() + x, (*iterate)->m_point->y() + y );
for (iterate2 = (*iterate)->controlpoints.begin(); for (iterate2 = (*iterate)->controlpoints.begin();
iterate2 != (*iterate)->controlpoints.end(); iterate2++) iterate2 != (*iterate)->controlpoints.end(); iterate2++)
{ {
(*iterate2)->setXY( (*iterate2)->x() + x, (*iterate2)->y() + y ); (*iterate2)->setXY( (*iterate2)->x() + x, (*iterate2)->y() + y );
@ -487,13 +487,13 @@ DrawCmd* ASSDrawEngine::ControlAt ( int x, int y, Point* &point )
// attempts to delete a commmand, returns true|false if successful|fail // attempts to delete a commmand, returns true|false if successful|fail
bool ASSDrawEngine::DeleteCommand ( DrawCmd* cmd ) bool ASSDrawEngine::DeleteCommand ( DrawCmd* cmd )
{ {
DrawCmdList::iterator iterate = cmds.begin(); DrawCmdList::iterator iterate = cmds.begin();
// can't delete the first command without deleting other commands first // can't delete the first command without deleting other commands first
if ( cmd == (*iterate) && cmds.size() > 1) return false; if ( cmd == (*iterate) && cmds.size() > 1) return false;
DrawCmd* lastiter = NULL; DrawCmd* lastiter = NULL;
for (; iterate != cmds.end(); iterate++) for (; iterate != cmds.end(); iterate++)
{ {
if ( cmd == (*iterate) ) if ( cmd == (*iterate) )
@ -509,7 +509,7 @@ bool ASSDrawEngine::DeleteCommand ( DrawCmd* cmd )
else else
lastiter = (*iterate); lastiter = (*iterate);
} }
return true; return true;
} }
@ -521,14 +521,14 @@ void ASSDrawEngine::ConnectSubsequentCmds (DrawCmd* cmd1, DrawCmd* cmd2)
{ {
cmd1->m_point->cmd_next = cmd2; cmd1->m_point->cmd_next = cmd2;
} }
if (cmd2 != NULL) if (cmd2 != NULL)
{ {
cmd2->prev = cmd1; cmd2->prev = cmd1;
} }
} }
void ASSDrawEngine::RefreshDisplay() void ASSDrawEngine::RefreshDisplay()
{ {
if (!refresh_called) if (!refresh_called)
{ {
@ -552,7 +552,7 @@ void ASSDrawEngine::OnPaint(wxPaintEvent& event)
void ASSDrawEngine::draw() void ASSDrawEngine::draw()
{ {
refresh_called = false; refresh_called = false;
PixelFormat::AGGType pixf(rBuf); PixelFormat::AGGType pixf(rBuf);
RendererBase rbase(pixf); RendererBase rbase(pixf);
RendererPrimitives rprim(rbase); RendererPrimitives rprim(rbase);
@ -564,11 +564,11 @@ void ASSDrawEngine::draw()
rasterizer.reset(); rasterizer.reset();
update_rendered_bound_coords(true); update_rendered_bound_coords(true);
DoDraw(rbase, rprim, rsolid, mtx); DoDraw(rbase, rprim, rsolid, mtx);
delete rm_path, rb_path, rm_curve; delete rm_path, rb_path, rm_curve;
} }
void ASSDrawEngine::ConstructPathsAndCurves(agg::trans_affine& mtx, void ASSDrawEngine::ConstructPathsAndCurves(agg::trans_affine& mtx,
trans_path*& _rm_path, trans_path*& _rb_path, agg::conv_curve<trans_path>*& _rm_curve) trans_path*& _rm_path, trans_path*& _rb_path, agg::conv_curve<trans_path>*& _rm_curve)
{ {
mtx *= agg::trans_affine_scaling(pointsys->scale); mtx *= agg::trans_affine_scaling(pointsys->scale);
@ -639,7 +639,7 @@ void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage&
else else
path.line_to(cmd->m_point->x(),cmd->m_point->y()); path.line_to(cmd->m_point->x(),cmd->m_point->y());
break; break;
case S: case S:
unsigned np = cmd->controlpoints.size(); unsigned np = cmd->controlpoints.size();
agg::pod_array<double> m_polygon(np * 2); agg::pod_array<double> m_polygon(np * 2);
@ -663,9 +663,9 @@ void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage&
_pn += 2; _pn += 2;
} }
path.line_to(cmd->m_point->x(), cmd->m_point->y()); path.line_to(cmd->m_point->x(), cmd->m_point->y());
} }
else else
{ {
//path.line_to((int) m_polygon[0],(int) m_polygon[1]); //path.line_to((int) m_polygon[0],(int) m_polygon[1]);
aggpolygon poly(&m_polygon[0], np, false, false); aggpolygon poly(&m_polygon[0], np, false, false);
agg::conv_bcspline<agg::simple_polygon_vertex_source> bspline(poly); agg::conv_bcspline<agg::simple_polygon_vertex_source> bspline(poly);
@ -678,7 +678,7 @@ void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage&
path.line_to(cmd->m_point->x(), cmd->m_point->y()); path.line_to(cmd->m_point->x(), cmd->m_point->y());
} }
break; break;
} }
} }

View file

@ -51,11 +51,11 @@ void ASSDrawShapePreview::OnSize(wxSizeEvent& event)
{ {
return; return;
wxSize siz = event.GetSize(); wxSize siz = event.GetSize();
if (shapelib->layout == HORIZONTAL) if (shapelib->layout == HORIZONTAL)
SetSize(siz.x, siz.x); SetSize(siz.x, siz.x);
else else
SetSize(siz.y, siz.y); SetSize(siz.y, siz.y);
SetFitToViewPointOnNextPaint(10, 10); SetFitToViewPointOnNextPaint(10, 10);
} }
@ -67,13 +67,13 @@ BEGIN_EVENT_TABLE(ASSDrawShapeLibrary, wxScrolledWindow)
EVT_TOOL(TOOL_DELETE, ASSDrawShapeLibrary::DeleteChecked) EVT_TOOL(TOOL_DELETE, ASSDrawShapeLibrary::DeleteChecked)
END_EVENT_TABLE() END_EVENT_TABLE()
ASSDrawShapeLibrary::ASSDrawShapeLibrary( wxWindow *parent, ASSDrawFrame *frame ) ASSDrawShapeLibrary::ASSDrawShapeLibrary( wxWindow *parent, ASSDrawFrame *frame )
: wxScrolledWindow(parent, wxID_ANY) : wxScrolledWindow(parent, wxID_ANY)
{ {
m_frame = frame; m_frame = frame;
//sizer = NULL; //sizer = NULL;
layout = VERTICAL; layout = VERTICAL;
wxToolBar *tbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT | wxTB_NODIVIDER); wxToolBar *tbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT | wxTB_NODIVIDER);
tbar->SetMargins(0, 3); tbar->SetMargins(0, 3);
tbar->AddTool(TOOL_SAVE, _T("Save canvas"), wxBITMAP(add)); tbar->AddTool(TOOL_SAVE, _T("Save canvas"), wxBITMAP(add));
@ -105,7 +105,7 @@ void ASSDrawShapeLibrary::OnSize(wxSizeEvent& event)
wxSize siz = GetClientSize(); wxSize siz = GetClientSize();
libsizer->SetDimension(0, 0, siz.x, siz.y); libsizer->SetDimension(0, 0, siz.x, siz.y);
UpdatePreviewDisplays(); UpdatePreviewDisplays();
} }
@ -139,7 +139,7 @@ void ASSDrawShapeLibrary::UpdatePreviewDisplays()
node = node->GetNext(); node = node->GetNext();
} }
sizer->Layout(); sizer->Layout();
sizer->FitInside(libarea); sizer->FitInside(libarea);
libarea->Show(true); libarea->Show(true);
} }
@ -209,12 +209,12 @@ void ASSDrawShapeLibrary::OnPopupMenuClicked(wxCommandEvent &event)
void ASSDrawShapeLibrary::SaveShapeFromCanvas(wxCommandEvent& WXUNUSED(event)) void ASSDrawShapeLibrary::SaveShapeFromCanvas(wxCommandEvent& WXUNUSED(event))
{ {
AddShapePreview(m_frame->m_canvas->GenerateASS(), true); AddShapePreview(m_frame->m_canvas->GenerateASS(), true);
} }
void ASSDrawShapeLibrary::CheckUncheckAllPreviews(wxCommandEvent &event) void ASSDrawShapeLibrary::CheckUncheckAllPreviews(wxCommandEvent &event)
{ {
bool checked = event.GetId() == TOOL_CHECK; bool checked = event.GetId() == TOOL_CHECK;
wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst(); wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
while (node != NULL) while (node != NULL)
{ {
@ -262,4 +262,4 @@ void ASSDrawShapeLibrary::LoadToCanvas(ASSDrawShapePreview *preview)
m_frame->m_canvas->RefreshDisplay(); m_frame->m_canvas->RefreshDisplay();
m_frame->m_canvas->RefreshUndocmds(); m_frame->m_canvas->RefreshUndocmds();
m_frame->UpdateFrameUI(); m_frame->UpdateFrameUI();
} }

View file

@ -48,7 +48,7 @@ ASSDrawSettingsDialog::ASSDrawSettingsDialog(wxWindow *parent, ASSDrawFrame *fra
m_frame = frame; m_frame = frame;
propgrid = NULL; propgrid = NULL;
} }
void ASSDrawSettingsDialog::Init() void ASSDrawSettingsDialog::Init()
{ {
propgrid = new wxPropertyGrid(this, propgrid = new wxPropertyGrid(this,
@ -73,7 +73,7 @@ void ASSDrawSettingsDialog::Init()
pgid = propgrid->Append(new wxBoolProperty (label, wxPG_LABEL, boolvar ) ); \ pgid = propgrid->Append(new wxBoolProperty (label, wxPG_LABEL, boolvar ) ); \
propgrid->SetPropertyAttribute( pgid, wxPG_BOOL_USE_CHECKBOX, (long)1 ); propgrid->SetPropertyAttribute( pgid, wxPG_BOOL_USE_CHECKBOX, (long)1 );
wxLongPropertyValidator validator(0x0,0xFF); wxLongPropertyValidator validator(0x0,0xFF);
propgrid->Append(new wxPropertyCategory(_T("Appearance"),wxPG_LABEL) ); propgrid->Append(new wxPropertyCategory(_T("Appearance"),wxPG_LABEL) );
APPENDCOLOURPROP(colors_canvas_bg_pgid, _T("Canvas"), m_frame->colors.canvas_bg) APPENDCOLOURPROP(colors_canvas_bg_pgid, _T("Canvas"), m_frame->colors.canvas_bg)
APPENDCOLOURPROP(colors_canvas_shape_normal_pgid, _T("Drawing"), m_frame->colors.canvas_shape_normal) APPENDCOLOURPROP(colors_canvas_shape_normal_pgid, _T("Drawing"), m_frame->colors.canvas_shape_normal)
@ -103,7 +103,7 @@ void ASSDrawSettingsDialog::Init()
APPENDBOOLPROP(behaviors_parse_spc_pgid, _T("Parse S/P/C"), m_frame->behaviors.parse_spc); APPENDBOOLPROP(behaviors_parse_spc_pgid, _T("Parse S/P/C"), m_frame->behaviors.parse_spc);
APPENDBOOLPROP(behaviors_nosplashscreen_pgid, _T("No splash screen"), m_frame->behaviors.nosplashscreen); APPENDBOOLPROP(behaviors_nosplashscreen_pgid, _T("No splash screen"), m_frame->behaviors.nosplashscreen);
APPENDBOOLPROP(behaviors_confirmquit_pgid, _T("Confirm quit"), m_frame->behaviors.confirmquit); APPENDBOOLPROP(behaviors_confirmquit_pgid, _T("Confirm quit"), m_frame->behaviors.confirmquit);
wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 1, 0, 0); wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 1, 0, 0);
sizer->AddGrowableCol(0); sizer->AddGrowableCol(0);
sizer->AddGrowableRow(0); sizer->AddGrowableRow(0);
@ -156,7 +156,7 @@ void ASSDrawSettingsDialog::OnSettingsApplyButtonClicked(wxCommandEvent &event)
PARSECOLOR(m_frame->colors.origin, colors_origin_pgid) PARSECOLOR(m_frame->colors.origin, colors_origin_pgid)
PARSECOLOR(m_frame->colors.ruler_h, colors_ruler_h_pgid) PARSECOLOR(m_frame->colors.ruler_h, colors_ruler_h_pgid)
PARSECOLOR(m_frame->colors.ruler_v, colors_ruler_v_pgid) PARSECOLOR(m_frame->colors.ruler_v, colors_ruler_v_pgid)
PARSE(&m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid) PARSE(&m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid)
PARSE(&m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid) PARSE(&m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid)
PARSE(&m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid) PARSE(&m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid)
@ -176,7 +176,7 @@ void ASSDrawSettingsDialog::OnSettingsApplyButtonClicked(wxCommandEvent &event)
wxCommandEvent evento( wxEVT_SETTINGS_CHANGED, event.GetId() ); wxCommandEvent evento( wxEVT_SETTINGS_CHANGED, event.GetId() );
evento.SetEventObject( button ); evento.SetEventObject( button );
m_frame->GetEventHandler()->ProcessEvent( evento ); m_frame->GetEventHandler()->ProcessEvent( evento );
} }
void ASSDrawSettingsDialog::OnSettingsRevertButtonClicked(wxCommandEvent &event) void ASSDrawSettingsDialog::OnSettingsRevertButtonClicked(wxCommandEvent &event)
@ -187,7 +187,7 @@ void ASSDrawSettingsDialog::OnSettingsRevertButtonClicked(wxCommandEvent &event)
void ASSDrawSettingsDialog::RefreshSettingsDisplay() void ASSDrawSettingsDialog::RefreshSettingsDisplay()
{ {
if (propgrid == NULL) return; if (propgrid == NULL) return;
#define UPDATESETTING(value, pgid) propgrid->SetPropertyValue(pgid, value); #define UPDATESETTING(value, pgid) propgrid->SetPropertyValue(pgid, value);
UPDATESETTING(m_frame->colors.canvas_bg, colors_canvas_bg_pgid) UPDATESETTING(m_frame->colors.canvas_bg, colors_canvas_bg_pgid)