1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-26 01:18:06 +02:00

Simplify ToolsToolBar::SetCurrentTool

This commit is contained in:
Paul Licameli 2017-06-07 21:02:57 -04:00
parent 41a56441dc
commit 114f5a4a63
3 changed files with 12 additions and 18 deletions

View File

@ -2258,7 +2258,7 @@ void AudacityProject::SetTool(int tool)
{ {
ToolsToolBar *toolbar = GetToolsToolBar(); ToolsToolBar *toolbar = GetToolsToolBar();
if (toolbar) { if (toolbar) {
toolbar->SetCurrentTool(tool, true); toolbar->SetCurrentTool(tool);
mTrackPanel->Refresh(false); mTrackPanel->Refresh(false);
} }
} }
@ -2300,7 +2300,7 @@ void AudacityProject::OnNextTool()
if (toolbar) { if (toolbar) {
// Use GetDownTool() here since GetCurrentTool() can return a value that // Use GetDownTool() here since GetCurrentTool() can return a value that
// doesn't represent the real tool if the Multi-tool is being used. // doesn't represent the real tool if the Multi-tool is being used.
toolbar->SetCurrentTool((toolbar->GetDownTool()+1)%numTools, true); toolbar->SetCurrentTool((toolbar->GetDownTool()+1)%numTools);
mTrackPanel->Refresh(false); mTrackPanel->Refresh(false);
} }
} }
@ -2311,7 +2311,7 @@ void AudacityProject::OnPrevTool()
if (toolbar) { if (toolbar) {
// Use GetDownTool() here since GetCurrentTool() can return a value that // Use GetDownTool() here since GetCurrentTool() can return a value that
// doesn't represent the real tool if the Multi-tool is being used. // doesn't represent the real tool if the Multi-tool is being used.
toolbar->SetCurrentTool((toolbar->GetDownTool()+(numTools-1))%numTools, true); toolbar->SetCurrentTool((toolbar->GetDownTool()+(numTools-1))%numTools);
mTrackPanel->Refresh(false); mTrackPanel->Refresh(false);
} }
} }

View File

@ -225,24 +225,21 @@ int ToolsToolBar::GetCurrentTool() const
/// Sets the currently active tool /// Sets the currently active tool
/// @param tool - The index of the tool to be used. /// @param tool - The index of the tool to be used.
/// @param show - should we update the button display? void ToolsToolBar::SetCurrentTool(int tool)
void ToolsToolBar::SetCurrentTool(int tool, bool show)
{ {
//In multi-mode the current tool is shown by the //In multi-mode the current tool is shown by the
//cursor icon. The buttons are not updated. //cursor icon. The buttons are not updated.
bool leavingMulticlipMode = bool leavingMulticlipMode =
IsDown(multiTool) && show && tool != multiTool; IsDown(multiTool) && tool != multiTool;
if (leavingMulticlipMode) if (leavingMulticlipMode)
mTool[multiTool]->PopUp(); mTool[multiTool]->PopUp();
if (tool != mCurrentTool || leavingMulticlipMode) { if (tool != mCurrentTool || leavingMulticlipMode) {
if (show) mTool[mCurrentTool]->PopUp();
mTool[mCurrentTool]->PopUp();
mCurrentTool=tool; mCurrentTool=tool;
if (show) mTool[mCurrentTool]->PushDown();
mTool[mCurrentTool]->PushDown();
} }
//JKC: ANSWER-ME: Why is this RedrawAllProjects() line required? //JKC: ANSWER-ME: Why is this RedrawAllProjects() line required?
//msmeyer: I think it isn't, we leave it out for 1.3.1 (beta), and //msmeyer: I think it isn't, we leave it out for 1.3.1 (beta), and
@ -250,14 +247,11 @@ void ToolsToolBar::SetCurrentTool(int tool, bool show)
// RedrawAllProjects(); // RedrawAllProjects();
//msmeyer: But we instruct the projects to handle the cursor shape again //msmeyer: But we instruct the projects to handle the cursor shape again
if (show) RefreshCursorForAllProjects();
{
RefreshCursorForAllProjects();
gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"), gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
IsDown(multiTool)); IsDown(multiTool));
gPrefs->Flush(); gPrefs->Flush();
}
} }
bool ToolsToolBar::IsDown(int tool) const bool ToolsToolBar::IsDown(int tool) const

View File

@ -55,7 +55,7 @@ class ToolsToolBar final : public ToolBar {
void OnTool(wxCommandEvent & evt); void OnTool(wxCommandEvent & evt);
void SetCurrentTool(int tool, bool show); void SetCurrentTool(int tool);
//These interrogate the state of the buttons or controls. //These interrogate the state of the buttons or controls.
int GetCurrentTool() const; int GetCurrentTool() const;