From e023831134d1d60a7a9882901e8aab6daa1e6c84 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 20 May 2010 08:55:29 +0000 Subject: [PATCH] Detangle the visual tools from SubsEditBox a bit by making changes to the file no longer go through the edit box. Originally committed to SVN as r4317. --- aegisub/src/audio_display.cpp | 153 ------------------------ aegisub/src/dialog_style_manager.cpp | 7 -- aegisub/src/visual_tool.cpp | 107 +++++++---------- aegisub/src/visual_tool.h | 21 +--- aegisub/src/visual_tool_clip.cpp | 22 ---- aegisub/src/visual_tool_cross.cpp | 11 +- aegisub/src/visual_tool_drag.cpp | 32 +---- aegisub/src/visual_tool_rotatexy.cpp | 32 +---- aegisub/src/visual_tool_rotatez.cpp | 29 +---- aegisub/src/visual_tool_scale.cpp | 17 +-- aegisub/src/visual_tool_vector_clip.cpp | 62 +--------- 11 files changed, 63 insertions(+), 430 deletions(-) diff --git a/aegisub/src/audio_display.cpp b/aegisub/src/audio_display.cpp index 6aec3ca8b..e45234bde 100644 --- a/aegisub/src/audio_display.cpp +++ b/aegisub/src/audio_display.cpp @@ -32,8 +32,6 @@ /// @file audio_display.cpp /// @brief Display audio in the main UI /// @ingroup audio_ui -/// - /////////// // Headers @@ -68,8 +66,6 @@ #include "vfr.h" #include "video_context.h" - - #ifdef __WXMAC__ /// DOCME @@ -80,10 +76,8 @@ # define AudioDisplayWindowStyle wxSUNKEN_BORDER | wxWANTS_CHARS #endif - /// @brief Constructor /// @param parent -/// AudioDisplay::AudioDisplay(wxWindow *parent) : wxWindow (parent, -1, wxDefaultPosition, wxSize(200,Options.AsInt(_T("Audio Display Height"))), AudioDisplayWindowStyle , _T("Audio Display")) { @@ -134,10 +128,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent) //wxLog::SetActiveTarget(new wxLogWindow(NULL,_T("Log"),true,false)); } - - /// @brief Destructor -/// AudioDisplay::~AudioDisplay() { if (player) player->CloseStream(); delete provider; @@ -158,10 +149,7 @@ AudioDisplay::~AudioDisplay() { min = NULL; } - - /// @brief Reset -/// void AudioDisplay::Reset() { wxLogDebug(_T("AudioDisplay::Reset")); hasSel = false; @@ -174,11 +162,8 @@ void AudioDisplay::Reset() { dialogue = NULL; } - - /// @brief Update image /// @param weak -/// void AudioDisplay::UpdateImage(bool weak) { // Update samples UpdateSamples(); @@ -191,9 +176,7 @@ void AudioDisplay::UpdateImage(bool weak) { Refresh(false); } - /// @brief Actually update the image on the display -/// /// This is where most actual drawing of the audio display happens, or other functions /// to draw specific parts are called from. void AudioDisplay::DoUpdateImage() { @@ -415,11 +398,8 @@ void AudioDisplay::DoUpdateImage() { needImageUpdateWeak = true; } - - /// @brief Draw other lines than the current active /// @param dc The DC to draw to. -/// /// Draws markers for inactive lines, eg. the previous line, per configuration. void AudioDisplay::DrawInactiveLines(wxDC &dc) { // Check if there is anything to do @@ -492,8 +472,6 @@ void AudioDisplay::DrawInactiveLines(wxDC &dc) { } } - - /// @brief Draw keyframe markers /// @param dc The DC to draw to. void AudioDisplay::DrawKeyframes(wxDC &dc) { @@ -516,8 +494,6 @@ void AudioDisplay::DrawKeyframes(wxDC &dc) { } } - - /// @brief Draw timescale at bottom of audio display /// @param dc The DC to draw to. void AudioDisplay::DrawTimescale(wxDC &dc) { @@ -582,8 +558,6 @@ void AudioDisplay::DrawTimescale(wxDC &dc) { } } - - /// @brief Draw audio waveform /// @param dc The DC to draw to. /// @param weak False if the visible portion of the display has changed. @@ -626,12 +600,9 @@ void AudioDisplay::DrawWaveform(wxDC &dc,bool weak) { } } - - /// @brief Draw spectrum analyzer /// @param finaldc The DC to draw to. /// @param weak False if the visible portion of the display has changed. -/// /// @bug Slow when non-weak and the selection has to be drawn, see: /// @ticket{951} Spectrum view scrolls/updates considerably slower when selection is visible void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) { @@ -684,12 +655,10 @@ void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) { } } - /// @brief Get selection position /// @param selStart /// @param selEnd /// @param cap -/// void AudioDisplay::GetDialoguePos(int64_t &selStart,int64_t &selEnd, bool cap) { selStart = GetXAtMS(curStartMS); selEnd = GetXAtMS(curEndMS); @@ -702,13 +671,10 @@ void AudioDisplay::GetDialoguePos(int64_t &selStart,int64_t &selEnd, bool cap) { } } - - /// @brief Get karaoke position /// @param karStart /// @param karEnd /// @param cap -/// void AudioDisplay::GetKaraokePos(int64_t &karStart,int64_t &karEnd, bool cap) { try { // Wrap around @@ -736,11 +702,8 @@ void AudioDisplay::GetKaraokePos(int64_t &karStart,int64_t &karEnd, bool cap) { } } - - /// @brief Update /// @return -/// void AudioDisplay::Update() { if (blockUpdate) return; if (loaded) { @@ -751,10 +714,7 @@ void AudioDisplay::Update() { } } - - /// @brief Recreate the image -/// void AudioDisplay::RecreateImage() { GetClientSize(&w,&h); h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0; @@ -763,11 +723,8 @@ void AudioDisplay::RecreateImage() { UpdateImage(false); } - - /// @brief Make dialogue visible /// @param force -/// void AudioDisplay::MakeDialogueVisible(bool force) { wxLogDebug(_T("AudioDisplay::MakeDialogueVisible(force=%d)"), force?1:0); // Variables @@ -799,11 +756,8 @@ void AudioDisplay::MakeDialogueVisible(bool force) { UpdateImage(); } - - /// @brief Set position /// @param pos -/// void AudioDisplay::SetPosition(int pos) { wxLogDebug(_T("AudioDisplay::SetPosition(pos=%d)"), pos); Position = pos; @@ -811,13 +765,10 @@ void AudioDisplay::SetPosition(int pos) { UpdateImage(); } - - /// @brief Update position /// @param pos /// @param IsSample /// @return -/// void AudioDisplay::UpdatePosition (int pos,bool IsSample) { // Safeguards if (!provider) return; @@ -832,14 +783,11 @@ void AudioDisplay::UpdatePosition (int pos,bool IsSample) { UpdateScrollbar(); } - - /// @brief Note: aka Horizontal Zoom Set samples in percentage /// @param percent /// @param update /// @param pivot /// @return -/// void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) { // Calculate if (percent < 1) percent = 1; @@ -863,11 +811,8 @@ void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) { } } - - /// @brief Update samples /// @return -/// void AudioDisplay::UpdateSamples() { // Set samples if (!provider) return; @@ -891,24 +836,18 @@ void AudioDisplay::UpdateSamples() { } } - - /// @brief Set scale /// @param _scale /// @return -/// void AudioDisplay::SetScale(float _scale) { if (scale == _scale) return; scale = _scale; UpdateImage(); } - - /// @brief Load from file /// @param file /// @return -/// void AudioDisplay::SetFile(wxString file) { wxLogDebug(_T("AudioDisplay::SetFile(file=%s)"), file.c_str()); // Unload @@ -1017,10 +956,7 @@ void AudioDisplay::SetFile(wxString file) { wxLogDebug(_T("AudioDisplay::SetFile: returning")); } - - /// @brief Load from video -/// void AudioDisplay::SetFromVideo() { wxLogDebug(_T("AudioDisplay::SetFromVideo")); if (VideoContext::Get()->IsLoaded()) { @@ -1031,20 +967,14 @@ void AudioDisplay::SetFromVideo() { } } - - /// @brief Reload audio -/// void AudioDisplay::Reload() { wxLogDebug(_T("AudioDisplay::Reload")); if (provider) SetFile(provider->GetFilename()); } - - /// @brief Update scrollbar /// @return -/// void AudioDisplay::UpdateScrollbar() { if (!provider) return; int page = w/12; @@ -1053,73 +983,52 @@ void AudioDisplay::UpdateScrollbar() { ScrollBar->SetScrollbar(Position/12,page,len,int(page*0.7),true); } - - /// @brief Gets the sample number at the x coordinate /// @param x /// @return -/// int64_t AudioDisplay::GetSampleAtX(int x) { return (x+Position)*samples; } - - /// @brief Gets the x coordinate corresponding to sample /// @param n /// @return -/// int AudioDisplay::GetXAtSample(int64_t n) { return samples ? (n/samples)-Position : 0; } - - /// @brief Get MS from X /// @param x /// @return -/// int AudioDisplay::GetMSAtX(int64_t x) { return (PositionSample+(x*samples)) * 1000 / provider->GetSampleRate(); } - - /// @brief Get X from MS /// @param ms /// @return -/// int AudioDisplay::GetXAtMS(int64_t ms) { return ((ms * provider->GetSampleRate() / 1000)-PositionSample)/samples; } - - /// @brief Get MS At sample /// @param x /// @return -/// int AudioDisplay::GetMSAtSample(int64_t x) { return x * 1000 / provider->GetSampleRate(); } - - /// @brief Get Sample at MS /// @param ms /// @return -/// int64_t AudioDisplay::GetSampleAtMS(int64_t ms) { return ms * provider->GetSampleRate() / 1000; } - - /// @brief Play /// @param start /// @param end /// @return -/// void AudioDisplay::Play(int start,int end) { wxLogDebug(_T("AudioDisplay::Play")); Stop(); @@ -1153,23 +1062,17 @@ void AudioDisplay::Play(int start,int end) { wxLogDebug(_T("AudioDisplay::Play: playback started, returning")); } - - /// @brief Stop -/// void AudioDisplay::Stop() { wxLogDebug(_T("AudioDisplay::Stop")); if (VideoContext::Get()->IsPlaying()) VideoContext::Get()->Stop(); if (player) player->Stop(); } - - /// @brief Get samples of dialogue /// @param start /// @param end /// @return -/// void AudioDisplay::GetTimesDialogue(int &start,int &end) { wxLogDebug(_T("AudioDisplay::GetTimesDialogue")); if (!dialogue) { @@ -1182,13 +1085,10 @@ void AudioDisplay::GetTimesDialogue(int &start,int &end) { end = dialogue->End.GetMS(); } - - /// @brief Get samples of selection /// @param start /// @param end /// @return -/// void AudioDisplay::GetTimesSelection(int &start,int &end) { wxLogDebug(_T("AudioDisplay::GetTimesSelection")); start = 0; @@ -1210,12 +1110,9 @@ void AudioDisplay::GetTimesSelection(int &start,int &end) { catch (...) {} } - - /// @brief Set the current selection /// @param start /// @param end -/// void AudioDisplay::SetSelection(int start, int end) { wxLogDebug(_T("AudioDisplay::SetSelection(start=%d, end=%d)"), start, end); curStartMS = start; @@ -1223,14 +1120,11 @@ void AudioDisplay::SetSelection(int start, int end) { Update(); } - - /// @brief Set dialogue /// @param _grid /// @param diag /// @param n /// @return -/// void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) { wxLogDebug(_T("AudioDisplay::SetDialogue")); // Actual parameters @@ -1275,12 +1169,9 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) { wxLogDebug(_T("AudioDisplay::SetDialogue: returning")); } - - /// @brief Commit changes /// @param nextLine /// @return -/// void AudioDisplay::CommitChanges (bool nextLine) { wxLogDebug(_T("AudioDisplay::CommitChanges(nextLine=%d)"), nextLine?1:0); // Loaded? @@ -1392,12 +1283,9 @@ void AudioDisplay::CommitChanges (bool nextLine) { wxLogDebug(_T("AudioDisplay::CommitChanges: returning")); } - - /// @brief Add lead /// @param in /// @param out -/// void AudioDisplay::AddLead(bool in,bool out) { // Lead in if (in) { @@ -1417,7 +1305,6 @@ void AudioDisplay::AddLead(bool in,bool out) { Update(); } - /////////////// // Event table BEGIN_EVENT_TABLE(AudioDisplay, wxWindow) @@ -1430,12 +1317,9 @@ BEGIN_EVENT_TABLE(AudioDisplay, wxWindow) EVT_KILL_FOCUS(AudioDisplay::OnLoseFocus) END_EVENT_TABLE() - - /// @brief Paint /// @param event /// @return -/// void AudioDisplay::OnPaint(wxPaintEvent& event) { if (w == 0 || h == 0) return; DoUpdateImage(); @@ -1444,12 +1328,9 @@ void AudioDisplay::OnPaint(wxPaintEvent& event) { if (origImage) dc.DrawBitmap(*origImage,0,0); } - - /// @brief Mouse event /// @param event /// @return -/// void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { // Get x,y int64_t x = event.GetX(); @@ -1854,15 +1735,12 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { if (defCursor) SetCursor(wxNullCursor); } - - /// @brief Get snap to boundary /// @param ms /// @param rangeX /// @param shiftHeld /// @param start /// @return -/// int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) { // Range? if (rangeX <= 0) return ms; @@ -1935,7 +1813,6 @@ int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) { return bestMS; } - // // SCRUBBING CODE, REMOVED FROM THE FUNCTION ABOVE /* @@ -2050,11 +1927,8 @@ int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) { */ - - /// @brief Size event /// @param event -/// void AudioDisplay::OnSize(wxSizeEvent &event) { // Set size GetClientSize(&w,&h); @@ -2071,12 +1945,9 @@ void AudioDisplay::OnSize(wxSizeEvent &event) { UpdateScrollbar(); } - - /// @brief Timer event /// @param event /// @return -/// void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) { if (!origImage) return; @@ -2161,11 +2032,8 @@ void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) { oldCurPos = curpos; } - - /// @brief Key down /// @param event -/// void AudioDisplay::OnKeyDown(wxKeyEvent &event) { int key = event.GetKeyCode(); #ifdef __APPLE__ @@ -2332,13 +2200,10 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) { } } - - /// @brief Change line /// @param delta /// @param block /// @return -/// void AudioDisplay::ChangeLine(int delta, bool block) { wxLogDebug(_T("AudioDisplay::ChangeLine(delta=%d)"), delta); if (dialogue) { @@ -2365,12 +2230,9 @@ void AudioDisplay::ChangeLine(int delta, bool block) { wxLogDebug(_T("AudioDisplay::ChangeLine: returning")); } - - /// @brief Next /// @param play /// @return -/// void AudioDisplay::Next(bool play) { wxLogDebug(_T("AudioDisplay::Next")); // Karaoke @@ -2423,12 +2285,9 @@ void AudioDisplay::Next(bool play) { wxLogDebug(_T("AudioDisplay::Next: returning")); } - - /// @brief Previous /// @param play /// @return -/// void AudioDisplay::Prev(bool play) { wxLogDebug(_T("AudioDisplay::Prev")); // Karaoke @@ -2479,12 +2338,9 @@ void AudioDisplay::Prev(bool play) { wxLogDebug(_T("AudioDisplay::Prev: returning")); } - - /// @brief Gets syllable at x position /// @param x /// @return -/// int AudioDisplay::GetSyllableAtX(int x) { if (!karaoke->enabled) return -1; int ms = GetMSAtX(x); @@ -2502,11 +2358,8 @@ int AudioDisplay::GetSyllableAtX(int x) { return -1; } - - /// @brief Focus events /// @param event -/// void AudioDisplay::OnGetFocus(wxFocusEvent &event) { if (!hasFocus) { hasFocus = true; @@ -2514,10 +2367,8 @@ void AudioDisplay::OnGetFocus(wxFocusEvent &event) { } } - /// @brief DOCME /// @param event -/// void AudioDisplay::OnLoseFocus(wxFocusEvent &event) { if (hasFocus && loaded) { hasFocus = false; @@ -2526,14 +2377,10 @@ void AudioDisplay::OnLoseFocus(wxFocusEvent &event) { } } - - /// @brief Update time edit controls -/// void AudioDisplay::UpdateTimeEditCtrls() { grid->editBox->StartTime->SetTime(curStartMS,true); grid->editBox->EndTime->SetTime(curEndMS,true); grid->editBox->Duration->SetTime(curEndMS-curStartMS,true); } - diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 27b1fa4c1..bb40e02bc 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -32,8 +32,6 @@ /// @file dialog_style_manager.cpp /// @brief Style Manager dialogue box and partial logic /// @ingroup style_editor -/// - #include "config.h" @@ -61,7 +59,6 @@ /// @brief Constructor /// @param parent /// @param _grid -/// DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid) : wxDialog (parent,-1,_("Styles Manager"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogStylesManager")) { @@ -368,7 +365,6 @@ BEGIN_EVENT_TABLE(DialogStyleManager, wxDialog) EVT_BUTTON(BUTTON_STORAGE_SORT, DialogStyleManager::OnStorageSort) END_EVENT_TABLE() - ////////// // Events @@ -1160,8 +1156,6 @@ int DialogStyleManager::lastx = -1; /// DOCME int DialogStyleManager::lasty = -1; - - /// @brief DialogStyleManagerEvent stuff /// @param ctrl DialogStyleManagerEvent::DialogStyleManagerEvent(DialogStyleManager *ctrl) { @@ -1171,7 +1165,6 @@ BEGIN_EVENT_TABLE(DialogStyleManagerEvent, wxEvtHandler) EVT_KEY_DOWN(DialogStyleManagerEvent::OnKeyDown) END_EVENT_TABLE() - void DialogStyleManagerEvent::OnKeyDown(wxKeyEvent &event) { control->OnKeyDown(event); //we need to access controls, so rather than make the controls public... } diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index e20e22108..7fb4cc0c4 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -32,11 +32,7 @@ /// @file visual_tool.cpp /// @brief Base class for visual typesetting functions /// @ingroup visual_ts -/// - -////////////// -// Headers #include "config.h" #ifndef AGI_PRE @@ -83,7 +79,6 @@ VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) frame_n = VideoContext::Get()->GetFrameN(); } - // Features if (CanDrag()) PopulateFeatureList(); } @@ -96,13 +91,11 @@ VisualTool::~VisualTool() { void VisualTool::OnMouseEvent (wxMouseEvent &event) { bool realTime = Options.AsBool(L"Video Visual Realtime"); - // Mouse leaving control if (event.Leaving()) { Update(); return; } - // Clicks leftClick = event.ButtonDown(wxMOUSE_BTN_LEFT); leftDClick = event.LeftDClick(); shiftDown = event.m_shiftDown; @@ -115,7 +108,6 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { // Drag a feature if (CanDrag()) { - // Populate list if needed if (!dragListOK) { PopulateFeatureList(); dragListOK = true; @@ -129,25 +121,20 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { } } - // Start dragging if (!dragging && leftClick && DragEnabled()) { - // Get a feature curFeature = GetHighlightedFeature(); if (curFeature != -1) { - // Initialize drag InitializeDrag(features[curFeature]); if (features[curFeature].lineN != -1) { VideoContext::Get()->grid->editBox->SetToLine(features[curFeature].lineN,true); VideoContext::Get()->grid->SelectRow(features[curFeature].lineN); } - // Set start value dragStartX = video.x; dragStartY = video.y; dragOrigX = features[curFeature].x; dragOrigY = features[curFeature].y; - // Set flags dragging = true; parent->CaptureMouse(); if (realTime) AssLimitToVisibleFilter::SetFrame(frame_n); @@ -155,7 +142,6 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { } if (dragging) { - // Dragging if (event.LeftIsDown()) { features[curFeature].x = (video.x - dragStartX + dragOrigX); features[curFeature].y = (video.y - dragStartY + dragOrigY); @@ -167,47 +153,34 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { features[curFeature].x = dragOrigX; } } - - // Update drag UpdateDrag(features[curFeature]); if (realTime) { - // Commit CommitDrag(features[curFeature]); Commit(); } } - - // Release else { - // Disable limiting if (realTime) AssLimitToVisibleFilter::SetFrame(-1); - // Commit dragging = false; CommitDrag(features[curFeature]); Commit(true); - // Clean up curFeature = -1; parent->ReleaseMouse(); parent->SetFocus(); } } - } // Hold if (!dragging && CanHold()) { - // Start holding if (!holding && event.LeftIsDown() && HoldEnabled()) { - // Get a dialogue curDiag = GetActiveDialogueLine(); if (curDiag) { - // Initialize Drag InitializeHold(); - // Set flags holding = true; parent->CaptureMouse(); if (realTime) AssLimitToVisibleFilter::SetFrame(frame_n); @@ -215,29 +188,21 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { } if (holding) { - // Holding if (event.LeftIsDown()) { - // Update drag UpdateHold(); if (realTime) { - // Commit CommitHold(); Commit(); } } - - // Release else { - // Disable limiting if (realTime) AssLimitToVisibleFilter::SetFrame(-1); - // Commit holding = false; CommitHold(); Commit(true); - // Clean up curDiag = NULL; parent->ReleaseMouse(); parent->SetFocus(); @@ -245,31 +210,18 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { } } - // Update Update(); } /// @brief Commit /// @param full void VisualTool::Commit(bool full) { - // Get grid SubtitlesGrid *grid = VideoContext::Get()->grid; - - // See if anything actually changed - // Fix by jfs: Only if not doing a full commit. Not sure why, but this avoids bug #532 - if (!full) { - AssDialogue *diag = grid->GetDialogue(grid->editBox->linen); - if (diag && grid->editBox->TextEdit->GetText() == diag->Text) return; - } - - // Commit changes - grid->editBox->CommitText(); if (full) grid->ass->FlagAsModified(_("visual typesetting")); grid->CommitChanges(false,!full); + grid->editBox->Update(false, true, false); } - - /// @brief Get active dialogue line /// @return AssDialogue* VisualTool::GetActiveDialogueLine() { @@ -281,7 +233,6 @@ AssDialogue* VisualTool::GetActiveDialogueLine() { int f1 = VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true); int f2 = VFR_Output.GetFrameAtTime(diag->End.GetMS(),false); - // Invisible if (f1 > frame_n || f2 < frame_n) return NULL; } @@ -304,17 +255,14 @@ int VisualTool::GetHighlightedFeature() { /// @brief Draw all features void VisualTool::DrawAllFeatures() { - // Populate list, if needed if (!dragListOK) { PopulateFeatureList(); dragListOK = true; } - // Get feature that mouse is over int mouseOver = curFeature; if (curFeature == -1) mouseOver = GetHighlightedFeature(); - // Draw features for (size_t i=0;iMargin[i]; int align = 2; - // Get style AssStyle *style = VideoContext::Get()->grid->ass->GetStyle(diag->Style); if (style) { align = style->alignment; @@ -368,7 +313,6 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, in } } - // Script size int sw,sh; VideoContext::Get()->GetScriptSize(sw,sh); @@ -581,8 +525,6 @@ void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) { diag->ClearBlocks(); } - - /// @brief Get line's clip /// @param diag /// @param x1 @@ -636,8 +578,6 @@ void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,b parent->FromScriptCoords(&x2, &y2); } - - /// @brief Get line vector clip, if it exists /// @param diag /// @param scale @@ -687,7 +627,46 @@ wxString VisualTool::GetLineVectorClip(AssDialogue *diag,int &scale,bool &invers /// @brief Set override /// @param tag /// @param value -void VisualTool::SetOverride(wxString tag,wxString value) { - VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false); - //parent->SetFocus(); +void VisualTool::SetOverride(AssDialogue* line, wxString tag, wxString value) { + if (!line) return; + + wxString removeTag; + if (tag == L"\\1c") removeTag = L"\\c"; + else if (tag == L"\\fr") removeTag = L"\\frz"; + else if (tag == L"\\pos") removeTag = L"\\move"; + else if (tag == L"\\move") removeTag = L"\\pos"; + else if (tag == L"\\clip") removeTag = L"\\iclip"; + else if (tag == L"\\iclip") removeTag = L"\\clip"; + + wxString insert = tag + value; + + // Get block at start + line->ParseASSTags(); + AssDialogueBlock *block = line->Blocks.at(0); + + // Get current block as plain or override + AssDialogueBlockPlain *plain = dynamic_cast(block); + AssDialogueBlockOverride *ovr = dynamic_cast(block); + + if (plain) { + line->Text = L"{" + insert + L"}" + line->Text; + } + else if (ovr) { + ovr->text += insert; + ovr->ParseTags(); + + // Remove old of same + for (size_t i = 0; i < ovr->Tags.size() - 1; i++) { + wxString name = ovr->Tags.at(i)->Name; + if (tag == name || removeTag == name) { + delete ovr->Tags.at(i); + ovr->Tags.erase(ovr->Tags.begin() + i); + i--; + } + } + + line->UpdateText(); + } + + parent->SetFocus(); } diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 7d9e4a14a..9e217a8d5 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -32,12 +32,9 @@ /// @file visual_tool.h /// @see visual_tool.cpp /// @ingroup visual_ts -/// - #pragma once - /////////// // Headers #ifndef AGI_PRE @@ -51,7 +48,6 @@ #include "gl_wrap.h" #include "visual_feature.h" - ////////////// // Prototypes class VideoDisplay; @@ -59,20 +55,15 @@ class AssDialogue; class VisualTool; struct VideoState; - - /// DOCME #define VISUAL_SUB_TOOL_START 1300 /// DOCME #define VISUAL_SUB_TOOL_END (VISUAL_SUB_TOOL_START+100) - - /// DOCME /// @class VisualTool /// @brief DOCME -/// /// DOCME class VisualTool : public OpenGLWrapper { int GetHighlightedFeature(); @@ -83,14 +74,12 @@ protected: /// DOCME static const wxColour colour[4]; - /// DOCME bool holding; /// DOCME AssDialogue *curDiag; - /// DOCME bool dragging; @@ -112,13 +101,11 @@ protected: /// DOCME bool dragListOK; - /// DOCME int frame_n; VideoState const& video; - /// DOCME bool leftClick; @@ -141,8 +128,7 @@ protected: void GetLineScale(AssDialogue *diag,float &scalX,float &scalY); void GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,bool &inverse); wxString GetLineVectorClip(AssDialogue *diag,int &scale,bool &inverse); - void SetOverride(wxString tag,wxString value); - + void SetOverride(AssDialogue* line, wxString tag, wxString value); AssDialogue *GetActiveDialogueLine(); void DrawAllFeatures(); @@ -171,7 +157,6 @@ protected: /// virtual void CommitHold() {} - /// @brief DOCME /// @return /// @@ -206,7 +191,6 @@ protected: /// virtual void ClickedFeature(VisualDraggableFeature &feature) {} - /// @brief DOCME /// virtual void DoRefresh() {} @@ -226,6 +210,3 @@ public: virtual ~VisualTool(); }; - - - diff --git a/aegisub/src/visual_tool_clip.cpp b/aegisub/src/visual_tool_clip.cpp index 6ff8bfcaa..49f05d26c 100644 --- a/aegisub/src/visual_tool_clip.cpp +++ b/aegisub/src/visual_tool_clip.cpp @@ -32,8 +32,6 @@ /// @file visual_tool_clip.cpp /// @brief Rectangular clipping visual typesetting tool /// @ingroup visual_ts -/// - /////////// // Headers @@ -47,10 +45,8 @@ #include "video_display.h" #include "visual_tool_clip.h" - /// @brief Constructor /// @param _parent -/// VisualToolClip::VisualToolClip(VideoDisplay *parent, VideoState const& video, wxToolBar *) : VisualTool(parent, video) , curX1(0) @@ -114,10 +110,7 @@ void VisualToolClip::InitializeHold() { curDiag->StripTag(L"\\iclip"); } - - /// @brief Update hold -/// void VisualToolClip::UpdateHold() { // Coordinates curX1 = startX; @@ -139,10 +132,7 @@ void VisualToolClip::UpdateHold() { if (CanDrag()) PopulateFeatureList(); } - - /// @brief Commit hold -/// void VisualToolClip::CommitHold() { int x1 = curX1; int x2 = curX2; @@ -153,10 +143,7 @@ void VisualToolClip::CommitHold() { SetOverride(GetActiveDialogueLine(), inverse ? L"\\iclip" : L"\\clip",wxString::Format(L"(%i,%i,%i,%i)",x1,y1,x2,y2)); } - - /// @brief Populate feature list -/// void VisualToolClip::PopulateFeatureList() { // Clear if (features.size() != 4) { @@ -202,22 +189,16 @@ void VisualToolClip::PopulateFeatureList() { i++; } - - /// @brief Initialize /// @param feature -/// void VisualToolClip::InitializeDrag(VisualDraggableFeature &feature) { curDiag = GetActiveDialogueLine(); curDiag->StripTag(L"\\clip"); curDiag->StripTag(L"\\iclip"); } - - /// @brief Update drag /// @param feature -/// void VisualToolClip::UpdateDrag(VisualDraggableFeature &feature) { // Update brothers features[feature.brother[0]].y = feature.y; @@ -234,11 +215,8 @@ void VisualToolClip::UpdateDrag(VisualDraggableFeature &feature) { if (curY1 > curY2) IntSwap(curY1,curY2); } - - /// @brief Done dragging /// @param feature -/// void VisualToolClip::CommitDrag(VisualDraggableFeature &feature) { CommitHold(); } diff --git a/aegisub/src/visual_tool_cross.cpp b/aegisub/src/visual_tool_cross.cpp index cd7072bfa..df1703551 100644 --- a/aegisub/src/visual_tool_cross.cpp +++ b/aegisub/src/visual_tool_cross.cpp @@ -32,8 +32,6 @@ /// @file visual_tool_cross.cpp /// @brief Crosshair double-click-to-position visual typesetting tool /// @ingroup visual_ts -/// - /////////// // Headers @@ -47,10 +45,8 @@ #include "video_display.h" #include "visual_tool_cross.h" - /// @brief Constructor /// @param _parent -/// VisualToolCross::VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *) : VisualTool(parent, video) { @@ -58,7 +54,6 @@ VisualToolCross::VisualToolCross(VideoDisplay *parent, VideoState const& video, VisualToolCross::~VisualToolCross() { } /// @brief Update -/// void VisualToolCross::Update() { // Position if (leftDClick) { @@ -66,15 +61,13 @@ void VisualToolCross::Update() { int vy = video.y; parent->ToScriptCoords(&vx, &vy); SubtitlesGrid *grid = VideoContext::Get()->grid; - SetOverride(L"\\pos",wxString::Format(L"(%i,%i)",vx,vy)); - grid->editBox->CommitText(); + SetOverride(GetActiveDialogueLine(), L"\\pos",wxString::Format(L"(%i,%i)",vx,vy)); grid->ass->FlagAsModified(_("positioning")); grid->CommitChanges(false,true); + grid->editBox->Update(false, true, false); } } - - /// @brief Draw void VisualToolCross::Draw() { // Draw cross diff --git a/aegisub/src/visual_tool_drag.cpp b/aegisub/src/visual_tool_drag.cpp index c63e81f4a..80f5edb1b 100644 --- a/aegisub/src/visual_tool_drag.cpp +++ b/aegisub/src/visual_tool_drag.cpp @@ -32,7 +32,6 @@ /// @file visual_tool_drag.cpp /// @brief Position all visible subtitles by dragging visual typesetting tool /// @ingroup visual_ts -/// #include "config.h" @@ -51,12 +50,9 @@ enum { BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START }; - - /// @brief Constructor /// @param _parent /// @param toolBar -/// VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar) : VisualTool(parent, video) , toolBar(toolBar) @@ -67,11 +63,8 @@ VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wx toolBar->Show(true); } - - /// @brief Update toggle buttons /// @return -/// void VisualToolDrag::UpdateToggleButtons() { // Check which bitmap to use bool toMove = true; @@ -96,8 +89,6 @@ void VisualToolDrag::UpdateToggleButtons() { toggleMoveOnMove = toMove; } - - /// @brief Toggle button pressed /// @param event /// @return @@ -117,8 +108,8 @@ void VisualToolDrag::OnSubTool(wxCommandEvent &event) { parent->ToScriptCoords(&x2, &y2); // Replace tag - if (hasMove) SetOverride(L"\\pos",wxString::Format(L"(%i,%i)",x1,y1)); - else SetOverride(L"\\move",wxString::Format(L"(%i,%i,%i,%i,%i,%i)",x1,y1,x1,y1,0,line->End.GetMS() - line->Start.GetMS())); + if (hasMove) SetOverride(line, L"\\pos",wxString::Format(L"(%i,%i)",x1,y1)); + else SetOverride(line, L"\\move",wxString::Format(L"(%i,%i,%i,%i,%i,%i)",x1,y1,x1,y1,0,line->End.GetMS() - line->Start.GetMS())); Commit(true); // Update display @@ -126,16 +117,12 @@ void VisualToolDrag::OnSubTool(wxCommandEvent &event) { } } - - /// @brief Refresh -/// void VisualToolDrag::DoRefresh() { UpdateToggleButtons(); } /// @brief Draw -/// void VisualToolDrag::Draw() { DrawAllFeatures(); @@ -189,10 +176,7 @@ void VisualToolDrag::Draw() { } } - - /// @brief Populate list -/// void VisualToolDrag::PopulateFeatureList() { // Clear features features.clear(); @@ -271,25 +255,21 @@ void VisualToolDrag::PopulateFeatureList() { /// @brief Update drag /// @param feature -/// void VisualToolDrag::UpdateDrag(VisualDraggableFeature &feature) { // Update "value" to reflect the time of the frame in which the feature is being dragged int time = VFR_Output.GetTimeAtFrame(frame_n,true,true); feature.value = MID(0,time - feature.line->Start.GetMS(),feature.line->End.GetMS()-feature.line->Start.GetMS()); } - - /// @brief Commit drag /// @param feature -/// void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { // Origin if (feature.type == DRAG_BIG_TRIANGLE) { int x = feature.x; int y = feature.y; parent->ToScriptCoords(&x, &y); - SetOverride(L"\\org",wxString::Format(L"(%i,%i)",x,y)); + SetOverride(feature.line, L"\\org",wxString::Format(L"(%i,%i)",x,y)); } // Position @@ -297,7 +277,7 @@ void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { int x = feature.x; int y = feature.y; parent->ToScriptCoords(&x, &y); - SetOverride(L"\\pos",wxString::Format(L"(%i,%i)",x,y)); + SetOverride(feature.line, L"\\pos",wxString::Format(L"(%i,%i)",x,y)); } // Move @@ -316,8 +296,6 @@ void VisualToolDrag::CommitDrag(VisualDraggableFeature &feature) { parent->ToScriptCoords(&x2, &y2); // Set override - SetOverride(L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1, y1, x2, y2, p1->value, p2->value)); + SetOverride(feature.line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1, y1, x2, y2, p1->value, p2->value)); } } - - diff --git a/aegisub/src/visual_tool_rotatexy.cpp b/aegisub/src/visual_tool_rotatexy.cpp index 5c97ad393..06fb0e308 100644 --- a/aegisub/src/visual_tool_rotatexy.cpp +++ b/aegisub/src/visual_tool_rotatexy.cpp @@ -32,7 +32,6 @@ /// @file visual_tool_rotatexy.cpp /// @brief 3D rotation in X/Y axes visual typesetting tool /// @ingroup visual_ts -/// #include "config.h" @@ -48,10 +47,8 @@ #include "video_display.h" #include "visual_tool_rotatexy.h" - /// @brief Constructor /// @param _parent -/// VisualToolRotateXY::VisualToolRotateXY(VideoDisplay *parent, VideoState const& video, wxToolBar *) : VisualTool(parent, video) { @@ -168,10 +165,7 @@ void VisualToolRotateXY::Draw() { glShadeModel(GL_FLAT); } - - /// @brief Start holding -/// void VisualToolRotateXY::InitializeHold() { GetLinePosition(curDiag,odx,ody,orgx,orgy); GetLineRotation(curDiag,origAngleX,origAngleY,rz); @@ -183,10 +177,7 @@ void VisualToolRotateXY::InitializeHold() { curDiag->StripTag(L"\\fry"); } - - /// @brief Update hold -/// void VisualToolRotateXY::UpdateHold() { // Find screen angles float screenAngleX = (orgy-video.x)*2.0; @@ -213,19 +204,14 @@ void VisualToolRotateXY::UpdateHold() { } } - - /// @brief Commit hold -/// void VisualToolRotateXY::CommitHold() { - SetOverride(L"\\frx",wxString::Format(L"(%0.3g)",curAngleX)); - SetOverride(L"\\fry",wxString::Format(L"(%0.3g)",curAngleY)); + AssDialogue* line = GetActiveDialogueLine(); + SetOverride(line, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX)); + SetOverride(line, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY)); } - - /// @brief Get \\org pivot -/// void VisualToolRotateXY::PopulateFeatureList() { // Get line curDiag = GetActiveDialogueLine(); @@ -240,36 +226,26 @@ void VisualToolRotateXY::PopulateFeatureList() { feat.type = DRAG_BIG_TRIANGLE; } - - /// @brief Update dragging of \\org /// @param feature -/// void VisualToolRotateXY::UpdateDrag(VisualDraggableFeature &feature) { orgx = feature.x; orgy = feature.y; } - - /// @brief Commit dragging of \\org /// @param feature -/// void VisualToolRotateXY::CommitDrag(VisualDraggableFeature &feature) { int x = feature.x; int y = feature.y; parent->ToScriptCoords(&x, &y); - SetOverride(L"\\org",wxString::Format(L"(%i,%i)",x,y)); + SetOverride(feature.line, L"\\org",wxString::Format(L"(%i,%i)",x,y)); } - - /// @brief Refresh -/// void VisualToolRotateXY::DoRefresh() { AssDialogue *line = GetActiveDialogueLine(); GetLinePosition(line,odx,ody,orgx,orgy); GetLineRotation(line,curAngleX,curAngleY,rz); } - diff --git a/aegisub/src/visual_tool_rotatez.cpp b/aegisub/src/visual_tool_rotatez.cpp index 019ff4f00..212c47b4b 100644 --- a/aegisub/src/visual_tool_rotatez.cpp +++ b/aegisub/src/visual_tool_rotatez.cpp @@ -32,7 +32,6 @@ /// @file visual_tool_rotatez.cpp /// @brief 2D rotation in Z axis visual typesetting tool /// @ingroup visual_ts -/// #include "config.h" @@ -48,10 +47,8 @@ #include "video_display.h" #include "visual_tool_rotatez.h" - /// @brief Constructor /// @param _parent -/// VisualToolRotateZ::VisualToolRotateZ(VideoDisplay *parent, VideoState const& video, wxToolBar *) : VisualTool(parent, video) { @@ -153,10 +150,7 @@ void VisualToolRotateZ::Draw() { } } - - /// @brief Start holding -/// void VisualToolRotateZ::InitializeHold() { GetLinePosition(curDiag,odx,ody,orgx,orgy); startAngle = atan2(double(orgy-video.y),double(video.x-orgx)) * 180.0 / 3.1415926535897932; @@ -166,10 +160,7 @@ void VisualToolRotateZ::InitializeHold() { curDiag->StripTag(L"\\fr"); } - - /// @brief Update hold -/// void VisualToolRotateZ::UpdateHold() { // Find angle float screenAngle = atan2(double(orgy-video.y),double(video.x-orgx)) * 180.0 / 3.1415926535897932; @@ -182,18 +173,12 @@ void VisualToolRotateZ::UpdateHold() { } } - - /// @brief Commit hold -/// void VisualToolRotateZ::CommitHold() { - SetOverride(L"\\frz",wxString::Format(L"(%0.3g)",curAngle)); + SetOverride(GetActiveDialogueLine(), L"\\frz",wxString::Format(L"(%0.3g)",curAngle)); } - - /// @brief Get \\org pivot -/// void VisualToolRotateZ::PopulateFeatureList() { // Get line curDiag = GetActiveDialogueLine(); @@ -208,36 +193,26 @@ void VisualToolRotateZ::PopulateFeatureList() { feat.type = DRAG_BIG_TRIANGLE; } - - /// @brief Update dragging of \\org /// @param feature -/// void VisualToolRotateZ::UpdateDrag(VisualDraggableFeature &feature) { orgx = feature.x; orgy = feature.y; } - - /// @brief Commit dragging of \\org /// @param feature -/// void VisualToolRotateZ::CommitDrag(VisualDraggableFeature &feature) { int x = feature.x; int y = feature.y; parent->ToScriptCoords(&x, &y); - SetOverride(L"\\org",wxString::Format(L"(%i,%i)",x,y)); + SetOverride(feature.line, L"\\org",wxString::Format(L"(%i,%i)",x,y)); } - - /// @brief Refresh -/// void VisualToolRotateZ::DoRefresh() { AssDialogue *line = GetActiveDialogueLine(); GetLinePosition(line,odx,ody,orgx,orgy); GetLineRotation(line,rx,ry,curAngle); } - diff --git a/aegisub/src/visual_tool_scale.cpp b/aegisub/src/visual_tool_scale.cpp index e3a5a4cbb..ef07a315f 100644 --- a/aegisub/src/visual_tool_scale.cpp +++ b/aegisub/src/visual_tool_scale.cpp @@ -32,7 +32,6 @@ /// @file visual_tool_scale.cpp /// @brief X/Y scaling visual typesetting tool /// @ingroup visual_ts -/// #include "config.h" @@ -48,10 +47,8 @@ #include "video_display.h" #include "visual_tool_scale.h" - /// @brief Constructor /// @param _parent -/// VisualToolScale::VisualToolScale(VideoDisplay *parent, VideoState const& video, wxToolBar *) : VisualTool(parent, video) { @@ -126,10 +123,7 @@ void VisualToolScale::Draw() { glPopMatrix(); } - - /// @brief Start holding -/// void VisualToolScale::InitializeHold() { startX = video.x; startY = video.y; @@ -140,10 +134,7 @@ void VisualToolScale::InitializeHold() { curDiag->StripTag(_T("\\fscy")); } - - /// @brief Update hold -/// void VisualToolScale::UpdateHold() { using std::max; // Deltas @@ -165,13 +156,9 @@ void VisualToolScale::UpdateHold() { } } - - /// @brief Commit hold -/// void VisualToolScale::CommitHold() { - SetOverride(_T("\\fscx"),wxString::Format(L"(%0.3g)",curScaleX)); - SetOverride(_T("\\fscy"),wxString::Format(L"(%0.3g)",curScaleY)); + SetOverride(GetActiveDialogueLine(), _T("\\fscx"),wxString::Format(L"(%0.3g)",curScaleX)); + SetOverride(GetActiveDialogueLine(), _T("\\fscy"),wxString::Format(L"(%0.3g)",curScaleY)); } - diff --git a/aegisub/src/visual_tool_vector_clip.cpp b/aegisub/src/visual_tool_vector_clip.cpp index 4f804562d..da85dbe12 100644 --- a/aegisub/src/visual_tool_vector_clip.cpp +++ b/aegisub/src/visual_tool_vector_clip.cpp @@ -32,7 +32,6 @@ /// @file visual_tool_vector_clip.cpp /// @brief Vector clipping visual typesetting tool /// @ingroup visual_ts -/// #ifndef AGI_PRE #include @@ -45,7 +44,6 @@ #include "video_display.h" #include "visual_tool_vector_clip.h" - /////// // IDs enum { @@ -78,12 +76,9 @@ enum { BUTTON_LAST // Leave this at the end and don't use it }; - - /// @brief Constructor /// @param parent /// @param _toolBar -/// VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar) : VisualTool(parent, video), toolBar(toolBar), spline(*parent) { @@ -110,20 +105,14 @@ VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, VideoState cons if (features.size() == 0) SetMode(1); } - - /// @brief Sub-tool pressed /// @param event -/// void VisualToolVectorClip::OnSubTool(wxCommandEvent &event) { SetMode(event.GetId() - BUTTON_DRAG); } - - /// @brief Set mode /// @param _mode -/// void VisualToolVectorClip::SetMode(int _mode) { // Make sure clicked is checked and everything else isn't. (Yes, this is radio behavior, but the separators won't let me use it) for (int i=BUTTON_DRAG;i