forked from mia/Aegisub
Announce the set of lines changed in commits
Currently this is only populated when commits are amended, for the simple reason that it's the only time that AssFile knows what lines changed. It is probably worth expanding this in the future.
This commit is contained in:
parent
4e72fff1d9
commit
fee60be5db
5 changed files with 26 additions and 11 deletions
|
@ -215,6 +215,18 @@ public:
|
||||||
UnscopedConnection Connect(void (T::*func)(Arg1, Arg2), T* a1) {
|
UnscopedConnection Connect(void (T::*func)(Arg1, Arg2), T* a1) {
|
||||||
return Connect(std::bind(func, a1, _1, _2));
|
return Connect(std::bind(func, a1, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Connect a member function with the correct signature to this signal
|
||||||
|
/// @param func Function to connect
|
||||||
|
/// @param a1 Object
|
||||||
|
///
|
||||||
|
/// This overload is purely for convenience so that classes can do
|
||||||
|
/// sig.Connect(&Class::Foo, this) rather than
|
||||||
|
/// sig.Connect(&Class::Foo, this, _1)
|
||||||
|
template<class T>
|
||||||
|
UnscopedConnection Connect(void (T::*func)(Arg1), T* a1) {
|
||||||
|
return Connect(std::bind(func, a1, _1));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @class Signal
|
/// @class Signal
|
||||||
|
|
|
@ -372,6 +372,10 @@ void AssFile::AddToRecent(wxString const& file) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int AssFile::Commit(wxString const& desc, int type, int amendId, AssEntry *single_line) {
|
int AssFile::Commit(wxString const& desc, int type, int amendId, AssEntry *single_line) {
|
||||||
|
std::set<const AssEntry*> changed_lines;
|
||||||
|
if (single_line)
|
||||||
|
changed_lines.insert(single_line);
|
||||||
|
|
||||||
++commitId;
|
++commitId;
|
||||||
// Allow coalescing only if it's the last change and the file has not been
|
// Allow coalescing only if it's the last change and the file has not been
|
||||||
// saved since the last change
|
// saved since the last change
|
||||||
|
@ -389,7 +393,7 @@ int AssFile::Commit(wxString const& desc, int type, int amendId, AssEntry *singl
|
||||||
else {
|
else {
|
||||||
UndoStack.back() = *this;
|
UndoStack.back() = *this;
|
||||||
}
|
}
|
||||||
AnnounceCommit(type);
|
AnnounceCommit(type, changed_lines);
|
||||||
return commitId;
|
return commitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +412,7 @@ int AssFile::Commit(wxString const& desc, int type, int amendId, AssEntry *singl
|
||||||
if (UndoStack.size() > 1 && OPT_GET("App/Auto/Save on Every Change")->GetBool() && !filename.empty() && CanSave())
|
if (UndoStack.size() > 1 && OPT_GET("App/Auto/Save on Every Change")->GetBool() && !filename.empty() && CanSave())
|
||||||
Save(filename);
|
Save(filename);
|
||||||
|
|
||||||
AnnounceCommit(type);
|
AnnounceCommit(type, changed_lines);
|
||||||
return commitId;
|
return commitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +424,7 @@ void AssFile::Undo() {
|
||||||
UndoStack.pop_back();
|
UndoStack.pop_back();
|
||||||
*this = UndoStack.back();
|
*this = UndoStack.back();
|
||||||
|
|
||||||
AnnounceCommit(COMMIT_NEW);
|
AnnounceCommit(COMMIT_NEW, std::set<const AssEntry*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssFile::Redo() {
|
void AssFile::Redo() {
|
||||||
|
@ -430,7 +434,7 @@ void AssFile::Redo() {
|
||||||
UndoStack.push_back(*this);
|
UndoStack.push_back(*this);
|
||||||
RedoStack.pop_back();
|
RedoStack.pop_back();
|
||||||
|
|
||||||
AnnounceCommit(COMMIT_NEW);
|
AnnounceCommit(COMMIT_NEW, std::set<const AssEntry*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString AssFile::GetUndoDescription() const {
|
wxString AssFile::GetUndoDescription() const {
|
||||||
|
|
|
@ -33,14 +33,12 @@
|
||||||
///
|
///
|
||||||
|
|
||||||
#include <boost/container/list.hpp>
|
#include <boost/container/list.hpp>
|
||||||
|
#include <boost/intrusive/list.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/arrstr.h>
|
#include <wx/arrstr.h>
|
||||||
|
|
||||||
#include <boost/intrusive/list.hpp>
|
|
||||||
|
|
||||||
#include <libaegisub/signal.h>
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
#include "ass_entry.h"
|
#include "ass_entry.h"
|
||||||
|
@ -65,7 +63,7 @@ class AssFile {
|
||||||
int autosavedCommitId;
|
int autosavedCommitId;
|
||||||
|
|
||||||
/// A set of changes has been committed to the file (AssFile::CommitType)
|
/// A set of changes has been committed to the file (AssFile::CommitType)
|
||||||
agi::signal::Signal<int> AnnounceCommit;
|
agi::signal::Signal<int, std::set<const AssEntry*> const&> AnnounceCommit;
|
||||||
/// A new file has been opened (filename)
|
/// A new file has been opened (filename)
|
||||||
agi::signal::Signal<wxString> FileOpen;
|
agi::signal::Signal<wxString> FileOpen;
|
||||||
/// The file is about to be saved
|
/// The file is about to be saved
|
||||||
|
|
|
@ -118,8 +118,8 @@ void AudioKaraoke::OnActiveLineChanged(AssDialogue *new_line) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioKaraoke::OnFileChanged(int type) {
|
void AudioKaraoke::OnFileChanged(int type, std::set<const AssEntry *> const& changed) {
|
||||||
if (enabled && (type & AssFile::COMMIT_DIAG_FULL)) {
|
if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (changed.empty() || changed.count(active_line))) {
|
||||||
LoadFromLine();
|
LoadFromLine();
|
||||||
split_area->Refresh(false);
|
split_area->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <libaegisub/signal.h>
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
class AssDialogue;
|
class AssDialogue;
|
||||||
|
class AssEntry;
|
||||||
class AssKaraoke;
|
class AssKaraoke;
|
||||||
class wxButton;
|
class wxButton;
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ class AudioKaraoke : public wxWindow {
|
||||||
void OnActiveLineChanged(AssDialogue *new_line);
|
void OnActiveLineChanged(AssDialogue *new_line);
|
||||||
void OnContextMenu(wxContextMenuEvent&);
|
void OnContextMenu(wxContextMenuEvent&);
|
||||||
void OnEnableButton(wxCommandEvent &evt);
|
void OnEnableButton(wxCommandEvent &evt);
|
||||||
void OnFileChanged(int type);
|
void OnFileChanged(int type, std::set<const AssEntry *> const& changed);
|
||||||
void OnMouse(wxMouseEvent &event);
|
void OnMouse(wxMouseEvent &event);
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void OnSize(wxSizeEvent &event);
|
void OnSize(wxSizeEvent &event);
|
||||||
|
|
Loading…
Reference in a new issue