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);
|
||||
ShowCursor(activeMode != Video_Mode_Standard);
|
||||
Render();
|
||||
}
|
||||
void VideoDisplay::OnKey(wxKeyEvent &event) {
|
||||
int key = event.GetKeyCode();
|
||||
|
|
|
@ -105,9 +105,11 @@ VisualTool<FeatureType>::~VisualTool() {
|
|||
template<class FeatureType>
|
||||
void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
||||
bool realTime = realtime->GetBool();
|
||||
bool needRender = false;
|
||||
|
||||
if (event.Leaving()) {
|
||||
Update();
|
||||
parent->Render();
|
||||
return;
|
||||
}
|
||||
externalChange = false;
|
||||
|
@ -127,7 +129,9 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
|||
dragListOK = true;
|
||||
}
|
||||
if (!dragging) {
|
||||
int oldHigh = curFeatureI;
|
||||
GetHighlightedFeature();
|
||||
if (curFeatureI != oldHigh) needRender = true;
|
||||
}
|
||||
|
||||
if (dragging) {
|
||||
|
@ -150,7 +154,12 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
|||
CommitDrag(&features[*cur]);
|
||||
}
|
||||
}
|
||||
if (realTime) Commit();
|
||||
if (realTime) {
|
||||
Commit();
|
||||
}
|
||||
else {
|
||||
needRender = true;
|
||||
}
|
||||
}
|
||||
// end drag
|
||||
else {
|
||||
|
@ -195,6 +204,9 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
|||
CommitHold();
|
||||
Commit();
|
||||
}
|
||||
else {
|
||||
needRender = true;
|
||||
}
|
||||
}
|
||||
// end hold
|
||||
else {
|
||||
|
@ -242,6 +254,7 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
|||
if (!altDown) {
|
||||
ClearSelection();
|
||||
SetEditbox();
|
||||
needRender = true;
|
||||
}
|
||||
curDiag = GetActiveDialogueLine();
|
||||
if (curDiag && InitializeHold()) {
|
||||
|
@ -252,7 +265,7 @@ void VisualTool<FeatureType>::OnMouseEvent (wxMouseEvent &event) {
|
|||
}
|
||||
}
|
||||
|
||||
Update();
|
||||
if (Update() || needRender) parent->Render();
|
||||
externalChange = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ protected:
|
|||
public:
|
||||
virtual void OnMouseEvent(wxMouseEvent &event)=0;
|
||||
virtual void OnSubTool(wxCommandEvent &)=0;
|
||||
virtual void Update()=0;
|
||||
virtual bool Update()=0;
|
||||
virtual void Draw()=0;
|
||||
virtual void Refresh()=0;
|
||||
virtual ~IVisualTool() { };
|
||||
|
@ -194,7 +194,8 @@ public:
|
|||
/// @brief Event handler for the subtoolbar
|
||||
virtual void OnSubTool(wxCommandEvent &) { }
|
||||
/// @brief Called when there's stuff
|
||||
virtual void Update() { };
|
||||
/// @return Should the display rerender?
|
||||
virtual bool Update() { return false; };
|
||||
/// @brief Draw stuff
|
||||
virtual void Draw()=0;
|
||||
/// @brief Called by stuff when there's stuff
|
||||
|
|
|
@ -52,11 +52,11 @@ VisualToolCross::VisualToolCross(VideoDisplay *parent, VideoState const& video,
|
|||
VisualToolCross::~VisualToolCross() { }
|
||||
|
||||
/// @brief Update
|
||||
void VisualToolCross::Update() {
|
||||
if (!leftDClick) return;
|
||||
bool VisualToolCross::Update() {
|
||||
if (!leftDClick) return true;
|
||||
|
||||
AssDialogue* line = GetActiveDialogueLine();
|
||||
if (!line) return;
|
||||
if (!line) return true;
|
||||
|
||||
|
||||
int dx, dy;
|
||||
|
@ -80,6 +80,7 @@ void VisualToolCross::Update() {
|
|||
}
|
||||
|
||||
Commit(true, _("positioning"));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Draw
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
||||
~VisualToolCross();
|
||||
|
||||
void Update();
|
||||
bool Update();
|
||||
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));
|
||||
}
|
||||
}
|
||||
void VisualToolDrag::Update() {
|
||||
if (!leftDClick) return;
|
||||
bool VisualToolDrag::Update() {
|
||||
if (!leftDClick) return false;
|
||||
|
||||
int dx, dy;
|
||||
int vx = video.x;
|
||||
|
@ -321,7 +321,7 @@ void VisualToolDrag::Update() {
|
|||
}
|
||||
else {
|
||||
AssDialogue* line = GetActiveDialogueLine();
|
||||
if (!line) return;
|
||||
if (!line) return false;
|
||||
GetLinePosition(line, dx, dy);
|
||||
}
|
||||
parent->ToScriptCoords(&dx, &dy);
|
||||
|
@ -359,4 +359,5 @@ void VisualToolDrag::Update() {
|
|||
Commit(true, _("positioning"));
|
||||
|
||||
GenerateFeatures();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,6 @@ public:
|
|||
void OnSelectionChange(bool clear, int row, bool selected);
|
||||
|
||||
void Draw();
|
||||
void Update();
|
||||
bool Update();
|
||||
void OnSubTool(wxCommandEvent &event);
|
||||
};
|
||||
|
|
|
@ -88,4 +88,5 @@ public:
|
|||
VisualToolRotateZ(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
||||
|
||||
void Draw();
|
||||
bool Update() { return true; }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue