mirror of https://github.com/odrling/Aegisub
Added support for origin dragging.
Originally committed to SVN as r1352.
This commit is contained in:
parent
686c95b8dc
commit
2251c79791
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -53,6 +53,7 @@ enum DraggableFeatureType {
|
|||
DRAG_NONE,
|
||||
DRAG_BIG_SQUARE,
|
||||
DRAG_BIG_CIRCLE,
|
||||
DRAG_BIG_TRIANGLE,
|
||||
DRAG_SMALL_SQUARE,
|
||||
DRAG_SMALL_CIRCLE
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue