This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
498 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <LCUI.h> | ||
#include <LCUI/gui/widget.h> | ||
#include <LCDesign/ui/components/message.h> | ||
|
||
static LCUI_WidgetPrototype message_view_proto; | ||
|
||
static void OpenNormalMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenInfoMessage(L"This is a normal message", 3000); | ||
} | ||
|
||
static void OpenSuccessMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenSuccessMessage(L"This is a success message", 3000); | ||
} | ||
|
||
static void OpenWarningMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenWarningMessage(L"This is a warning message", 3000); | ||
} | ||
|
||
static void OpenErrorMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenErrorMessage(L"This is a error message", 3000); | ||
} | ||
|
||
static void OpenCustomDurationMessage(LCUI_Widget w, LCUI_WidgetEvent e, | ||
void *arg) | ||
{ | ||
LCDesign_OpenSuccessMessage(L"This is a prompt message for success, " | ||
L"and it will disappear in 10 seconds", | ||
10000); | ||
} | ||
|
||
static void OpenLoadingMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenLoadingMessage(L"Action in progress..", 3000); | ||
} | ||
|
||
static void MessageView_OnReady(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
Dict *dict; | ||
LCUI_Widget btn; | ||
|
||
dict = Widget_CollectReferences(w); | ||
btn = Dict_FetchValue(dict, "open-normal-message"); | ||
Widget_BindEvent(btn, "click", OpenNormalMessage, NULL, NULL); | ||
|
||
btn = Dict_FetchValue(dict, "open-success-message"); | ||
Widget_BindEvent(btn, "click", OpenSuccessMessage, NULL, NULL); | ||
|
||
btn = Dict_FetchValue(dict, "open-warning-message"); | ||
Widget_BindEvent(btn, "click", OpenWarningMessage, NULL, NULL); | ||
|
||
btn = Dict_FetchValue(dict, "open-error-message"); | ||
Widget_BindEvent(btn, "click", OpenErrorMessage, NULL, NULL); | ||
|
||
btn = Dict_FetchValue(dict, "open-custom-duration-message"); | ||
Widget_BindEvent(btn, "click", OpenCustomDurationMessage, NULL, NULL); | ||
|
||
btn = Dict_FetchValue(dict, "open-loading-message"); | ||
Widget_BindEvent(btn, "click", OpenLoadingMessage, NULL, NULL); | ||
|
||
Dict_Release(dict); | ||
Widget_UnbindEvent(w, "ready", MessageView_OnReady); | ||
} | ||
|
||
static void MessageView_OnInit(LCUI_Widget w) | ||
{ | ||
Widget_BindEvent(w, "ready", MessageView_OnReady, NULL, NULL); | ||
} | ||
|
||
void UI_InitMessageView(void) | ||
{ | ||
message_view_proto = LCUIWidget_NewPrototype("message-view", NULL); | ||
message_view_proto->init = MessageView_OnInit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Message | ||
|
||
Display global messages as feedback in response to user operations. | ||
|
||
## Normal prompt | ||
|
||
Normal message for information. | ||
|
||
``` embedded-xml | ||
<w class="button-container"> | ||
<button ref="open-normal-message" class="btn btn-primary">Display normal message</button> | ||
</w> | ||
``` | ||
|
||
``` c | ||
#include <LCUI.h> | ||
#include <LCUI/gui/widget.h> | ||
#include <LCDesign/ui/components/message.h> | ||
|
||
static void OpenMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenInfoMessage(L"This is a normal message", 3000); | ||
} | ||
|
||
// ... other code | ||
|
||
LCUI_Widget btn = LCUIWidget_GetById("btn-open-message"); | ||
Widget_BindEvent(btn, "click", OpenMessage, NULL, NULL); | ||
|
||
// ... other code | ||
``` | ||
## Other types of message | ||
Messages of success, error and warning types. | ||
``` embedded-xml | ||
<w class="button-container"> | ||
<button ref="open-success-message" class="btn">Success</button> | ||
<button ref="open-error-message" class="btn">Error</button> | ||
<button ref="open-warning-message" class="btn">Warning</button> | ||
</w> | ||
``` | ||
|
||
``` c | ||
#include <LCUI.h> | ||
#include <LCUI/gui/widget.h> | ||
#include <LCDesign/ui/components/message.h> | ||
|
||
static void OpenSuccessMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenSuccessMessage(L"This is a success message", 3000); | ||
} | ||
|
||
static void OpenWarningMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenWarningMessage(L"This is a warning message", 3000); | ||
} | ||
|
||
static void OpenErrorMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenErrorMessage(L"This is a error message", 3000); | ||
} | ||
|
||
// ... other code | ||
|
||
LCUI_Widget btn; | ||
|
||
btn = LCUIWidget_GetById("btn-open-success-message"); | ||
Widget_BindEvent(btn, "click", OpenSuccessMessage, NULL, NULL); | ||
|
||
btn = LCUIWidget_GetById("btn-open-warning-message"); | ||
Widget_BindEvent(btn, "click", OpenWarningMessage, NULL, NULL); | ||
|
||
btn = LCUIWidget_GetById("btn-open-error-message"); | ||
Widget_BindEvent(btn, "click", OpenErrorMessage, NULL, NULL); | ||
|
||
// ... other code | ||
``` | ||
## Customize duration | ||
Customize message display duration to `10s`. | ||
``` embedded-xml | ||
<w class="button-container"> | ||
<button ref="open-custom-duration-message" class="btn">Customized display duration</button> | ||
</w> | ||
``` | ||
|
||
``` c | ||
#include <LCUI.h> | ||
#include <LCUI/gui/widget.h> | ||
#include <LCDesign/ui/components/message.h> | ||
|
||
static void OpenMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenSuccessMessage(L"This is a prompt message for success, " | ||
L"and it will disappear in 10 seconds", | ||
10000); | ||
} | ||
|
||
// ... other code | ||
|
||
LCUI_Widget btn = LCUIWidget_GetById("btn-open-message"); | ||
Widget_BindEvent(btn, "click", OpenMessage, NULL, NULL); | ||
|
||
// ... other code | ||
``` | ||
## Message with loading indicator | ||
Display a global loading indicator, which is dismissed by itself asynchronously. | ||
``` embedded-xml | ||
<w class="button-container"> | ||
<button ref="open-loading-message" class="btn">Display a loading indicator</button> | ||
</w> | ||
``` | ||
|
||
``` c | ||
#include <LCUI.h> | ||
#include <LCUI/gui/widget.h> | ||
#include <LCDesign/ui/components/message.h> | ||
|
||
static void OpenMessage(LCUI_Widget w, LCUI_WidgetEvent e, void *arg) | ||
{ | ||
LCDesign_OpenLoadingMessage(L"Action in progress..", 3000); | ||
} | ||
|
||
// ... other code | ||
|
||
LCUI_Widget btn = LCUIWidget_GetById("btn-open-message"); | ||
Widget_BindEvent(btn, "click", OpenMessage, NULL, NULL); | ||
|
||
// ... other code | ||
``` |
Oops, something went wrong.