From 1af87b08087ee32f96338bd3de00cf8e64598d56 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 7 Jul 2007 05:51:18 +0000 Subject: [PATCH] Added freehand and smoothed freehand drawing to vector \clip. Originally committed to SVN as r1386. --- aegisub/Makefile.am | 1 + .../bitmaps/visual_vector_clip_freehand.bmp | Bin 1318 -> 1318 bytes .../visual_vector_clip_freehand_smooth.bmp | Bin 0 -> 1318 bytes aegisub/res.rc | 1 + aegisub/spline.cpp | 72 ++++------- aegisub/spline.h | 25 +--- aegisub/spline_curve.cpp | 119 ++++++++++++++++++ aegisub/spline_curve.h | 65 ++++++++++ aegisub/vector2d.h | 5 +- aegisub/video_box.cpp | 9 ++ aegisub/video_box.h | 6 +- aegisub/visual_tool.cpp | 16 ++- aegisub/visual_tool.h | 10 ++ aegisub/visual_tool_drag.cpp | 2 +- aegisub/visual_tool_vector_clip.cpp | 100 +++++++++++++-- aegisub/visual_tool_vector_clip.h | 14 +++ 16 files changed, 357 insertions(+), 88 deletions(-) create mode 100644 aegisub/bitmaps/visual_vector_clip_freehand_smooth.bmp create mode 100644 aegisub/spline_curve.cpp create mode 100644 aegisub/spline_curve.h diff --git a/aegisub/Makefile.am b/aegisub/Makefile.am index 1e790796f..aad1f32e8 100644 --- a/aegisub/Makefile.am +++ b/aegisub/Makefile.am @@ -178,6 +178,7 @@ aegisub_SOURCES = \ scintilla_text_ctrl.cpp \ spellchecker.cpp \ spline.cpp \ + spline_curve.cpp \ standard_paths.cpp \ static_bmp.cpp \ string_codec.cpp \ diff --git a/aegisub/bitmaps/visual_vector_clip_freehand.bmp b/aegisub/bitmaps/visual_vector_clip_freehand.bmp index b12e008f2849ae82d9cd138263a9efe9ffb48547..886cd5b132938e92e7f8e565827dcf2176d43fbd 100644 GIT binary patch delta 111 zcmZ3+wTx?n1IuK07XElfc1Ct20OBACK$t)h&H$^03P1#bBEP}9;M{Z&AEIUQT9yg` DD>e!0 delta 141 zcmZ3+wTx?n14}(S1TaEr7zN`qGD28TK8OM{k@#Q%2p>ZJ1{s1-l@8{!15E;pu|W9{ MnOO0N0WWIRF3v diff --git a/aegisub/bitmaps/visual_vector_clip_freehand_smooth.bmp b/aegisub/bitmaps/visual_vector_clip_freehand_smooth.bmp new file mode 100644 index 0000000000000000000000000000000000000000..b12e008f2849ae82d9cd138263a9efe9ffb48547 GIT binary patch literal 1318 zcmZwFKho1c42NN5#!UDsID#sM6HsgDxq~{cp`)l^IEQM^K%pa~|BCSL%KS+N+t2=1 z8_zmx@8>Tc-pD>a9U>p;y~jIT37h;T{71T9^uDyg3(w;$g{)ZpL;O%z(h z1PVIl2qX$E;sS+%!UKsypU+j&;0PoNEkajPVQ>Tzh2~ER6b45iQD_k^X@$WNNEBL3 z_?x0wrz4Ok^ej!4G&ll@LeH{INrNMhDD=D%SJL1JBnmyRE0i=i0*OM;t4t*gjzFT& z^O{RZgCmeA^!^0aN*Wx2M4=^Ee~4nO+_BC?p(RwHFgOB1qR{h6T}gu@ zkSO$gZXOb0a0C*Co~@8d8XSQ{p=X%)bEPbykJ| literal 0 HcmV?d00001 diff --git a/aegisub/res.rc b/aegisub/res.rc index b90d9ee94..59cf3d137 100644 --- a/aegisub/res.rc +++ b/aegisub/res.rc @@ -149,6 +149,7 @@ visual_vector_clip_remove BITMAP "bitmaps/visual_vector_clip_remove.bmp" visual_vector_clip_convert BITMAP "bitmaps/visual_vector_clip_convert.bmp" visual_vector_clip_insert BITMAP "bitmaps/visual_vector_clip_insert.bmp" visual_vector_clip_freehand BITMAP "bitmaps/visual_vector_clip_freehand.bmp" +visual_vector_clip_freehand_smooth BITMAP "bitmaps/visual_vector_clip_freehand_smooth.bmp" visual_realtime BITMAP "bitmaps/visual_realtime.bmp" arrow_up BITMAP "bitmaps/arrow_up.bmp" diff --git a/aegisub/spline.cpp b/aegisub/spline.cpp index 5e9f23934..994783bca 100644 --- a/aegisub/spline.cpp +++ b/aegisub/spline.cpp @@ -38,53 +38,7 @@ // Headers #include #include "spline.h" - - -///////////////////// -// Curve constructor -SplineCurve::SplineCurve() { - type = CURVE_INVALID; -} - - -///////////////////////////////////////////////////////// -// Split a curve in two using the de Casteljau algorithm -void SplineCurve::Split(SplineCurve &c1,SplineCurve &c2,float t) { - // Split a line - if (type == CURVE_LINE) { - c1.type = CURVE_LINE; - c2.type = CURVE_LINE; - c1.p1 = p1; - c1.p2 = p1*t+p2*(1-t); - c2.p1 = c1.p2; - c2.p2 = p2; - } - - // Split a bicubic - else if (type == CURVE_BICUBIC) { - c1.type = CURVE_BICUBIC; - c2.type = CURVE_BICUBIC; - - // Sub-divisions - float u = 1-t; - Vector2D p12 = p1*t+p2*u; - Vector2D p23 = p2*t+p3*u; - Vector2D p34 = p3*t+p4*u; - Vector2D p123 = p12*t+p23*u; - Vector2D p234 = p23*t+p34*u; - Vector2D p1234 = p123*t+p234*u; - - // Set points - c1.p1 = p1; - c1.p2 = p12; - c1.p3 = p123; - c1.p4 = p1234; - c2.p1 = p1234; - c2.p2 = p234; - c2.p3 = p34; - c2.p4 = p4; - } -} +#include "utils.h" ////////////////////// @@ -362,3 +316,27 @@ Vector2D Spline::GetClosestControlPoint(Vector2D reference) { // TODO return Vector2D(-1,-1); } + + +/////////////////////// +// Smoothes the spline +void Spline::Smooth(float smooth) { + // See if there are enough curves + if (curves.size() < 3) return; + + // Smooth curve + SplineCurve *curve0 = NULL; + SplineCurve *curve1 = &curves.back(); + SplineCurve *curve2 = NULL; + for (std::list::iterator cur=curves.begin();cur!=curves.end();) { + // Get curves + curve0 = curve1; + curve1 = &(*cur); + cur++; + if (cur == curves.end()) curve2 = &curves.front(); + else curve2 = &(*cur); + + // Smooth curve + curve1->Smooth(curve0->p1,curve2->p2,smooth); + } +} diff --git a/aegisub/spline.h b/aegisub/spline.h index 702599775..ede60db7e 100644 --- a/aegisub/spline.h +++ b/aegisub/spline.h @@ -42,29 +42,7 @@ #include #include #include -#include "vector2d.h" - - -/////////////// -// Curve types -enum CurveType { - CURVE_INVALID, - CURVE_POINT, - CURVE_LINE, - CURVE_BICUBIC -}; - - -//////////////// -// Spline curve -class SplineCurve { -public: - Vector2D p1,p2,p3,p4; - CurveType type; - - SplineCurve(); - void Split(SplineCurve &c1,SplineCurve &c2,float t=0.5); -}; +#include "spline_curve.h" ///////////////////////// @@ -80,6 +58,7 @@ public: void AppendCurve(SplineCurve &curve); void MovePoint(int curveIndex,int point,wxPoint pos); + void Smooth(float smooth=1.0f); void GetPointList(std::vector &points); diff --git a/aegisub/spline_curve.cpp b/aegisub/spline_curve.cpp new file mode 100644 index 000000000..616880b17 --- /dev/null +++ b/aegisub/spline_curve.cpp @@ -0,0 +1,119 @@ +// Copyright (c) 2007, Rodrigo Braz Monteiro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Aegisub Group nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +/////////// +// Headers +#include "spline_curve.h" +#include "utils.h" + + +///////////////////// +// Curve constructor +SplineCurve::SplineCurve() { + type = CURVE_INVALID; +} + + +///////////////////////////////////////////////////////// +// Split a curve in two using the de Casteljau algorithm +void SplineCurve::Split(SplineCurve &c1,SplineCurve &c2,float t) { + // Split a line + if (type == CURVE_LINE) { + c1.type = CURVE_LINE; + c2.type = CURVE_LINE; + c1.p1 = p1; + c1.p2 = p1*t+p2*(1-t); + c2.p1 = c1.p2; + c2.p2 = p2; + } + + // Split a bicubic + else if (type == CURVE_BICUBIC) { + c1.type = CURVE_BICUBIC; + c2.type = CURVE_BICUBIC; + + // Sub-divisions + float u = 1-t; + Vector2D p12 = p1*t+p2*u; + Vector2D p23 = p2*t+p3*u; + Vector2D p34 = p3*t+p4*u; + Vector2D p123 = p12*t+p23*u; + Vector2D p234 = p23*t+p34*u; + Vector2D p1234 = p123*t+p234*u; + + // Set points + c1.p1 = p1; + c1.p2 = p12; + c1.p3 = p123; + c1.p4 = p1234; + c2.p1 = p1234; + c2.p2 = p234; + c2.p3 = p34; + c2.p4 = p4; + } +} + + +////////////////////// +// Smoothes the curve +// Based on http://antigrain.com/research/bezier_interpolation/index.html +void SplineCurve::Smooth(Vector2D P0,Vector2D P3,float smooth) { + // Validate + if (type != CURVE_LINE) return; + smooth = MID(0.0f,smooth,1.0f); + + // Get points + Vector2D P1 = p1; + Vector2D P2 = p2; + + // Calculate intermediate points + Vector2D c1 = (P0+P1)/2.0f; + Vector2D c2 = (P1+P2)/2.0f; + Vector2D c3 = (P2+P3)/2.0f; + float len1 = (P1-P0).Len(); + float len2 = (P2-P1).Len(); + float len3 = (P3-P2).Len(); + float k1 = len1/(len1+len2); + float k2 = len2/(len2+len3); + Vector2D m1 = c1+(c2-c1)*k1; + Vector2D m2 = c2+(c3-c2)*k2; + + // Set curve points + p4 = p2; + p2 = m1+(c2-m1)*smooth + P1 - m1; + p3 = m2+(c2-m2)*smooth + P2 - m2; + type = CURVE_BICUBIC; +} diff --git a/aegisub/spline_curve.h b/aegisub/spline_curve.h new file mode 100644 index 000000000..f2566e1cb --- /dev/null +++ b/aegisub/spline_curve.h @@ -0,0 +1,65 @@ +// Copyright (c) 2007, Rodrigo Braz Monteiro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Aegisub Group nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#pragma once + + +/////////// +// Headers +#include "vector2d.h" + + +/////////////// +// Curve types +enum CurveType { + CURVE_INVALID, + CURVE_POINT, + CURVE_LINE, + CURVE_BICUBIC +}; + + +//////////////// +// Spline curve +class SplineCurve { +public: + Vector2D p1,p2,p3,p4; + CurveType type; + + SplineCurve(); + void Split(SplineCurve &c1,SplineCurve &c2,float t=0.5); + void Smooth(Vector2D prev,Vector2D next,float smooth=1.0f); +}; diff --git a/aegisub/vector2d.h b/aegisub/vector2d.h index 076d022aa..f5f14b5c0 100644 --- a/aegisub/vector2d.h +++ b/aegisub/vector2d.h @@ -64,9 +64,10 @@ public: Vector2D Unit (); float Cross (const Vector2D param) const; - virtual float Dot (const Vector2D param) const; + float Dot (const Vector2D param) const; - virtual float Len () const; + float Len () const; + float Length () const { return Len(); } }; diff --git a/aegisub/video_box.cpp b/aegisub/video_box.cpp index b0c32619e..83ba5cff4 100644 --- a/aegisub/video_box.cpp +++ b/aegisub/video_box.cpp @@ -56,6 +56,7 @@ #include "utils.h" #include "main.h" #include "toggle_bitmap.h" +#include "visual_tool.h" /////////////// @@ -157,6 +158,7 @@ BEGIN_EVENT_TABLE(VideoBox, wxPanel) EVT_TOGGLEBUTTON(Video_Auto_Scroll, VideoBox::OnVideoToggleScroll) EVT_TOOL_RANGE(Video_Mode_Standard, Video_Mode_Vector_Clip, VideoBox::OnModeChange) + EVT_TOOL_RANGE(VISUAL_SUB_TOOL_START,VISUAL_SUB_TOOL_END, VideoBox::OnSubTool) EVT_TOOL(Video_Mode_Realtime, VideoBox::OnToggleRealtime) END_EVENT_TABLE() @@ -201,6 +203,13 @@ void VideoBox::OnModeChange(wxCommandEvent &event) { } +/////////////////////////// +// Sub-tool button pressed +void VideoBox::OnSubTool(wxCommandEvent &event) { + videoDisplay->visual->OnSubTool(event); +} + + /////////////////// // Realtime toggle void VideoBox::OnToggleRealtime(wxCommandEvent &event) { diff --git a/aegisub/video_box.h b/aegisub/video_box.h index 088a5fed4..4691fd06f 100644 --- a/aegisub/video_box.h +++ b/aegisub/video_box.h @@ -34,8 +34,7 @@ // -#ifndef VIDEO_BOX_H -#define VIDEO_BOX_H +#pragma once /////////// @@ -62,6 +61,7 @@ private: void OnVideoToggleScroll(wxCommandEvent &event); void OnModeChange(wxCommandEvent &event); + void OnSubTool(wxCommandEvent &event); void OnToggleRealtime(wxCommandEvent &event); public: @@ -102,5 +102,3 @@ enum { Video_Mode_Vector_Clip, Video_Mode_Realtime, }; - -#endif diff --git a/aegisub/visual_tool.cpp b/aegisub/visual_tool.cpp index ed2f8534f..515463815 100644 --- a/aegisub/visual_tool.cpp +++ b/aegisub/visual_tool.cpp @@ -132,8 +132,16 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { dragListOK = true; } + // Click on feature + if (!dragging && leftClick && !DragEnabled()) { + curFeature = GetHighlightedFeature(); + if (curFeature != -1) { + ClickedFeature(features[curFeature]); + } + } + // Start dragging - if (!dragging && leftClick) { + if (!dragging && leftClick && DragEnabled()) { // Get a feature curFeature = GetHighlightedFeature(); if (curFeature != -1) { @@ -178,13 +186,13 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { if (realTime) AssLimitToVisibleFilter::SetFrame(-1); // Commit + dragging = false; CommitDrag(features[curFeature]); grid->editBox->CommitText(); grid->ass->FlagAsModified(_("visual typesetting")); grid->CommitChanges(false); // Clean up - dragging = false; curFeature = -1; parent->ReleaseMouse(); parent->SetFocus(); @@ -196,7 +204,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { // Hold if (!dragging && CanHold()) { // Start holding - if (!holding && event.LeftIsDown()) { + if (!holding && event.LeftIsDown() && HoldEnabled()) { // Get a dialogue curDiag = GetActiveDialogueLine(); if (curDiag) { @@ -230,13 +238,13 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { if (realTime) AssLimitToVisibleFilter::SetFrame(-1); // Commit + holding = false; CommitHold(); grid->editBox->CommitText(); grid->ass->FlagAsModified(_("visual typesetting")); grid->CommitChanges(false); // Clean up - holding = false; curDiag = NULL; parent->ReleaseMouse(); parent->SetFocus(); diff --git a/aegisub/visual_tool.h b/aegisub/visual_tool.h index 215b6b07f..d05660425 100644 --- a/aegisub/visual_tool.h +++ b/aegisub/visual_tool.h @@ -52,6 +52,12 @@ class AssDialogue; class VisualTool; +///////////////////////// +// Visual sub tool range +#define VISUAL_SUB_TOOL_START 1300 +#define VISUAL_SUB_TOOL_END (VISUAL_SUB_TOOL_START+100) + + //////////////////// // Event sink class class VisualToolEvent : public wxEvtHandler { @@ -114,15 +120,18 @@ protected: virtual void OnButton(wxCommandEvent &event) {} virtual bool CanHold() { return false; } + virtual bool HoldEnabled() { return true; } virtual void InitializeHold() {} virtual void UpdateHold() {} virtual void CommitHold() {} virtual bool CanDrag() { return false; } + virtual bool DragEnabled() { return true; } virtual void PopulateFeatureList() { wxLogMessage(_T("wtf?")); } virtual void InitializeDrag(VisualDraggableFeature &feature) {} virtual void UpdateDrag(VisualDraggableFeature &feature) {} virtual void CommitDrag(VisualDraggableFeature &feature) {} + virtual void ClickedFeature(VisualDraggableFeature &feature) {} virtual void DoRefresh() {} @@ -130,6 +139,7 @@ public: int mouseX,mouseY; void OnMouseEvent(wxMouseEvent &event); + virtual void OnSubTool(wxCommandEvent &event) {} virtual void Update()=0; virtual void Draw()=0; void Refresh(); diff --git a/aegisub/visual_tool_drag.cpp b/aegisub/visual_tool_drag.cpp index e6f4140a1..12b24a804 100644 --- a/aegisub/visual_tool_drag.cpp +++ b/aegisub/visual_tool_drag.cpp @@ -51,7 +51,7 @@ /////// // IDs enum { - BUTTON_TOGGLE_MOVE = 1300 + BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START }; diff --git a/aegisub/visual_tool_vector_clip.cpp b/aegisub/visual_tool_vector_clip.cpp index b4265d69f..5fbf83034 100644 --- a/aegisub/visual_tool_vector_clip.cpp +++ b/aegisub/visual_tool_vector_clip.cpp @@ -43,24 +43,28 @@ /////// // IDs enum { - BUTTON_DRAG = 1300, + BUTTON_DRAG = VISUAL_SUB_TOOL_START, BUTTON_LINE, BUTTON_BICUBIC, BUTTON_INSERT, BUTTON_REMOVE, BUTTON_CONVERT, - BUTTON_FREEHAND + BUTTON_FREEHAND, + BUTTON_FREEHAND_SMOOTH, + BUTTON_LAST // Leave this at the end and don't use it }; /////////////// // Constructor -VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent,wxToolBar *toolBar) +VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent,wxToolBar *_toolBar) : VisualTool(parent) { DoRefresh(); + mode = 0; // Create toolbar + toolBar = _toolBar; toolBar->AddTool(BUTTON_DRAG,_("Drag"),wxBITMAP(visual_vector_clip_drag),_("Drag control points."),wxITEM_CHECK); toolBar->AddTool(BUTTON_LINE,_("Line"),wxBITMAP(visual_vector_clip_line),_("Appends a line."),wxITEM_CHECK); toolBar->AddTool(BUTTON_BICUBIC,_("Bicubic"),wxBITMAP(visual_vector_clip_bicubic),_("Appends a bezier bicubic curve."),wxITEM_CHECK); @@ -70,11 +74,31 @@ VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent,wxToolBar *toolB toolBar->AddTool(BUTTON_REMOVE,_("Remove"),wxBITMAP(visual_vector_clip_remove),_("Removes a control point."),wxITEM_CHECK); toolBar->AddSeparator(); toolBar->AddTool(BUTTON_FREEHAND,_("Freehand"),wxBITMAP(visual_vector_clip_freehand),_("Draws a freehand shape."),wxITEM_CHECK); + toolBar->AddTool(BUTTON_FREEHAND_SMOOTH,_("Freehand smooth"),wxBITMAP(visual_vector_clip_freehand_smooth),_("Draws a smoothed freehand shape."),wxITEM_CHECK); + toolBar->ToggleTool(BUTTON_DRAG,true); toolBar->Realize(); toolBar->Show(true); } +//////////////////// +// Sub-tool pressed +void VisualToolVectorClip::OnSubTool(wxCommandEvent &event) { + // Make sure clicked is checked and everything else isn't. (Yes, this is radio behavior, but the separators won't let me use it) + for (int i=BUTTON_DRAG;iToggleTool(i,i == event.GetId()); + } + SetMode(event.GetId() - BUTTON_DRAG); +} + + +//////////// +// Set mode +void VisualToolVectorClip::SetMode(int _mode) { + mode = _mode; +} + + ////////// // Update void VisualToolVectorClip::Update() { @@ -96,8 +120,8 @@ void VisualToolVectorClip::Draw() { // Draw lines SetLineColour(colour[3],1.0f,2); SetFillColour(colour[3],0.0f); - for (int i=0;i<((signed)points.size())-1;i++) { - DrawLine(points[i].x,points[i].y,points[i+1].x,points[i+1].y); + for (size_t i=1;i