Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget Class Referencefinal
Inheritance diagram for audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget:
[legend]
Collaboration diagram for audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget:
[legend]

Public Member Functions

 StatusWidget (CloudSyncStatusField &owner, wxWindow *parent)
 
 ~StatusWidget () override
 
void SetRect (const wxRect &rect)
 
int GetPreferredWidth (State state) const
 
const wxBitmap * GetBitmap () const
 
TranslatableString GetTranslatableText () const
 
wxString GetText () const
 
void OnPaint ()
 
void UpdatePrefs () override
 
void UpdateName ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Private Attributes

CloudSyncStatusFieldmOwner
 
const wxBitmap * mSyncedBitmap {}
 
const wxBitmap * mProgressBitmap {}
 
int mCloudSyncFailedMessageWidth {}
 
int mCloudSyncProgressMessageWidth {}
 

Additional Inherited Members

- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Definition at line 114 of file CloudSyncStatusField.cpp.

Constructor & Destructor Documentation

◆ StatusWidget()

audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::StatusWidget ( CloudSyncStatusField owner,
wxWindow *  parent 
)
inline

Definition at line 119 of file CloudSyncStatusField.cpp.

120 : wxPanelWrapper { parent }
121 , mOwner { owner }
122 {
123 SetBackgroundStyle(wxBG_STYLE_PAINT);
124 UpdatePrefs();
125
126 Bind(wxEVT_PAINT, [this](auto&) { OnPaint(); });
127
128#if wxUSE_ACCESSIBILITY
129 SetAccessible(safenew WindowAccessible(this));
130#endif
131 }
#define safenew
Definition: MemoryX.h:10
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References OnPaint(), safenew, and UpdatePrefs().

Here is the call graph for this function:

◆ ~StatusWidget()

audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::~StatusWidget ( )
inlineoverride

Definition at line 133 of file CloudSyncStatusField.cpp.

134 {
135 }

Member Function Documentation

◆ GetBitmap()

const wxBitmap * audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::GetBitmap ( ) const
inline

Definition at line 157 of file CloudSyncStatusField.cpp.

References mOwner, mProgressBitmap, mSyncedBitmap, and audacity::cloud::audiocom::sync::CloudSyncStatusField::Uploading.

Referenced by OnPaint().

Here is the caller graph for this function:

◆ GetPreferredWidth()

int audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::GetPreferredWidth ( State  state) const
inline

Definition at line 142 of file CloudSyncStatusField.cpp.

References audacity::cloud::audiocom::sync::CloudSyncStatusField::Failed, mCloudSyncFailedMessageWidth, mCloudSyncProgressMessageWidth, mProgressBitmap, mSyncedBitmap, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::Padding, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::ProgressBarWidth, and audacity::cloud::audiocom::sync::CloudSyncStatusField::Uploading.

◆ GetText()

wxString audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::GetText ( ) const
inline

Definition at line 174 of file CloudSyncStatusField.cpp.

References GetTranslatableText(), and TranslatableString::Translation().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTranslatableText()

TranslatableString audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::GetTranslatableText ( ) const
inline

Definition at line 163 of file CloudSyncStatusField.cpp.

References audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::CloudSyncFailedMessage, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::CloudSyncProgressMessage, audacity::cloud::audiocom::sync::CloudSyncStatusField::Failed, mOwner, audacity::cloud::audiocom::sync::CloudSyncStatusField::mProgress, and audacity::cloud::audiocom::sync::CloudSyncStatusField::Uploading.

Referenced by GetText(), and UpdateName().

Here is the caller graph for this function:

◆ OnPaint()

void audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::OnPaint ( )
inline

Definition at line 179 of file CloudSyncStatusField.cpp.

180 {
181 wxAutoBufferedPaintDC dc(this);
182 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
183
184 auto bitmap = GetBitmap();
185
186 const wxSize widgetSize = GetSize();
187 const wxSize bitmapSize = bitmap->GetSize();
188
189 gc->SetBrush(wxBrush(GetBackgroundColour()));
190 gc->DrawRectangle(0, 0, widgetSize.x, widgetSize.y);
191 gc->DrawBitmap(
192 *bitmap, Padding, (widgetSize.y - bitmapSize.y) / 2.0, bitmapSize.x,
193 bitmapSize.y);
194
195 const auto text = GetText();
196
197 if (text.empty())
198 return;
199
200 gc->SetFont(GetFont(), GetForegroundColour());
201 gc->DrawText(text, Padding + bitmapSize.x + 2 * Padding, 0);
202
203 if (mOwner.mState != State::Uploading)
204 return;
205
206 gc->SetAntialiasMode(wxANTIALIAS_NONE);
207
208 const auto progress = std::clamp(mOwner.mProgress, 0, 100);
209
210 const auto progressFilledPen =
211 gc->CreatePen(wxGraphicsPenInfo {}
212 .Colour(wxColour(0xc3c3c3))
213 .Width(ProgressBarBorderSize));
214
215 const auto progressEmptyPen =
216 gc->CreatePen(wxGraphicsPenInfo {}
217 .Colour(wxColour(0xc3c3c3))
218 .Width(ProgressBarBorderSize));
219 const auto zeroPen = gc->CreatePen(
220 wxGraphicsPenInfo {}.Width(0).Style(wxPENSTYLE_TRANSPARENT));
221
222 const auto progressFilledBrush = gc->CreateBrush(wxColour(0x3cf03c));
223 const auto progressEmptyBrush = gc->CreateBrush(wxColour(0xffffff));
224
225 const auto progressBarBorderLeft =
226 Padding + bitmapSize.x + 2 * Padding + mCloudSyncProgressMessageWidth;
227
228 const auto progressBarBorderRight =
229 progressBarBorderLeft + ProgressBarWidth;
230
231 const auto progressBarBorderTop =
232 (widgetSize.y - ProgressBarHeight) / 2.0;
233
234 const auto progressBarBorderBottom =
235 progressBarBorderTop + ProgressBarHeight;
236
237 const auto filledWidth =
238 (ProgressBarWidth - ProgressBarBorderSize * 2) * progress / 100;
239
240 const auto progressBarFillLeft =
241 progressBarBorderLeft + ProgressBarBorderSize;
242 const auto progressBarFillRight = progressBarFillLeft + filledWidth;
243
244 const auto progressBarEmptyLeft =
245 progressBarFillRight + (progress > 0 ? 1 : 0);
246 const auto progressBarEmptyRight =
247 progressBarBorderRight - ProgressBarBorderSize;
248
249 const auto filledHeight = ProgressBarHeight - ProgressBarBorderSize;
250
251 // Draw border
252 if (progress == 0)
253 gc->SetPen(progressEmptyPen);
254 else
255 gc->SetPen(progressFilledPen);
256
257 gc->StrokeLine(
258 progressBarBorderLeft, progressBarBorderTop, progressBarBorderLeft,
259 progressBarBorderBottom);
260
261 if (progress > 0)
262 {
263 gc->StrokeLine(
264 progressBarFillLeft, progressBarBorderTop, progressBarFillRight,
265 progressBarBorderTop);
266
267 gc->StrokeLine(
268 progressBarFillLeft, progressBarBorderBottom, progressBarFillRight,
269 progressBarBorderBottom);
270
271 gc->SetPen(zeroPen);
272 gc->SetBrush(progressFilledBrush);
273
274 gc->DrawRectangle(
275 progressBarFillLeft, progressBarBorderTop + ProgressBarBorderSize,
276 progressBarFillRight - progressBarFillLeft + 1, filledHeight);
277 }
278
279 if (progress < 100)
280 {
281 gc->SetPen(progressEmptyPen);
282
283 gc->StrokeLine(
284 progressBarEmptyLeft, progressBarBorderTop, progressBarEmptyRight,
285 progressBarBorderTop);
286
287 gc->StrokeLine(
288 progressBarEmptyLeft, progressBarBorderBottom,
289 progressBarEmptyRight, progressBarBorderBottom);
290
291 gc->SetPen(zeroPen);
292 gc->SetBrush(progressEmptyBrush);
293
294 gc->DrawRectangle(
295 progressBarEmptyLeft, progressBarBorderTop + ProgressBarBorderSize,
296 progressBarEmptyRight - progressBarEmptyLeft + 1, filledHeight);
297 }
298
299 if (progress == 100)
300 gc->SetPen(progressFilledPen);
301 else
302 gc->SetPen(progressEmptyPen);
303
304 gc->StrokeLine(
305 progressBarBorderRight, progressBarBorderTop, progressBarBorderRight,
306 progressBarBorderBottom);
307 }

References GetBitmap(), GetText(), mCloudSyncProgressMessageWidth, mOwner, audacity::cloud::audiocom::sync::CloudSyncStatusField::mProgress, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::Padding, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::ProgressBarBorderSize, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::ProgressBarHeight, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::ProgressBarWidth, and audacity::cloud::audiocom::sync::CloudSyncStatusField::Uploading.

Referenced by StatusWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRect()

void audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::SetRect ( const wxRect &  rect)
inline

Definition at line 137 of file CloudSyncStatusField.cpp.

138 {
139 SetSize(rect);
140 }

◆ UpdateName()

void audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::UpdateName ( )
inline

Definition at line 324 of file CloudSyncStatusField.cpp.

325 {
327 }

References GetTranslatableText(), and wxPanelWrapper::SetName().

Here is the call graph for this function:

◆ UpdatePrefs()

void audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::UpdatePrefs ( )
inlineoverridevirtual

Implements PrefsListener.

Definition at line 309 of file CloudSyncStatusField.cpp.

310 {
311 mSyncedBitmap = &theTheme.Bitmap(bmpCloud);
312 mProgressBitmap = &theTheme.Bitmap(bmpCloudProgress);
313
315 GetTextExtent(CloudSyncFailedMessage.Translation()).x;
316
319 .Format(100)
320 .Translation())
321 .x;
322 }
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxBitmap & Bitmap(int iIndex)

References ThemeBase::Bitmap(), audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::CloudSyncFailedMessage, audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::CloudSyncProgressMessage, mCloudSyncFailedMessageWidth, mCloudSyncProgressMessageWidth, mProgressBitmap, mSyncedBitmap, and theTheme.

Referenced by StatusWidget().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mCloudSyncFailedMessageWidth

int audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::mCloudSyncFailedMessageWidth {}
private

Definition at line 335 of file CloudSyncStatusField.cpp.

Referenced by GetPreferredWidth(), and UpdatePrefs().

◆ mCloudSyncProgressMessageWidth

int audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::mCloudSyncProgressMessageWidth {}
private

Definition at line 336 of file CloudSyncStatusField.cpp.

Referenced by GetPreferredWidth(), OnPaint(), and UpdatePrefs().

◆ mOwner

CloudSyncStatusField& audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::mOwner
private

Definition at line 330 of file CloudSyncStatusField.cpp.

Referenced by GetBitmap(), GetTranslatableText(), and OnPaint().

◆ mProgressBitmap

const wxBitmap* audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::mProgressBitmap {}
private

Definition at line 333 of file CloudSyncStatusField.cpp.

Referenced by GetBitmap(), GetPreferredWidth(), and UpdatePrefs().

◆ mSyncedBitmap

const wxBitmap* audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::mSyncedBitmap {}
private

Definition at line 332 of file CloudSyncStatusField.cpp.

Referenced by GetBitmap(), GetPreferredWidth(), and UpdatePrefs().


The documentation for this class was generated from the following file: