Visual typesetting fixes and failed attempt to make \clip typesetting allow dragging of corners.

Originally committed to SVN as r1349.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-04 05:22:35 +00:00
parent 92e61f885f
commit 0d40d2533f
5 changed files with 128 additions and 7 deletions

View file

@ -510,6 +510,7 @@ void SubsEditBox::SetControlsState (bool state) {
Color3->Enable(state);
Color4->Enable(state);
FontName->Enable(state);
CommitButton->Enable(state);
UpdateFrameTiming();

View file

@ -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);
}
}

View file

@ -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;
if (CanDrag()) PopulateFeatureList();
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();
}

View file

@ -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);
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();
}

View file

@ -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);