Visual tools rewriting, currently only the crosshair works.

Originally committed to SVN as r1324.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-01 00:19:55 +00:00
parent f963a8c462
commit 7e8de1c389
13 changed files with 617 additions and 1203 deletions

View file

@ -209,12 +209,13 @@ aegisub_SOURCES = \
video_box.cpp \ video_box.cpp \
video_context.cpp \ video_context.cpp \
video_display.cpp \ video_display.cpp \
video_display_visual.cpp \
video_draggable_feature.cpp \
video_frame.cpp \ video_frame.cpp \
video_provider.cpp \ video_provider.cpp \
video_provider_dummy.cpp \ video_provider_dummy.cpp \
video_slider.cpp \ video_slider.cpp \
visual_feature.cpp \
visual_tool.cpp \
visual_tool_cross.cpp \
MatroskaParser.c MatroskaParser.c
noinst_HEADERS = \ noinst_HEADERS = \

View file

@ -81,17 +81,21 @@ bool AegisubApp::OnInit() {
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
// App name // App name (yeah, this is a little weird to get rid of an odd warning)
#ifdef __WXMSW__ || __WXMAC__ #ifdef __WXMSW__
SetAppName(_T("Aegisub"));
#else
#ifdef __WXMAC__
SetAppName(_T("Aegisub")); SetAppName(_T("Aegisub"));
#else #else
SetAppName(_T("aegisub")); SetAppName(_T("aegisub"));
#endif
#endif #endif
// Crash handling // Crash handling
#ifndef _DEBUG #ifndef _DEBUG
wxHandleFatalExceptions(true); wxHandleFatalExceptions(true);
#endif #endif
// Set config file // Set config file
Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat"))); Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat")));

View file

@ -43,7 +43,6 @@
#include <wx/rawbmp.h> #include <wx/rawbmp.h>
#include "video_box.h" #include "video_box.h"
#include "video_display.h" #include "video_display.h"
#include "video_display_visual.h"
#include "video_slider.h" #include "video_slider.h"
#include "frame_main.h" #include "frame_main.h"
#include "toggle_bitmap.h" #include "toggle_bitmap.h"
@ -208,42 +207,42 @@ void VideoBox::OnVideoToggleScroll(wxCommandEvent &event) {
///////////////// /////////////////
// Standard mode // Standard mode
void VideoBox::OnModeStandard(wxCommandEvent &event) { void VideoBox::OnModeStandard(wxCommandEvent &event) {
videoDisplay->visual->SetMode(0); videoDisplay->SetVisualMode(0);
} }
///////////// /////////////
// Drag mode // Drag mode
void VideoBox::OnModeDrag(wxCommandEvent &event) { void VideoBox::OnModeDrag(wxCommandEvent &event) {
videoDisplay->visual->SetMode(1); videoDisplay->SetVisualMode(1);
} }
///////////////// /////////////////
// Rotate Z mode // Rotate Z mode
void VideoBox::OnModeRotateZ(wxCommandEvent &event) { void VideoBox::OnModeRotateZ(wxCommandEvent &event) {
videoDisplay->visual->SetMode(2); videoDisplay->SetVisualMode(2);
} }
////////////////// //////////////////
// Rotate XY mode // Rotate XY mode
void VideoBox::OnModeRotateXY(wxCommandEvent &event) { void VideoBox::OnModeRotateXY(wxCommandEvent &event) {
videoDisplay->visual->SetMode(3); videoDisplay->SetVisualMode(3);
} }
////////////// //////////////
// Scale mode // Scale mode
void VideoBox::OnModeScale(wxCommandEvent &event) { void VideoBox::OnModeScale(wxCommandEvent &event) {
videoDisplay->visual->SetMode(4); videoDisplay->SetVisualMode(4);
} }
///////////// /////////////
// Clip mode // Clip mode
void VideoBox::OnModeClip(wxCommandEvent &event) { void VideoBox::OnModeClip(wxCommandEvent &event) {
videoDisplay->visual->SetMode(5); videoDisplay->SetVisualMode(5);
} }

View file

@ -72,7 +72,7 @@ class VideoContextThread;
// Main class // Main class
class VideoContext : public wxEvtHandler { class VideoContext : public wxEvtHandler {
friend class AudioProvider; friend class AudioProvider;
friend class VideoDisplayVisual; friend class VisualTool;
friend class VideoContextThread; friend class VideoContextThread;
private: private:

View file

@ -51,7 +51,6 @@
#include <wx/config.h> #include <wx/config.h>
#include "utils.h" #include "utils.h"
#include "video_display.h" #include "video_display.h"
#include "video_display_visual.h"
#include "video_provider.h" #include "video_provider.h"
#include "vfr.h" #include "vfr.h"
#include "ass_file.h" #include "ass_file.h"
@ -68,6 +67,8 @@
#include "video_slider.h" #include "video_slider.h"
#include "video_box.h" #include "video_box.h"
#include "gl_wrap.h" #include "gl_wrap.h"
#include "visual_tool.h"
#include "visual_tool_cross.h"
/////// ///////
@ -116,8 +117,10 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos,
origSize = size; origSize = size;
zoomValue = 1.0; zoomValue = 1.0;
freeSize = false; freeSize = false;
visual = new VideoDisplayVisual(this); visual = NULL;
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
visualMode = -1;
SetVisualMode(0);
} }
@ -125,6 +128,7 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos,
// Destructor // Destructor
VideoDisplay::~VideoDisplay () { VideoDisplay::~VideoDisplay () {
delete visual; delete visual;
visual = NULL;
VideoContext::Get()->RemoveDisplay(this); VideoContext::Get()->RemoveDisplay(this);
} }
@ -275,8 +279,7 @@ void VideoDisplay::Render() {
DrawTVEffects(); DrawTVEffects();
// Draw overlay // Draw overlay
wxASSERT(visual); if (visual) visual->Draw();
visual->DrawOverlay();
// Swap buffers // Swap buffers
glFinish(); glFinish();
@ -451,7 +454,7 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
} }
// Enforce correct cursor display // Enforce correct cursor display
ShowCursor(visual->mode != 0); ShowCursor(visualMode != 0);
// Click? // Click?
if (event.ButtonDown(wxMOUSE_BTN_ANY)) { if (event.ButtonDown(wxMOUSE_BTN_ANY)) {
@ -459,16 +462,21 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
} }
// Send to visual // Send to visual
wxASSERT(visual); if (visual) visual->OnMouseEvent(event);
visual->OnMouseEvent(event);
} }
///////////// /////////////
// Key event // Key event
void VideoDisplay::OnKey(wxKeyEvent &event) { void VideoDisplay::OnKey(wxKeyEvent &event) {
wxASSERT(visual); // FIXME: should these be configurable?
visual->OnKeyEvent(event); // Think of the frenchmen and other people not using qwerty layout
if (event.GetKeyCode() == 'A') SetVisualMode(0);
if (event.GetKeyCode() == 'S') SetVisualMode(1);
if (event.GetKeyCode() == 'D') SetVisualMode(2);
if (event.GetKeyCode() == 'F') SetVisualMode(3);
if (event.GetKeyCode() == 'G') SetVisualMode(4);
if (event.GetKeyCode() == 'H') SetVisualMode(5);
} }
@ -603,6 +611,7 @@ void VideoDisplay::OnSaveSnapshotRaw(wxCommandEvent &event) {
///////////////////// /////////////////////
// Copy coordinates // Copy coordinates
void VideoDisplay::OnCopyCoords(wxCommandEvent &event) { void VideoDisplay::OnCopyCoords(wxCommandEvent &event) {
wxLogMessage(_T("TODO: FIXME"));
if (wxTheClipboard->Open()) { if (wxTheClipboard->Open()) {
int sw,sh; int sw,sh;
VideoContext::Get()->GetScriptSize(sw,sh); VideoContext::Get()->GetScriptSize(sw,sh);
@ -614,23 +623,6 @@ void VideoDisplay::OnCopyCoords(wxCommandEvent &event) {
} }
//////////////////
// DrawVideoWithOverlay
void VideoDisplay::DrawText( wxPoint Pos, wxString text ) {
//// Draw frame
//wxClientDC dc(this);
//dc.SetBrush(wxBrush(wxColour(128,128,128),wxSOLID));
//dc.DrawRectangle( 0,0, provider->GetWidth(), provider->GetHeight() );
//dc.SetTextForeground(wxColour(64,64,64));
//dc.DrawText(text,Pos.x+1,Pos.y-1);
//dc.DrawText(text,Pos.x+1,Pos.y+1);
//dc.DrawText(text,Pos.x-1,Pos.y-1);
//dc.DrawText(text,Pos.x-1,Pos.y+1);
//dc.SetTextForeground(wxColour(255,255,255));
//dc.DrawText(text,Pos.x,Pos.y);
}
///////////////////////////// /////////////////////////////
// Convert mouse coordinates // Convert mouse coordinates
void VideoDisplay::ConvertMouseCoords(int &x,int &y) { void VideoDisplay::ConvertMouseCoords(int &x,int &y) {
@ -643,3 +635,19 @@ void VideoDisplay::ConvertMouseCoords(int &x,int &y) {
x = (x-dx1)*w/dx2; x = (x-dx1)*w/dx2;
y = (y-dy1)*h/dy2; y = (y-dy1)*h/dy2;
} }
////////////
// Set mode
void VideoDisplay::SetVisualMode(int mode) {
// Set visual
visualMode = mode;
delete visual;
switch (mode) {
case 0: visual = new VisualToolCross(this); break;
default: visual = NULL;
}
// Render
Render();
}

View file

@ -56,7 +56,7 @@ class AudioProvider;
class AudioDisplay; class AudioDisplay;
class AssDialogue; class AssDialogue;
class VideoProvider; class VideoProvider;
class VideoDisplayVisual; class VisualTool;
class VideoBox; class VideoBox;
@ -64,9 +64,11 @@ class VideoBox;
// Main class // Main class
class VideoDisplay: public wxGLCanvas { class VideoDisplay: public wxGLCanvas {
friend class AudioProvider; friend class AudioProvider;
friend class VideoDisplayVisual; friend class VisualTool;
private: private:
int visualMode;
wxSize origSize; wxSize origSize;
int w,h; int w,h;
int dx1,dx2,dy1,dy2; int dx1,dx2,dy1,dy2;
@ -88,7 +90,7 @@ private:
void OnSaveSnapshotRaw(wxCommandEvent &event); void OnSaveSnapshotRaw(wxCommandEvent &event);
public: public:
VideoDisplayVisual *visual; VisualTool *visual;
VideoBox *box; VideoBox *box;
double zoomValue; double zoomValue;
@ -107,12 +109,12 @@ public:
void ShowCursor(bool show); void ShowCursor(bool show);
void ConvertMouseCoords(int &x,int &y); void ConvertMouseCoords(int &x,int &y);
void DrawText(wxPoint Pos, wxString Text);
void UpdatePositionDisplay(); void UpdatePositionDisplay();
void UpdateSize(); void UpdateSize();
void SetZoom(double value); void SetZoom(double value);
void SetZoomPos(int pos); void SetZoomPos(int pos);
void UpdateSubsRelativeTime(); void UpdateSubsRelativeTime();
void SetVisualMode(int mode);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

File diff suppressed because it is too large Load diff

View file

@ -36,12 +36,12 @@
/////////// ///////////
// Headers // Headers
#include "video_draggable_feature.h" #include "visual_feature.h"
/////////////// ///////////////
// Constructor // Constructor
VideoDraggableFeature::VideoDraggableFeature() { VisualDraggableFeature::VisualDraggableFeature() {
type = DRAG_NONE; type = DRAG_NONE;
x = -1; x = -1;
y = -1; y = -1;
@ -51,12 +51,12 @@ VideoDraggableFeature::VideoDraggableFeature() {
///////////////////// /////////////////////
// Is mouse over it? // Is mouse over it?
bool VideoDraggableFeature::IsMouseOver(int x,int y) { bool VisualDraggableFeature::IsMouseOver(int x,int y) {
return false; return false;
} }
//////////////// ////////////////
// Draw feature // Draw feature
void VideoDraggableFeature::Draw(bool highlighted) { void VisualDraggableFeature::Draw(bool highlighted) {
} }

View file

@ -55,7 +55,7 @@ enum DraggableFeatureType {
///////////////////// /////////////////////
// Drag-able feature // Drag-able feature
class VideoDraggableFeature { class VisualDraggableFeature {
public: public:
DraggableFeatureType type; DraggableFeatureType type;
int x,y; int x,y;
@ -65,5 +65,5 @@ public:
bool IsMouseOver(int x,int y); bool IsMouseOver(int x,int y);
void Draw(bool highlighted); void Draw(bool highlighted);
VideoDraggableFeature(); VisualDraggableFeature();
}; };

338
aegisub/visual_tool.cpp Normal file
View file

@ -0,0 +1,338 @@
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
//////////////
// Headers
#include <wx/glcanvas.h>
#include <GL/glu.h>
#include <wx/wxprec.h>
#include "visual_tool.h"
#include "video_display.h"
#include "video_provider.h"
#include "vfr.h"
#include "ass_file.h"
#include "ass_time.h"
#include "ass_dialogue.h"
#include "ass_override.h"
#include "ass_style.h"
#include "subs_grid.h"
#include "options.h"
#include "subs_edit_box.h"
#include "export_visible_lines.h"
#include "utils.h"
///////////////
// Constructor
VisualTool::VisualTool(VideoDisplay *par) {
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);
}
//////////////
// Destructor
VisualTool::~VisualTool() {
}
////////////////////////
// Get position of line
void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y) {
int orgx=0,orgy=0;
GetLinePosition(diag,x,y,orgx,orgy);
}
void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) {
// No dialogue
if (!diag) {
x = -1;
y = -1;
return;
}
// Default values
int margin[4];
for (int i=0;i<4;i++) margin[i] = diag->Margin[i];
int align = 2;
// Get style
AssStyle *style = VideoContext::Get()->grid->ass->GetStyle(diag->Style);
if (style) {
align = style->alignment;
for (int i=0;i<4;i++) {
if (margin[i] == 0) margin[i] = style->Margin[i];
}
}
// Script size
int sw,sh;
VideoContext::Get()->GetScriptSize(sw,sh);
// Process margins
margin[3] = margin[2];
margin[1] = sw - margin[1];
margin[3] = sh - margin[3];
// Position
bool posSet = false;
bool orgSet = false;
int posx = -1;
int posy = -1;
// Overrides processing
diag->ParseASSTags();
AssDialogueBlockOverride *override;
AssOverrideTag *tag;
size_t blockn = diag->Blocks.size();
for (size_t i=0;i<blockn;i++) {
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(i));
if (override) {
for (size_t j=0;j<override->Tags.size();j++) {
tag = override->Tags.at(j);
// Position
if ((tag->Name == _T("\\pos") || tag->Name == _("\\move")) && tag->Params.size() >= 2) {
if (!posSet) {
posx = tag->Params[0]->AsInt();
posy = tag->Params[1]->AsInt();
posSet = true;
}
}
// Alignment
else if ((tag->Name == _T("\\an") || tag->Name == _T("\\a")) && tag->Params.size() >= 1) {
align = tag->Params[0]->AsInt();
if (tag->Name == _T("\\a")) {
switch(align) {
case 1: align = 1; break;
case 2: align = 2; break;
case 3: align = 3; break;
case 5: align = 7; break;
case 6: align = 8; break;
case 7: align = 9; break;
case 9: align = 4; break;
case 10: align = 5; break;
case 11: align = 6; break;
default: align = 2; break;
}
}
}
// Origin
else if (!orgSet && tag->Name == _T("\\org") && tag->Params.size() >= 2) {
orgx = tag->Params[0]->AsInt();
orgy = tag->Params[1]->AsInt();
orgSet = true;
}
}
}
}
diag->ClearBlocks();
// Got position
if (posSet) {
x = posx;
y = posy;
if (!orgSet) {
orgx = x;
orgy = y;
}
return;
}
// Alignment type
int hor = (align - 1) % 3;
int vert = (align - 1) / 3;
// Calculate positions
if (hor == 0) x = margin[0];
else if (hor == 1) x = (margin[0] + margin[1])/2;
else if (hor == 2) x = margin[1];
if (vert == 0) y = margin[3];
else if (vert == 1) y = (margin[2] + margin[3])/2;
else if (vert == 2) y = margin[2];
// No origin?
if (!orgSet) {
orgx = x;
orgy = y;
}
}
///////////////////////
// Get line's rotation
void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) {
// Default values
rx = ry = rz = 0.0f;
// Prepare overrides
diag->ParseASSTags();
AssDialogueBlockOverride *override;
AssOverrideTag *tag;
size_t blockn = diag->Blocks.size();
if (blockn == 0) {
diag->ClearBlocks();
return;
}
// Process override
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
if (override) {
for (size_t j=0;j<override->Tags.size();j++) {
tag = override->Tags.at(j);
if (tag->Name == _T("\\frx") && tag->Params.size() == 1) {
rx = tag->Params[0]->AsFloat();
}
if (tag->Name == _T("\\fry") && tag->Params.size() == 1) {
ry = tag->Params[0]->AsFloat();
}
if ((tag->Name == _T("\\frz") || tag->Name == _T("\fr")) && tag->Params.size() == 1) {
rz = tag->Params[0]->AsFloat();
}
}
}
diag->ClearBlocks();
}
////////////////////
// Get line's scale
void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) {
// Default values
scalX = scalY = 100.0f;
// Prepare overrides
diag->ParseASSTags();
AssDialogueBlockOverride *override;
AssOverrideTag *tag;
size_t blockn = diag->Blocks.size();
if (blockn == 0) {
diag->ClearBlocks();
return;
}
// Process override
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
if (override) {
for (size_t j=0;j<override->Tags.size();j++) {
tag = override->Tags.at(j);
if (tag->Name == _T("\\fscx") && tag->Params.size() == 1) {
scalX = tag->Params[0]->AsFloat();
}
if (tag->Name == _T("\\fscy") && tag->Params.size() == 1) {
scalY = tag->Params[0]->AsFloat();
}
}
}
diag->ClearBlocks();
}
///////////////////
// Get line's clip
void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2) {
// Default values
x1 = y1 = 0;
int sw,sh;
VideoContext::Get()->GetScriptSize(sw,sh);
x2 = sw-1;
y2 = sh-1;
// Prepare overrides
diag->ParseASSTags();
AssDialogueBlockOverride *override;
AssOverrideTag *tag;
size_t blockn = diag->Blocks.size();
if (blockn == 0) {
diag->ClearBlocks();
return;
}
// Process override
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
if (override) {
for (size_t j=0;j<override->Tags.size();j++) {
tag = override->Tags.at(j);
if (tag->Name == _T("\\clip") && tag->Params.size() == 4) {
x1 = tag->Params[0]->AsInt();
y1 = tag->Params[1]->AsInt();
x2 = tag->Params[2]->AsInt();
y2 = tag->Params[3]->AsInt();
}
}
}
diag->ClearBlocks();
}
///////////////
// Mouse event
void VisualTool::OnMouseEvent (wxMouseEvent &event) {
// Coords
int x = event.GetX();
int y = event.GetY();
parent->ConvertMouseCoords(x,y);
parent->GetClientSize(&w,&h);
VideoContext::Get()->GetScriptSize(sw,sh);
frame_n = VideoContext::Get()->GetFrameN();
// Hover
if (x != mouseX || y != mouseY) {
mouseX = x;
mouseY = y;
}
// Mouse leaving control
if (event.Leaving()) {
mouseX = -1;
mouseY = -1;
}
// Transformed mouse x/y
mx = mouseX * sw / w;
my = mouseY * sh / h;
// Clicks
leftClick = event.ButtonDown(wxMOUSE_BTN_LEFT);
leftDClick = event.LeftDClick();
// Update
Update();
}

View file

@ -39,9 +39,8 @@
/////////// ///////////
// Headers // Headers
#include "video_display.h"
#include "gl_wrap.h" #include "gl_wrap.h"
#include "video_draggable_feature.h"
#include <vector>
////////////// //////////////
@ -52,43 +51,35 @@ class AssDialogue;
//////////////////////// ////////////////////////
// Visual handler class // Visual handler class
class VideoDisplayVisual : public OpenGLWrapper { class VisualTool : public OpenGLWrapper {
friend class VideoDisplay;
private: private:
wxColour colour[4];
int mouseX,mouseY;
int startX,startY;
int curX,curY,curX2,curY2;
int origX,origY;
float curFloat1,startFloat1,origFloat1;
float curFloat2,startFloat2,origFloat2;
int lineOrgX,lineOrgY;
int mode;
int hold;
bool holding;
wxString mouseText;
AssDialogue *curSelection;
VideoDisplay *parent; VideoDisplay *parent;
std::vector<VideoDraggableFeature> drags; protected:
wxColour colour[4];
int w,h,sw,sh,mx,my;
int frame_n;
bool leftClick;
bool leftDClick;
void GetLinePosition(AssDialogue *diag,int &x,int &y); void GetLinePosition(AssDialogue *diag,int &x,int &y);
void GetLinePosition(AssDialogue *diag,int &x,int &y,int &orgx,int &orgy); void GetLinePosition(AssDialogue *diag,int &x,int &y,int &orgx,int &orgy);
void GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz); void GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz);
void GetLineScale(AssDialogue *diag,float &scalX,float &scalY); void GetLineScale(AssDialogue *diag,float &scalX,float &scalY);
void GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2); void GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2);
void FillPositionData();
void DrawOverlay(); VideoDisplay *GetParent() { return parent; }
void OnMouseEvent(wxMouseEvent &event);
void OnKeyEvent(wxKeyEvent &event);
public: public:
void SetMode(int mode); int mouseX,mouseY;
VideoDisplayVisual(VideoDisplay *parent); void OnMouseEvent(wxMouseEvent &event);
~VideoDisplayVisual(); virtual void Update()=0;
virtual void Draw()=0;
VisualTool(VideoDisplay *parent);
virtual ~VisualTool();
}; };

View file

@ -0,0 +1,142 @@
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
///////////
// Headers
#include "visual_tool_cross.h"
#include "gl_text.h"
#include "subs_grid.h"
#include "subs_edit_box.h"
#include "ass_file.h"
///////////////
// Constructor
VisualToolCross::VisualToolCross(VideoDisplay *_parent)
: VisualTool(_parent)
{
_parent->ShowCursor(false);
}
//////////////
// Destructor
VisualToolCross::~VisualToolCross() {
GetParent()->ShowCursor(true);
}
//////////
// Update
void VisualToolCross::Update() {
// Position
if (leftDClick) {
int vx = (sw * mouseX + w/2) / w;
int vy = (sh * mouseY + h/2) / h;
SubtitlesGrid *grid = VideoContext::Get()->grid;
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),vx,vy),0,false);
grid->editBox->CommitText();
grid->ass->FlagAsModified(_("positioning"));
grid->CommitChanges(false,true);
}
// Render parent
GetParent()->Render();
}
////////
// Draw
void VisualToolCross::Draw() {
// Is it outside?
if (mouseX == -1 || mouseY == -1) return;
// Draw cross
glDisable(GL_LINE_SMOOTH);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_INVERT);
glBegin(GL_LINES);
glColor3f(1.0f,1.0f,1.0f);
glVertex2f(0,my);
glVertex2f(sw,my);
glVertex2f(mx,0);
glVertex2f(mx,sh);
glEnd();
glDisable(GL_COLOR_LOGIC_OP);
// Switch display
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f,w,h,0.0f,-1000.0f,1000.0f);
glMatrixMode(GL_MODELVIEW);
// Text of current coords
int dx = mouseX;
int dy = mouseY;
int vx = (sw * dx + w/2) / w;
int vy = (sh * dy + h/2) / h;
wxString mouseText;
if (!wxGetMouseState().ShiftDown()) mouseText = wxString::Format(_T("%i,%i"),vx,vy);
else mouseText = wxString::Format(_T("%i,%i"),vx - sw,vy - sh);
// Setup gl text
int tw,th;
OpenGLText::SetFont(_T("Verdana"),12,true);
OpenGLText::SetColour(wxColour(255,255,255));
OpenGLText::GetExtent(mouseText,tw,th);
// Calculate draw position
bool left = dx > w/2;
bool bottom = dy < h/2;
// Text draw coords
if (left) dx -= tw + 4;
else dx += 4;
if (bottom) dy += 3;
else dy -= th + 3;
// Draw text
OpenGLText::Print(mouseText,dx,dy);
// Restore matrix
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}

View file

@ -0,0 +1,54 @@
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
///////////
// Headers
#include "visual_tool.h"
////////////////////////
// Crosshair tool class
class VisualToolCross : public VisualTool {
public:
VisualToolCross(VideoDisplay *parent);
~VisualToolCross();
void Update();
void Draw();
};