Change the uses of -1 for invalid positions in the visual typesetting tools to INT_MIN, as -1 is sometimes a perfectly valid coordinate

Originally committed to SVN as r4258.
This commit is contained in:
Thomas Goyne 2010-05-01 01:45:16 +00:00
parent 5cbabf2d35
commit c7e06e9451
7 changed files with 22 additions and 24 deletions

View file

@ -120,7 +120,7 @@ VideoDisplay::VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl
, origSize(size) , origSize(size)
, currentFrame(-1) , currentFrame(-1)
, w(8), h(8), dx1(0), dx2(8), dy1(0), dy2(8) , w(8), h(8), dx1(0), dx2(8), dy1(0), dy2(8)
, mouse_x(-1), mouse_y(-1) , mouse_x(INT_MIN), mouse_y(INT_MIN)
, locked(false) , locked(false)
, zoomValue(1.0) , zoomValue(1.0)
, ControlSlider(ControlSlider) , ControlSlider(ControlSlider)

View file

@ -48,8 +48,8 @@
/// ///
VisualDraggableFeature::VisualDraggableFeature() { VisualDraggableFeature::VisualDraggableFeature() {
type = DRAG_NONE; type = DRAG_NONE;
x = -1; x = INT_MIN;
y = -1; y = INT_MIN;
value = value2 = 0; value = value2 = 0;
layer = 0; layer = 0;
lineN = -1; lineN = -1;

View file

@ -87,7 +87,7 @@ VisualTool::VisualTool(VideoDisplay *par) : eventSink(this) {
dragListOK = false; dragListOK = false;
// Video options // Video options
mouseX = mouseY = -1; mouseX = mouseY = INT_MIN;
frame_n = 0; frame_n = 0;
if (VideoContext::Get()->IsLoaded()) { if (VideoContext::Get()->IsLoaded()) {
parent->GetClientSize(&w,&h); parent->GetClientSize(&w,&h);
@ -124,10 +124,10 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
// Mouse leaving control // Mouse leaving control
if (event.Leaving()) { if (event.Leaving()) {
mouseX = -1; mouseX = INT_MIN;
mouseY = -1; mouseY = INT_MIN;
mx = -1; mx = INT_MIN;
my = -1; my = INT_MIN;
Update(); Update();
return; return;
} }
@ -393,10 +393,10 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y) {
void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) { void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) {
// No dialogue // No dialogue
if (!diag) { if (!diag) {
x = -1; x = INT_MIN;
y = -1; y = INT_MIN;
orgx = -1; orgx = INT_MIN;
orgy = -1; orgy = INT_MIN;
return; return;
} }
@ -426,8 +426,8 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, in
// Position // Position
bool posSet = false; bool posSet = false;
bool orgSet = false; bool orgSet = false;
int posx = -1; int posx = INT_MIN;
int posy = -1; int posy = INT_MIN;
// Overrides processing // Overrides processing
diag->ParseASSTags(); diag->ParseASSTags();

View file

@ -80,7 +80,7 @@ void VisualToolClip::Update() {
/// @return /// @return
/// ///
void VisualToolClip::Draw() { void VisualToolClip::Draw() {
if (mouseX == -1 || mouseY == -1) return; if (mouseX == INT_MIN || mouseY == INT_MIN) return;
// Get current line // Get current line
AssDialogue *line = GetActiveDialogueLine(); AssDialogue *line = GetActiveDialogueLine();
if (!line) return; if (!line) return;

View file

@ -90,7 +90,7 @@ void VisualToolCross::Update() {
/// @brief Draw /// @brief Draw
/// ///
void VisualToolCross::Draw() { void VisualToolCross::Draw() {
if (mouseX == -1 || mouseY == -1) return; if (mouseX == INT_MIN || mouseY == INT_MIN) return;
// Draw cross // Draw cross
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);

View file

@ -160,7 +160,7 @@ void VisualToolRotateZ::Draw() {
glPopMatrix(); glPopMatrix();
// Draw line to mouse // Draw line to mouse
if (mouseX != -1 && !dragging && GetHighlightedFeature() == -1) { if (!dragging && GetHighlightedFeature() == -1) {
SetLineColour(colour[0]); SetLineColour(colour[0]);
DrawLine(dx,dy,mx,my); DrawLine(dx,dy,mx,my);
} }

View file

@ -214,12 +214,10 @@ void VisualToolVectorClip::Draw() {
// Draw preview of inserted line // Draw preview of inserted line
if (mode == 1 || mode == 2) { if (mode == 1 || mode == 2) {
if (spline.curves.size()) { if (spline.curves.size()) {
if (mx != -1 || my != -1) { SplineCurve *c0 = &spline.curves.front();
SplineCurve *c0 = &spline.curves.front(); SplineCurve *c1 = &spline.curves.back();
SplineCurve *c1 = &spline.curves.back(); DrawDashedLine(mx,my,c0->p1.x,c0->p1.y,6);
DrawDashedLine(mx,my,c0->p1.x,c0->p1.y,6); DrawDashedLine(mx,my,c1->GetEndPoint().x,c1->GetEndPoint().y,6);
DrawDashedLine(mx,my,c1->GetEndPoint().x,c1->GetEndPoint().y,6);
}
} }
} }
@ -492,7 +490,7 @@ void VisualToolVectorClip::UpdateHold() {
// Freehand // Freehand
if (mode == 6 || mode == 7) { if (mode == 6 || mode == 7) {
if (lastX != -100000 && lastY != -100000) { if (lastX != -100000 && lastY != -100000) {
// See if distance is enough // See if distance is enough
Vector2D delta(lastX-mx,lastY-my); Vector2D delta(lastX-mx,lastY-my);
int len = (int)delta.Len(); int len = (int)delta.Len();