diff --git a/aegisub/subs_edit_box.cpp b/aegisub/subs_edit_box.cpp index 5f5db85cf..d29de1808 100644 --- a/aegisub/subs_edit_box.cpp +++ b/aegisub/subs_edit_box.cpp @@ -510,6 +510,7 @@ void SubsEditBox::SetControlsState (bool state) { Color3->Enable(state); Color4->Enable(state); FontName->Enable(state); + CommitButton->Enable(state); UpdateFrameTiming(); diff --git a/aegisub/visual_feature.cpp b/aegisub/visual_feature.cpp index b0a00ec01..db07c4a35 100644 --- a/aegisub/visual_feature.cpp +++ b/aegisub/visual_feature.cpp @@ -64,13 +64,21 @@ bool VisualDraggableFeature::IsMouseOver(int mx,int my) { } // Circle - if (type == DRAG_BIG_CIRCLE) { + else if (type == DRAG_BIG_CIRCLE) { int dx = mx-x; int dy = my-y; if (dx*dx + dy*dy <= 64) return true; return false; } + // Small circle + else if (type == DRAG_SMALL_CIRCLE) { + int dx = mx-x; + int dy = my-y; + if (dx*dx + dy*dy <= 16) return true; + return false; + } + // Fallback return false; } @@ -89,7 +97,12 @@ void VisualDraggableFeature::Draw(OpenGLWrapper *gl) { } // Circle - if (type == DRAG_BIG_CIRCLE) { + else if (type == DRAG_BIG_CIRCLE) { gl->DrawCircle(x,y,8); } + + // Small circle + else if (type == DRAG_SMALL_CIRCLE) { + gl->DrawCircle(x,y,4); + } } diff --git a/aegisub/visual_tool.cpp b/aegisub/visual_tool.cpp index cbe64e2a3..802e7077f 100644 --- a/aegisub/visual_tool.cpp +++ b/aegisub/visual_tool.cpp @@ -58,23 +58,33 @@ /////////////// // Constructor VisualTool::VisualTool(VideoDisplay *par) : eventSink(this) { + // Config parent = par; colour[0] = wxColour(27,60,114); colour[1] = wxColour(166,247,177); colour[2] = wxColour(255,255,255); colour[3] = wxColour(187,0,0); + // Holding variables holding = false; curDiag = NULL; + // Dragging variables dragging = false; curFeature = -1; dragListOK = false; + // Video options mouseX = mouseY = -1; + frame_n = 0; + if (VideoContext::Get()->IsLoaded()) { + parent->GetClientSize(&w,&h); + VideoContext::Get()->GetScriptSize(sw,sh); + frame_n = VideoContext::Get()->GetFrameN(); + } + // Features if (CanDrag()) PopulateFeatureList(); - frame_n = VideoContext::Get()->GetFrameN(); } diff --git a/aegisub/visual_tool_clip.cpp b/aegisub/visual_tool_clip.cpp index 555ff1f85..bc17e5ff6 100644 --- a/aegisub/visual_tool_clip.cpp +++ b/aegisub/visual_tool_clip.cpp @@ -53,6 +53,13 @@ VisualToolClip::VisualToolClip(VideoDisplay *_parent) : VisualTool(_parent) { _parent->ShowCursor(false); + + // Set defaults + curX1 = curY1 = 0; + curX2 = sw; + curY2 = sh; + AssDialogue *line = GetActiveDialogueLine(); + if (line) GetLineClip(line,curX1,curY1,curX2,curY2); } @@ -97,10 +104,13 @@ void VisualToolClip::Draw() { // Draw circles SetLineColour(colour[0]); SetFillColour(colour[1],0.5); - DrawCircle(dx1,dy1,4); - DrawCircle(dx2,dy1,4); - DrawCircle(dx2,dy2,4); - DrawCircle(dx1,dy2,4); + if (CanDrag()) DrawAllFeatures(); + else { + DrawCircle(dx1,dy1,4); + DrawCircle(dx2,dy1,4); + DrawCircle(dx2,dy2,4); + DrawCircle(dx1,dy2,4); + } } @@ -131,6 +141,9 @@ void VisualToolClip::UpdateHold() { curX2 = MID(0,curX2,sw); curY1 = MID(0,curY1,sh); curY2 = MID(0,curY2,sh); + + // Features + if (CanDrag()) PopulateFeatureList(); } @@ -139,3 +152,81 @@ void VisualToolClip::UpdateHold() { void VisualToolClip::CommitHold() { SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX1,curY1,curX2,curY2)); } + + +///////////////////////// +// Populate feature list +void VisualToolClip::PopulateFeatureList() { + // Clear + features.clear(); + + // Setup basic feature + VisualDraggableFeature feat; + feat.type = DRAG_SMALL_CIRCLE; + + // Top-left + feat.x = curX1; + feat.y = curY1; + feat.brother[0] = 1; + feat.brother[1] = 2; + feat.brother[2] = 3; + features.push_back(feat); + + // Top-right + feat.x = curX2; + feat.y = curY1; + feat.brother[0] = 0; + feat.brother[1] = 3; + feat.brother[2] = 2; + features.push_back(feat); + + // Bottom-left + feat.x = curX1; + feat.y = curY2; + feat.brother[0] = 3; + feat.brother[1] = 0; + feat.brother[2] = 1; + features.push_back(feat); + + // Bottom-right + feat.x = curX2; + feat.y = curY2; + feat.brother[0] = 2; + feat.brother[1] = 1; + feat.brother[2] = 0; + features.push_back(feat); +} + + +////////////// +// Initialize +void VisualToolClip::InitializeDrag(VisualDraggableFeature &feature) { + curDiag = GetActiveDialogueLine(); + curDiag->StripTag(_T("\\clip")); +} + + +/////////////// +// Update drag +void VisualToolClip::UpdateDrag(VisualDraggableFeature &feature) { + // Update brothers + features[feature.brother[0]].y = feature.y; + features[feature.brother[1]].x = feature.x; + + // Get "cur" from features + curX1 = features[0].x; + curX2 = features[3].x; + curY1 = features[0].y; + curY2 = features[3].y; + + // Make sure p1 < p2 + if (curX1 > curX2) IntSwap(curX1,curX2); + if (curY1 > curY2) IntSwap(curY1,curY2); +} + + +///////////////// +// Done dragging +void VisualToolClip::CommitDrag(VisualDraggableFeature &feature) { + CommitHold(); +} diff --git a/aegisub/visual_tool_clip.h b/aegisub/visual_tool_clip.h index e3570f9e0..6ace162ae 100644 --- a/aegisub/visual_tool_clip.h +++ b/aegisub/visual_tool_clip.h @@ -53,6 +53,12 @@ private: void UpdateHold(); void CommitHold(); + bool CanDrag() { return false; } + void PopulateFeatureList(); + void InitializeDrag(VisualDraggableFeature &feature); + void UpdateDrag(VisualDraggableFeature &feature); + void CommitDrag(VisualDraggableFeature &feature); + public: VisualToolClip(VideoDisplay *parent);