@@ -53,7 +53,7 @@ static const ImGuiWindowFlags NOTIFY_DEFAULT_TOAST_FLAGS =
53
53
va_end (args); \
54
54
}
55
55
56
- enum class ToastNotificationType : uint8_t
56
+ enum class ToastType : uint8_t
57
57
{
58
58
None,
59
59
Success,
@@ -87,12 +87,12 @@ enum class ImNotifyToastPos : uint8_t
87
87
/* *
88
88
* @brief A class for creating toast notifications with ImGui.
89
89
*/
90
- class ToastNotification
90
+ class Toast
91
91
{
92
92
private:
93
93
ImGuiWindowFlags flags = NOTIFY_DEFAULT_TOAST_FLAGS;
94
94
95
- ToastNotificationType type = ToastNotificationType ::None;
95
+ ToastType type = ToastType ::None;
96
96
char title[NOTIFY_MAX_MSG_LENGTH];
97
97
char content[NOTIFY_MAX_MSG_LENGTH];
98
98
@@ -137,9 +137,9 @@ class ToastNotification
137
137
*
138
138
* @param type The type of the toast notification.
139
139
*/
140
- inline void setType (const ToastNotificationType & type)
140
+ inline void setType (const ToastType & type)
141
141
{
142
- IM_ASSERT (type < ToastNotificationType ::COUNT);
142
+ IM_ASSERT (type < ToastType ::COUNT);
143
143
this ->type = type;
144
144
};
145
145
@@ -186,11 +186,11 @@ class ToastNotification
186
186
{
187
187
switch (this ->type )
188
188
{
189
- case ToastNotificationType ::None: return nullptr ;
190
- case ToastNotificationType ::Success: return " Success" ;
191
- case ToastNotificationType ::Warning: return " Warning" ;
192
- case ToastNotificationType ::Error: return " Error" ;
193
- case ToastNotificationType ::Info: return " Info" ;
189
+ case ToastType ::None: return nullptr ;
190
+ case ToastType ::Success: return " Success" ;
191
+ case ToastType ::Warning: return " Warning" ;
192
+ case ToastType ::Error: return " Error" ;
193
+ case ToastType ::Info: return " Info" ;
194
194
default : return nullptr ;
195
195
}
196
196
}
@@ -203,7 +203,7 @@ class ToastNotification
203
203
*
204
204
* @return ImGuiToastType The type of the toast notification.
205
205
*/
206
- inline ToastNotificationType getType () { return this ->type ; };
206
+ inline ToastType getType () { return this ->type ; };
207
207
208
208
/* *
209
209
* @brief Get the color of the toast notification based on its type.
@@ -214,11 +214,11 @@ class ToastNotification
214
214
{
215
215
switch (this ->type )
216
216
{
217
- case ToastNotificationType ::None: return {255 , 255 , 255 , 255 }; // White
218
- case ToastNotificationType ::Success: return {0 , 255 , 0 , 255 }; // Green
219
- case ToastNotificationType ::Warning: return {255 , 255 , 0 , 255 }; // Yellow
220
- case ToastNotificationType ::Error: return {255 , 0 , 0 , 255 }; // Error
221
- case ToastNotificationType ::Info: return {0 , 157 , 255 , 255 }; // Blue
217
+ case ToastType ::None: return {255 , 255 , 255 , 255 }; // White
218
+ case ToastType ::Success: return {0 , 255 , 0 , 255 }; // Green
219
+ case ToastType ::Warning: return {255 , 255 , 0 , 255 }; // Yellow
220
+ case ToastType ::Error: return {255 , 0 , 0 , 255 }; // Error
221
+ case ToastType ::Info: return {0 , 157 , 255 , 255 }; // Blue
222
222
default : return {255 , 255 , 255 , 255 }; // White
223
223
}
224
224
}
@@ -232,11 +232,11 @@ class ToastNotification
232
232
{
233
233
switch (this ->type )
234
234
{
235
- case ToastNotificationType ::None: return nullptr ;
236
- case ToastNotificationType ::Success: return ICON_MD_CHECK_CIRCLE; // Font Awesome 6
237
- case ToastNotificationType ::Warning: return ICON_MD_ALERT; // Font Awesome 6
238
- case ToastNotificationType ::Error: return ICON_MD_ALERT_DECAGRAM; // Font Awesome 6
239
- case ToastNotificationType ::Info: return ICON_MD_INFORMATION; // Font Awesome 6
235
+ case ToastType ::None: return nullptr ;
236
+ case ToastType ::Success: return ICON_MD_CHECK_CIRCLE; // Font Awesome 6
237
+ case ToastType ::Warning: return ICON_MD_ALERT; // Font Awesome 6
238
+ case ToastType ::Error: return ICON_MD_ALERT_DECAGRAM; // Font Awesome 6
239
+ case ToastType ::Info: return ICON_MD_INFORMATION; // Font Awesome 6
240
240
default : return nullptr ;
241
241
}
242
242
}
@@ -327,14 +327,14 @@ class ToastNotification
327
327
// Constructors
328
328
329
329
/* *
330
- * @brief Creates a new ToastNotification object with the specified type and dismiss time.
330
+ * @brief Creates a new Toast object with the specified type and dismiss time.
331
331
*
332
332
* @param type The type of the toast.
333
333
* @param dismissTime The time in milliseconds after which the toast should be dismissed. Default is NOTIFY_DEFAULT_DISMISS.
334
334
*/
335
- ToastNotification (ToastNotificationType type, int dismissTime = NOTIFY_DEFAULT_DISMISS)
335
+ Toast (ToastType type, int dismissTime = NOTIFY_DEFAULT_DISMISS)
336
336
{
337
- IM_ASSERT (type < ToastNotificationType ::COUNT);
337
+ IM_ASSERT (type < ToastType ::COUNT);
338
338
339
339
this ->type = type;
340
340
this ->dismissTime = dismissTime;
@@ -346,55 +346,55 @@ class ToastNotification
346
346
}
347
347
348
348
/* *
349
- * @brief Constructor for creating an ToastNotification object with a specified type and message format.
349
+ * @brief Constructor for creating an Toast object with a specified type and message format.
350
350
*
351
351
* @param type The type of the toast message.
352
352
* @param format The format string for the message.
353
353
* @param ... The variable arguments to be formatted according to the format string.
354
354
*/
355
- ToastNotification (ToastNotificationType type, const char * format, ...)
356
- : ToastNotification (type)
355
+ Toast (ToastType type, const char * format, ...)
356
+ : Toast (type)
357
357
{
358
358
NOTIFY_FORMAT (this ->setContent , format);
359
359
}
360
360
361
- /* @brief Constructor for creating an ToastNotification object with a specified type and std::string message.
361
+ /* @brief Constructor for creating an Toast object with a specified type and std::string message.
362
362
* @param dismissTime The time in milliseconds before the toast message is dismissed.
363
363
* @param message The message to be displayed in the toast.
364
364
*/
365
- ToastNotification (ToastNotificationType type, const std::string& message)
366
- : ToastNotification (type)
365
+ Toast (ToastType type, const std::string& message)
366
+ : Toast (type)
367
367
{
368
368
this ->setContent (message);
369
369
}
370
370
371
371
/* *
372
- * @brief Constructor for creating a new ToastNotification object with a specified type, dismiss time, and content format.
372
+ * @brief Constructor for creating a new Toast object with a specified type, dismiss time, and content format.
373
373
*
374
374
* @param type The type of the toast message.
375
375
* @param dismissTime The time in milliseconds before the toast message is dismissed.
376
376
* @param format The format string for the content of the toast message.
377
377
* @param ... The variable arguments to be formatted according to the format string.
378
378
*/
379
- ToastNotification (ToastNotificationType type, int dismissTime, const char * format, ...)
380
- : ToastNotification (type, dismissTime)
379
+ Toast (ToastType type, int dismissTime, const char * format, ...)
380
+ : Toast (type, dismissTime)
381
381
{
382
382
NOTIFY_FORMAT (this ->setContent , format);
383
383
}
384
384
385
- /* @brief Constructor for creating an ToastNotification object with a specified type, dismiss time, and std::string message.
385
+ /* @brief Constructor for creating an Toast object with a specified type, dismiss time, and std::string message.
386
386
* @param type The type of the toast message.
387
387
* @param dismissTime The time in milliseconds before the toast message is dismissed.
388
388
* @param message The message to be displayed in the toast.
389
389
*/
390
- ToastNotification (ToastNotificationType type, int dismissTime, const std::string& message)
391
- : ToastNotification (type, dismissTime)
390
+ Toast (ToastType type, int dismissTime, const std::string& message)
391
+ : Toast (type, dismissTime)
392
392
{
393
393
this ->setContent (message);
394
394
}
395
395
396
396
/* *
397
- * @brief Constructor for creating a new ToastNotification object with a specified type, dismiss time, title format, content format and a button.
397
+ * @brief Constructor for creating a new Toast object with a specified type, dismiss time, title format, content format and a button.
398
398
*
399
399
* @param type The type of the toast message.
400
400
* @param dismissTime The time in milliseconds before the toast message is dismissed.
@@ -403,8 +403,8 @@ class ToastNotification
403
403
* @param format The format string for the content of the toast message.
404
404
* @param ... The variable arguments to be formatted according to the format string.
405
405
*/
406
- ToastNotification (ToastNotificationType type, int dismissTime, const char * buttonLabel, const std::function<void ()>& onButtonPress, const char* format, ...)
407
- : ToastNotification (type, dismissTime)
406
+ Toast (ToastType type, int dismissTime, const char * buttonLabel, const std::function<void ()>& onButtonPress, const char* format, ...)
407
+ : Toast (type, dismissTime)
408
408
{
409
409
NOTIFY_FORMAT (this ->setContent , format);
410
410
@@ -415,13 +415,13 @@ class ToastNotification
415
415
416
416
namespace ImGui
417
417
{
418
- inline std::vector<ToastNotification > notifications;
418
+ inline std::vector<Toast > notifications;
419
419
420
420
/* *
421
421
* Inserts a new notification into the notification queue.
422
422
* @param toast The notification to be inserted.
423
423
*/
424
- inline void InsertNotification (const ToastNotification & toast)
424
+ inline void InsertNotification (const Toast & toast)
425
425
{
426
426
notifications.push_back (toast);
427
427
}
@@ -449,7 +449,7 @@ inline void RenderNotifications()
449
449
450
450
for (size_t i = 0 ; i < notifications.size (); ++i)
451
451
{
452
- ToastNotification * currentToast = ¬ifications[i];
452
+ Toast * currentToast = ¬ifications[i];
453
453
454
454
// Remove toast if expired
455
455
if (currentToast->getPhase () == ImNotifyToastPhase::Expired)
@@ -623,24 +623,24 @@ inline void RenderNotifications()
623
623
namespace sol_ToastNotification
624
624
{
625
625
// rename this to be more user friendly
626
- inline void ShowToast (const ToastNotification & toast)
626
+ inline void ShowToast (const Toast & toast)
627
627
{
628
628
ImGui::InsertNotification (toast);
629
629
}
630
630
631
631
inline void BindImNotifyToast (sol::table aTable)
632
632
{
633
- aTable.new_usertype <ToastNotification >(
634
- " ToastNotification " ,
635
- sol::constructors<ToastNotification (ToastNotificationType), ToastNotification (ToastNotificationType , int ),ToastNotification (ToastNotificationType ,const std::string&),ToastNotification (ToastNotificationType ,int ,const std::string&)>(),
636
- " SetTitle" , sol::resolve<void (const std::string&)>(&ToastNotification ::setTitle),
637
- " SetContent" , sol::resolve<void (const std::string&)>(&ToastNotification ::setContent),
638
- " SetType" , &ToastNotification ::setType,
639
- " SetWindowFlags" , &ToastNotification ::setWindowFlags);
633
+ aTable.new_usertype <Toast >(
634
+ " Toast " ,
635
+ sol::constructors<Toast (ToastType), Toast (ToastType , int ),Toast (ToastType ,const std::string&),Toast (ToastType ,int ,const std::string&)>(),
636
+ " SetTitle" , sol::resolve<void (const std::string&)>(&Toast ::setTitle),
637
+ " SetContent" , sol::resolve<void (const std::string&)>(&Toast ::setContent),
638
+ " SetType" , &Toast ::setType,
639
+ " SetWindowFlags" , &Toast ::setWindowFlags);
640
640
641
641
aTable.new_enum (
642
- " ToastNotificationType " , " None" , ToastNotificationType ::None, " Success" , ToastNotificationType ::Success, " Warning" , ToastNotificationType ::Warning, " Error" , ToastNotificationType ::Error, " Info" , ToastNotificationType ::Info);
642
+ " ToastType " , " None" , ToastType ::None, " Success" , ToastType ::Success, " Warning" , ToastType ::Warning, " Error" , ToastType ::Error, " Info" , ToastType ::Info);
643
643
644
644
aTable.set_function (" ShowToast" , ShowToast);
645
645
}
646
- } // namespace sol_ToastNotification
646
+ } // namespace sol_Toast
0 commit comments