From 2251c797914c9f4681798ff378c792a02a224ada Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Wed, 4 Jul 2007 07:26:24 +0000 Subject: [PATCH] Added support for origin dragging. Originally committed to SVN as r1352. --- aegisub/gl_wrap.cpp | 25 +++++++++++++++++++++++++ aegisub/gl_wrap.h | 1 + aegisub/visual_feature.cpp | 18 ++++++++++++++++++ aegisub/visual_feature.h | 1 + aegisub/visual_tool_drag.cpp | 19 ++++++++++++++++++- 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/aegisub/gl_wrap.cpp b/aegisub/gl_wrap.cpp index 228a873e7..eee180b8b 100644 --- a/aegisub/gl_wrap.cpp +++ b/aegisub/gl_wrap.cpp @@ -135,6 +135,31 @@ void OpenGLWrapper::DrawRectangle(float x1,float y1,float x2,float y2) { } +///////////////// +// Draw triangle +void OpenGLWrapper::DrawTriangle(float x1,float y1,float x2,float y2,float x3,float y3) { + // Fill + if (a2 != 0.0) { + SetModeFill(); + glBegin(GL_TRIANGLES); + glVertex2f(x1,y1); + glVertex2f(x2,y2); + glVertex2f(x3,y3); + glEnd(); + } + + // Outline + if (a1 != 0.0) { + SetModeLine(); + glBegin(GL_LINE_LOOP); + glVertex2f(x1,y1); + glVertex2f(x2,y2); + glVertex2f(x3,y3); + glEnd(); + } +} + + /////////////////////// // Draw ring (annulus) void OpenGLWrapper::DrawRing(float x,float y,float r1,float r2,float ar,float arcStart,float arcEnd) { diff --git a/aegisub/gl_wrap.h b/aegisub/gl_wrap.h index 3942a3a6d..b3012a4c9 100644 --- a/aegisub/gl_wrap.h +++ b/aegisub/gl_wrap.h @@ -64,6 +64,7 @@ public: void DrawCircle(float x,float y,float radius) { DrawEllipse(x,y,radius,radius); } void DrawRectangle(float x1,float y1,float x2,float y2); void DrawRing(float x,float y,float r1,float r2,float ar=1.0f,float arcStart=0.0f,float arcEnd=0.0f); + void DrawTriangle(float x1,float y1,float x2,float y2,float x3,float y3); static bool UseShaders(); static bool IsExtensionSupported(const char *ext); diff --git a/aegisub/visual_feature.cpp b/aegisub/visual_feature.cpp index db07c4a35..d0f09d244 100644 --- a/aegisub/visual_feature.cpp +++ b/aegisub/visual_feature.cpp @@ -71,6 +71,14 @@ bool VisualDraggableFeature::IsMouseOver(int mx,int my) { return false; } + // Triangle + else if (type == DRAG_BIG_TRIANGLE) { + if (my < y-8 || my > y+8) return false; + int dx = mx-x; + int dy = my-y-8; + return (16*dx+9*dy < 0 && 16*dx-9*dy > 0); + } + // Small circle else if (type == DRAG_SMALL_CIRCLE) { int dx = mx-x; @@ -99,6 +107,16 @@ void VisualDraggableFeature::Draw(OpenGLWrapper *gl) { // Circle else if (type == DRAG_BIG_CIRCLE) { gl->DrawCircle(x,y,8); + gl->DrawLine(x,y-16,x,y+16); + gl->DrawLine(x-16,y,x+16,y); + } + + // Triangle + else if (type == DRAG_BIG_TRIANGLE) { + gl->DrawTriangle(x-9,y-8,x+9,y-8,x,y+8); + gl->DrawLine(x,y-2,x,y-18); + gl->DrawLine(x,y-2,x-14,y+6); + gl->DrawLine(x,y-2,x+14,y+6); } // Small circle diff --git a/aegisub/visual_feature.h b/aegisub/visual_feature.h index 2c63baaf2..44d6d2aee 100644 --- a/aegisub/visual_feature.h +++ b/aegisub/visual_feature.h @@ -53,6 +53,7 @@ enum DraggableFeatureType { DRAG_NONE, DRAG_BIG_SQUARE, DRAG_BIG_CIRCLE, + DRAG_BIG_TRIANGLE, DRAG_SMALL_SQUARE, DRAG_SMALL_CIRCLE }; diff --git a/aegisub/visual_tool_drag.cpp b/aegisub/visual_tool_drag.cpp index 4996b245e..fe8006838 100644 --- a/aegisub/visual_tool_drag.cpp +++ b/aegisub/visual_tool_drag.cpp @@ -232,6 +232,18 @@ void VisualToolDrag::PopulateFeatureList() { features[n-1].brother[0] = n-2; features[n-2].brother[0] = n-1; } + + // Create org feature + if (torgx != x1 || torgy != y1) { + feat.x = torgx; + feat.y = torgy; + feat.layer = -1; + feat.type = DRAG_BIG_TRIANGLE; + feat.value = 0; + feat.line = diag; + feat.lineN = i; + features.push_back(feat); + } } } } @@ -256,8 +268,13 @@ void VisualToolDrag::UpdateDrag(VisualDraggableFeature &feature) { /////////////// // Commit drag void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { + // Origin + if (feature.type == DRAG_BIG_TRIANGLE) { + SetOverride(_T("\\org"),wxString::Format(_T("(%i,%i)"),feature.x,feature.y)); + } + // Position - if (feature.brother[0] == -1) { + else if (feature.brother[0] == -1) { SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),feature.x,feature.y)); }