Only rerender the video display on mouse events if display will actually change
Originally committed to SVN as r4456.
This commit is contained in:
parent
1b27b77ac3
commit
83e35ac63d
8 changed files with 29 additions and 13 deletions
|
@ -488,7 +488,6 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
|
|
||||||
tool->OnMouseEvent(event);
|
tool->OnMouseEvent(event);
|
||||||
ShowCursor(activeMode != Video_Mode_Standard);
|
ShowCursor(activeMode != Video_Mode_Standard);
|
||||||
Render();
|
|
||||||
}
|
}
|
||||||
void VideoDisplay::OnKey(wxKeyEvent &event) {
|
void VideoDisplay::OnKey(wxKeyEvent &event) {
|
||||||
int key = event.GetKeyCode();
|
int key = event.GetKeyCode();
|
||||||
|
|
|
@ -105,9 +105,11 @@ VisualTool<FeatureType>::~VisualTool() {
|
||||||
template<class FeatureType>
|
template<class FeatureType>
|
||||||
void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
bool realTime = realtime->GetBool();
|
bool realTime = realtime->GetBool();
|
||||||
|
bool needRender = false;
|
||||||
|
|
||||||
if (event.Leaving()) {
|
if (event.Leaving()) {
|
||||||
Update();
|
Update();
|
||||||
|
parent->Render();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
externalChange = false;
|
externalChange = false;
|
||||||
|
@ -127,7 +129,9 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
dragListOK = true;
|
dragListOK = true;
|
||||||
}
|
}
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
|
int oldHigh = curFeatureI;
|
||||||
GetHighlightedFeature();
|
GetHighlightedFeature();
|
||||||
|
if (curFeatureI != oldHigh) needRender = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
|
@ -150,7 +154,12 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
CommitDrag(&features[*cur]);
|
CommitDrag(&features[*cur]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (realTime) Commit();
|
if (realTime) {
|
||||||
|
Commit();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
needRender = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// end drag
|
// end drag
|
||||||
else {
|
else {
|
||||||
|
@ -195,6 +204,9 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
CommitHold();
|
CommitHold();
|
||||||
Commit();
|
Commit();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
needRender = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// end hold
|
// end hold
|
||||||
else {
|
else {
|
||||||
|
@ -242,6 +254,7 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
if (!altDown) {
|
if (!altDown) {
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
SetEditbox();
|
SetEditbox();
|
||||||
|
needRender = true;
|
||||||
}
|
}
|
||||||
curDiag = GetActiveDialogueLine();
|
curDiag = GetActiveDialogueLine();
|
||||||
if (curDiag && InitializeHold()) {
|
if (curDiag && InitializeHold()) {
|
||||||
|
@ -252,7 +265,7 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Update();
|
if (Update() || needRender) parent->Render();
|
||||||
externalChange = true;
|
externalChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
virtual void OnMouseEvent(wxMouseEvent &event)=0;
|
virtual void OnMouseEvent(wxMouseEvent &event)=0;
|
||||||
virtual void OnSubTool(wxCommandEvent &)=0;
|
virtual void OnSubTool(wxCommandEvent &)=0;
|
||||||
virtual void Update()=0;
|
virtual bool Update()=0;
|
||||||
virtual void Draw()=0;
|
virtual void Draw()=0;
|
||||||
virtual void Refresh()=0;
|
virtual void Refresh()=0;
|
||||||
virtual ~IVisualTool() { };
|
virtual ~IVisualTool() { };
|
||||||
|
@ -194,7 +194,8 @@ public:
|
||||||
/// @brief Event handler for the subtoolbar
|
/// @brief Event handler for the subtoolbar
|
||||||
virtual void OnSubTool(wxCommandEvent &) { }
|
virtual void OnSubTool(wxCommandEvent &) { }
|
||||||
/// @brief Called when there's stuff
|
/// @brief Called when there's stuff
|
||||||
virtual void Update() { };
|
/// @return Should the display rerender?
|
||||||
|
virtual bool Update() { return false; };
|
||||||
/// @brief Draw stuff
|
/// @brief Draw stuff
|
||||||
virtual void Draw()=0;
|
virtual void Draw()=0;
|
||||||
/// @brief Called by stuff when there's stuff
|
/// @brief Called by stuff when there's stuff
|
||||||
|
|
|
@ -52,11 +52,11 @@ VisualToolCross::VisualToolCross(VideoDisplay *parent, VideoState const& video,
|
||||||
VisualToolCross::~VisualToolCross() { }
|
VisualToolCross::~VisualToolCross() { }
|
||||||
|
|
||||||
/// @brief Update
|
/// @brief Update
|
||||||
void VisualToolCross::Update() {
|
bool VisualToolCross::Update() {
|
||||||
if (!leftDClick) return;
|
if (!leftDClick) return true;
|
||||||
|
|
||||||
AssDialogue* line = GetActiveDialogueLine();
|
AssDialogue* line = GetActiveDialogueLine();
|
||||||
if (!line) return;
|
if (!line) return true;
|
||||||
|
|
||||||
|
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
@ -80,6 +80,7 @@ void VisualToolCross::Update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Commit(true, _("positioning"));
|
Commit(true, _("positioning"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw
|
/// @brief Draw
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
||||||
~VisualToolCross();
|
~VisualToolCross();
|
||||||
|
|
||||||
void Update();
|
bool Update();
|
||||||
void Draw();
|
void Draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,8 @@ void VisualToolDrag::CommitDrag(VisualToolDragDraggableFeature* feature) {
|
||||||
SetOverride(feature->line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1, y1, x2, y2, feature->time, p->time));
|
SetOverride(feature->line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1, y1, x2, y2, feature->time, p->time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void VisualToolDrag::Update() {
|
bool VisualToolDrag::Update() {
|
||||||
if (!leftDClick) return;
|
if (!leftDClick) return false;
|
||||||
|
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
int vx = video.x;
|
int vx = video.x;
|
||||||
|
@ -321,7 +321,7 @@ void VisualToolDrag::Update() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AssDialogue* line = GetActiveDialogueLine();
|
AssDialogue* line = GetActiveDialogueLine();
|
||||||
if (!line) return;
|
if (!line) return false;
|
||||||
GetLinePosition(line, dx, dy);
|
GetLinePosition(line, dx, dy);
|
||||||
}
|
}
|
||||||
parent->ToScriptCoords(&dx, &dy);
|
parent->ToScriptCoords(&dx, &dy);
|
||||||
|
@ -359,4 +359,5 @@ void VisualToolDrag::Update() {
|
||||||
Commit(true, _("positioning"));
|
Commit(true, _("positioning"));
|
||||||
|
|
||||||
GenerateFeatures();
|
GenerateFeatures();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,6 @@ public:
|
||||||
void OnSelectionChange(bool clear, int row, bool selected);
|
void OnSelectionChange(bool clear, int row, bool selected);
|
||||||
|
|
||||||
void Draw();
|
void Draw();
|
||||||
void Update();
|
bool Update();
|
||||||
void OnSubTool(wxCommandEvent &event);
|
void OnSubTool(wxCommandEvent &event);
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,4 +88,5 @@ public:
|
||||||
VisualToolRotateZ(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
VisualToolRotateZ(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
||||||
|
|
||||||
void Draw();
|
void Draw();
|
||||||
|
bool Update() { return true; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue