Skip to content

Commit

Permalink
Improve repainting after a theme change.
Browse files Browse the repository at this point in the history
Now most things repaint properly after a theme change.  The sliders on the tracks don't yet.
  • Loading branch information
JamesCrook committed Apr 4, 2017
1 parent 017990f commit c17a7f5
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void Theme::ApplyUpdatedImages()
{
AColor::ReInit();
AudacityProject *p = GetActiveProject();
p->SetBackgroundColour( theTheme.Colour( clrMedium ) );
p->ResetColours();
for( int ii = 0; ii < ToolBarCount; ++ii )
{
Expand Down
1 change: 1 addition & 0 deletions src/TrackArtist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,7 @@ void TrackArtist::UpdatePrefs()
{
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
SetColours();
}

// Draws the sync-lock bitmap, tiled; always draws stationary relative to the DC
Expand Down
1 change: 1 addition & 0 deletions src/toolbars/ControlToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void ControlToolBar::MakeAlternateImages(AButton &button, int idx,

void ControlToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsLarge();

mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled,
Expand Down
20 changes: 6 additions & 14 deletions src/toolbars/DeviceToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ END_EVENT_TABLE()
DeviceToolBar::DeviceToolBar()
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
{
mPlayBitmap = NULL;
mRecordBitmap = NULL;
}

DeviceToolBar::~DeviceToolBar()
Expand All @@ -87,6 +85,7 @@ void DeviceToolBar::DeinitChildren()

void DeviceToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
DeinitChildren();
// Hosts
mHost = safenew wxChoice(this,
Expand All @@ -97,32 +96,25 @@ void DeviceToolBar::Populate()
Add(mHost, 0, wxALIGN_CENTER);

// Input device
if( mRecordBitmap == NULL )
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));

Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mRecordBitmap), 0, wxALIGN_CENTER);

theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
mInput = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
// Input channels
Add(mInput, 0, wxALIGN_CENTER);

mInputChannels = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
Add(mInputChannels, 0, wxALIGN_CENTER);

// Output device
if( mPlayBitmap == NULL )
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mPlayBitmap), 0, wxALIGN_CENTER);

theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
mOutput = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
Expand Down Expand Up @@ -473,8 +465,8 @@ void DeviceToolBar::RepositionCombos()
while (constrained && ratioUnused > 0.01f && i < 5) {
i++;
constrained = RepositionCombo(mHost, w, desiredHost, hostRatio, ratioUnused, 0, true);
constrained |= RepositionCombo(mInput, w, desiredInput, inputRatio, ratioUnused, mRecordBitmap->GetWidth(), true);
constrained |= RepositionCombo(mOutput, w, desiredOutput, outputRatio, ratioUnused, mPlayBitmap->GetWidth(), true);
constrained |= RepositionCombo(mInput, w, desiredInput, inputRatio, ratioUnused, theTheme.Bitmap(bmpMic).GetWidth(), true);
constrained |= RepositionCombo(mOutput, w, desiredOutput, outputRatio, ratioUnused, theTheme.Bitmap(bmpSpeaker).GetWidth(), true);
constrained |= RepositionCombo(mInputChannels, w, desiredChannels, channelsRatio, ratioUnused, 0, true);
}

Expand Down
3 changes: 0 additions & 3 deletions src/toolbars/DeviceToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ class DeviceToolBar final : public ToolBar {
void RepositionCombos();
void SetNames();
void RegenerateTooltips() override;

void ShowComboDialog(wxChoice *combo, const wxString &title);

std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;

wxChoice *mInput;
wxChoice *mOutput;
wxChoice *mInputChannels;
Expand Down
1 change: 1 addition & 0 deletions src/toolbars/EditToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ AButton *EditToolBar::AddButton(

void EditToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();

/* Buttons */
Expand Down
3 changes: 2 additions & 1 deletion src/toolbars/MeterToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <wx/gbsizer.h>

#include "MeterToolBar.h"

#include "../AllThemeResources.h"
#include "../AudioIO.h"
#include "../Project.h"
#include "../widgets/Meter.h"
Expand Down Expand Up @@ -105,6 +105,7 @@ void MeterToolBar::ReCreateButtons()

void MeterToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
wxASSERT(mProject); // to justify safenew
Add((mSizer = safenew wxGridBagSizer()), 1, wxEXPAND);

Expand Down
17 changes: 5 additions & 12 deletions src/toolbars/MixerToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ END_EVENT_TABLE()
MixerToolBar::MixerToolBar()
: ToolBar(MixerBarID, _("Mixer"), wxT("Mixer"))
{
mPlayBitmap = NULL;
mRecordBitmap = NULL;
mInputSliderVolume = 0.0;
mOutputSliderVolume = 0.0;
}
Expand All @@ -74,26 +72,21 @@ void MixerToolBar::Create(wxWindow *parent)

void MixerToolBar::Populate()
{
if( mRecordBitmap == NULL )
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));

SetBackgroundColour( theTheme.Colour( clrMedium ) );
// Recording icon and slider
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mRecordBitmap), 0, wxALIGN_CENTER);

theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
wxDefaultPosition, wxSize(130, 25));
mInputSlider->SetScroll(0.1f, 2.0f);
mInputSlider->SetName(_("Slider Recording"));
Add(mInputSlider, 0, wxALIGN_CENTER);

if( mPlayBitmap == NULL )
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));

// Playback icon and slider
Add(safenew wxStaticBitmap(this,
wxID_ANY,
*mPlayBitmap), 0, wxALIGN_CENTER);

theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
wxDefaultPosition, wxSize(130, 25));
mOutputSlider->SetScroll(0.1f, 2.0f);
Expand Down
2 changes: 0 additions & 2 deletions src/toolbars/MixerToolBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class MixerToolBar final : public ToolBar {
void InitializeMixerToolBar();
void SetToolTips();

std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;

ASlider *mInputSlider;
ASlider *mOutputSlider;

Expand Down
1 change: 1 addition & 0 deletions src/toolbars/ScrubbingToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ AButton *ScrubbingToolBar::AddButton

void ScrubbingToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();

/* Buttons */
Expand Down
1 change: 1 addition & 0 deletions src/toolbars/SelectionBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void SelectionBar::Create(wxWindow * parent)

void SelectionBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
mLeftTime = mRightTime = mAudioTime = nullptr;

// This will be inherited by all children:
Expand Down
2 changes: 2 additions & 0 deletions src/toolbars/SpectralSelectionBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ with changes in the SpectralSelectionBar.
#include "SpectralSelectionBar.h"

#include "../Prefs.h"
#include "../AllThemeResources.h"
#include "../SelectedRegion.h"
#include "../widgets/NumericTextCtrl.h"

Expand Down Expand Up @@ -106,6 +107,7 @@ void SpectralSelectionBar::Create(wxWindow * parent)

void SpectralSelectionBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
gPrefs->Read(preferencePath, &mbCenterAndWidth, true);

// This will be inherited by all children:
Expand Down
4 changes: 2 additions & 2 deletions src/toolbars/ToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ void ToolBarResizer::OnPaint( wxPaintEvent & event )
// Under GTK, we specifically set the toolbar background to the background
// colour in the system theme.
#if defined( __WXGTK__ )
dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
// dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
#endif

dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
dc.Clear();

wxSize sz = GetSize();
Expand Down
3 changes: 1 addition & 2 deletions src/toolbars/ToolDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,8 @@ void ToolDock::OnPaint( wxPaintEvent & WXUNUSED(event) )
//
// Under GTK, we don't set the toolbar background to the background
// colour in the system theme. Instead we use our own colour.
#if defined( __WXGTK__ )

dc.SetBackground( wxBrush( theTheme.Colour( clrMedium )));
#endif
dc.Clear();

// Set the gap color
Expand Down
1 change: 1 addition & 0 deletions src/toolbars/ToolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ void ToolManager::OnIndicatorPaint( wxPaintEvent & event )
// TODO: Better to use a bitmap than a triangular region.
wxWindow *w = (wxWindow *)event.GetEventObject();
wxPaintDC dc( w );
// TODO: Better (faster) to use the existing spare brush.
wxBrush brush( theTheme.Colour( clrTrackPanelText ) );
dc.SetBackground( brush );
dc.Clear();
Expand Down
1 change: 1 addition & 0 deletions src/toolbars/ToolsToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ AButton * ToolsToolBar::MakeTool( teBmps eTool,

void ToolsToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();
Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1));

Expand Down
1 change: 1 addition & 0 deletions src/toolbars/TranscriptionToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void TranscriptionToolBar::MakeAlternateImages(

void TranscriptionToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
// Very similar to code in ControlToolBar...
// Very similar to code in EditToolBar
MakeButtonBackgroundsSmall();
Expand Down

0 comments on commit c17a7f5

Please sign in to comment.