1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-25 08:58: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();
if (toolbar) {
toolbar->SetCurrentTool(tool, true);
toolbar->SetCurrentTool(tool);
mTrackPanel->Refresh(false);
}
}
@ -2300,7 +2300,7 @@ void AudacityProject::OnNextTool()
if (toolbar) {
// Use GetDownTool() here since GetCurrentTool() can return a value that
// 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);
}
}
@ -2311,7 +2311,7 @@ void AudacityProject::OnPrevTool()
if (toolbar) {
// Use GetDownTool() here since GetCurrentTool() can return a value that
// 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);
}
}

View File

@ -225,24 +225,21 @@ int ToolsToolBar::GetCurrentTool() const
/// Sets the currently active tool
/// @param tool - The index of the tool to be used.
/// @param show - should we update the button display?
void ToolsToolBar::SetCurrentTool(int tool, bool show)
void ToolsToolBar::SetCurrentTool(int tool)
{
//In multi-mode the current tool is shown by the
//cursor icon. The buttons are not updated.
bool leavingMulticlipMode =
IsDown(multiTool) && show && tool != multiTool;
IsDown(multiTool) && tool != multiTool;
if (leavingMulticlipMode)
mTool[multiTool]->PopUp();
if (tool != mCurrentTool || leavingMulticlipMode) {
if (show)
mTool[mCurrentTool]->PopUp();
mTool[mCurrentTool]->PopUp();
mCurrentTool=tool;
if (show)
mTool[mCurrentTool]->PushDown();
mTool[mCurrentTool]->PushDown();
}
//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
@ -250,14 +247,11 @@ void ToolsToolBar::SetCurrentTool(int tool, bool show)
// RedrawAllProjects();
//msmeyer: But we instruct the projects to handle the cursor shape again
if (show)
{
RefreshCursorForAllProjects();
RefreshCursorForAllProjects();
gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
IsDown(multiTool));
gPrefs->Flush();
}
gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
IsDown(multiTool));
gPrefs->Flush();
}
bool ToolsToolBar::IsDown(int tool) const

View File

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