Made the circles at the edges of the rectangular \clip visual typesetting tool draggable.

Originally committed to SVN as r1351.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-04 06:50:03 +00:00
parent efa8401415
commit 686c95b8dc
3 changed files with 44 additions and 37 deletions

View File

@ -139,7 +139,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
if (curFeature != -1) { if (curFeature != -1) {
// Initialize drag // Initialize drag
InitializeDrag(features[curFeature]); InitializeDrag(features[curFeature]);
VideoContext::Get()->grid->editBox->SetToLine(features[curFeature].lineN,true); if (features[curFeature].lineN != -1) VideoContext::Get()->grid->editBox->SetToLine(features[curFeature].lineN,true);
// Set start value // Set start value
dragStartX = mx; dragStartX = mx;
@ -286,11 +286,17 @@ int VisualTool::GetHighlightedFeature() {
///////////////////// /////////////////////
// Draw all features // Draw all features
void VisualTool::DrawAllFeatures() { void VisualTool::DrawAllFeatures() {
// Populate list, if needed
if (!dragListOK) { if (!dragListOK) {
PopulateFeatureList(); PopulateFeatureList();
dragListOK = true; dragListOK = true;
} }
int mouseOver = GetHighlightedFeature();
// Get feature that mouse is over
int mouseOver = curFeature;
if (curFeature == -1) mouseOver = GetHighlightedFeature();
// Draw features
for (size_t i=0;i<features.size();i++) { for (size_t i=0;i<features.size();i++) {
SetFillColour(colour[(signed)i == mouseOver ? 2 : 1],0.3f); SetFillColour(colour[(signed)i == mouseOver ? 2 : 1],0.3f);
SetLineColour(colour[0]); SetLineColour(colour[0]);
@ -303,7 +309,7 @@ void VisualTool::DrawAllFeatures() {
// Refresh // Refresh
void VisualTool::Refresh() { void VisualTool::Refresh() {
frame_n = VideoContext::Get()->GetFrameN(); frame_n = VideoContext::Get()->GetFrameN();
dragListOK = false; if (!dragging) dragListOK = false;
DoRefresh(); DoRefresh();
} }

View File

@ -79,7 +79,7 @@ void VisualToolClip::Draw() {
if (!line) return; if (!line) return;
// Get position // Get position
if (line != curDiag) GetLineClip(line,curX1,curY1,curX2,curY2); if (!dragging && !holding) GetLineClip(line,curX1,curY1,curX2,curY2);
int dx1 = curX1; int dx1 = curX1;
int dy1 = curY1; int dy1 = curY1;
int dx2 = curX2; int dx2 = curX2;
@ -93,13 +93,10 @@ void VisualToolClip::Draw() {
// Draw outside area // Draw outside area
SetLineColour(colour[3],0.0f); SetLineColour(colour[3],0.0f);
SetFillColour(colour[3],0.3f); SetFillColour(colour[3],0.3f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
DrawRectangle(0,0,sw,dy1); DrawRectangle(0,0,sw,dy1);
DrawRectangle(0,dy2,sw,sh); DrawRectangle(0,dy2,sw,sh);
DrawRectangle(0,dy1,dx1,dy2); DrawRectangle(0,dy1,dx1,dy2);
DrawRectangle(dx2,dy1,sw,dy2); DrawRectangle(dx2,dy1,sw,dy2);
glDisable(GL_BLEND);
// Draw circles // Draw circles
SetLineColour(colour[0]); SetLineColour(colour[0]);
@ -158,43 +155,47 @@ void VisualToolClip::CommitHold() {
// Populate feature list // Populate feature list
void VisualToolClip::PopulateFeatureList() { void VisualToolClip::PopulateFeatureList() {
// Clear // Clear
features.clear(); if (features.size() != 4) {
features.clear();
// Setup basic feature features.resize(4);
VisualDraggableFeature feat; }
feat.type = DRAG_SMALL_CIRCLE;
// Top-left // Top-left
feat.x = curX1; int i = 0;
feat.y = curY1; features[i].x = curX1;
feat.brother[0] = 1; features[i].y = curY1;
feat.brother[1] = 2; features[i].brother[0] = 1;
feat.brother[2] = 3; features[i].brother[1] = 2;
features.push_back(feat); features[i].brother[2] = 3;
features[i].type = DRAG_SMALL_CIRCLE;
i++;
// Top-right // Top-right
feat.x = curX2; features[i].x = curX2;
feat.y = curY1; features[i].y = curY1;
feat.brother[0] = 0; features[i].brother[0] = 0;
feat.brother[1] = 3; features[i].brother[1] = 3;
feat.brother[2] = 2; features[i].brother[2] = 2;
features.push_back(feat); features[i].type = DRAG_SMALL_CIRCLE;
i++;
// Bottom-left // Bottom-left
feat.x = curX1; features[i].x = curX1;
feat.y = curY2; features[i].y = curY2;
feat.brother[0] = 3; features[i].brother[0] = 3;
feat.brother[1] = 0; features[i].brother[1] = 0;
feat.brother[2] = 1; features[i].brother[2] = 1;
features.push_back(feat); features[i].type = DRAG_SMALL_CIRCLE;
i++;
// Bottom-right // Bottom-right
feat.x = curX2; features[i].x = curX2;
feat.y = curY2; features[i].y = curY2;
feat.brother[0] = 2; features[i].brother[0] = 2;
feat.brother[1] = 1; features[i].brother[1] = 1;
feat.brother[2] = 0; features[i].brother[2] = 0;
features.push_back(feat); features[i].type = DRAG_SMALL_CIRCLE;
i++;
} }

View File

@ -53,7 +53,7 @@ private:
void UpdateHold(); void UpdateHold();
void CommitHold(); void CommitHold();
bool CanDrag() { return false; } bool CanDrag() { return true; }
void PopulateFeatureList(); void PopulateFeatureList();
void InitializeDrag(VisualDraggableFeature &feature); void InitializeDrag(VisualDraggableFeature &feature);
void UpdateDrag(VisualDraggableFeature &feature); void UpdateDrag(VisualDraggableFeature &feature);