mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Updated About the IMGUI paradigm (markdown)
parent
107f6f16e1
commit
f1aa74b704
@ -53,34 +53,37 @@ m_SaveItem = NULL;
|
|||||||
// [...] React to item being pressed
|
// [...] React to item being pressed
|
||||||
void OnSave()
|
void OnSave()
|
||||||
{
|
{
|
||||||
m_Document->Save();
|
m_Document->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// [...] Sync enable state so item can be greyed
|
// [...] Sync enable state so item can be greyed
|
||||||
// IMPORTANT: Don't forget to call otherwise update menu color won't be correct!
|
// IMPORTANT: Don't forget to call otherwise update menu color won't be correct!
|
||||||
void UpdateSaveEnabledState()
|
void UpdateSaveEnabledState()
|
||||||
{
|
{
|
||||||
m_SaveItem->SetEnabled(m_Document != NULL && m_Document->m_IsDirty);
|
m_SaveItem->SetEnabled(m_Document != NULL && m_Document->m_IsDirty);
|
||||||
}
|
}
|
||||||
void SetDocumentDirty(bool dirty)
|
void SetDocumentDirty(bool dirty)
|
||||||
{
|
{
|
||||||
if (m_Document)
|
if (m_Document)
|
||||||
m_Document->m_IsDirty = dirty;
|
m_Document->m_IsDirty = dirty;
|
||||||
UpdateSaveEnabledState();
|
UpdateSaveEnabledState();
|
||||||
}
|
}
|
||||||
set SetDocument(Document* document)
|
void SetDocument(Document* document)
|
||||||
{
|
{
|
||||||
m_Document = document;
|
m_Document = document;
|
||||||
UpdateSaveEnabledState();
|
UpdateSaveEnabledState();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Typical IMGUI:
|
Typical IMGUI:
|
||||||
```cpp
|
```cpp
|
||||||
// editor.cpp
|
// editor.cpp
|
||||||
bool is_save_allowed = (m_Document != NULL && m_Document->m_IsDirty);
|
void UpdateUI()
|
||||||
if (Lib_MenuItem("SAVE", is_save_allowed))
|
{
|
||||||
m_Document->Save();
|
bool is_save_allowed = (m_Document != NULL && m_Document->m_IsDirty);
|
||||||
|
if (Lib_MenuItem("SAVE", is_save_allowed))
|
||||||
|
m_Document->Save();
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This is a simple and perhaps exaggerated example provided to get a better intuition about the difference of IMGUI vs RMGUI. There are lots of things to say and criticize about this example. It tends to illustrates the shortcoming of RMGUIs more than it illustrates the shortcomings of IMGUIs. But it should illustrate the core benefit that IMGUIs **tends to facilitate data binding, action binding, and creation/destruction of UI components**. It does facilitate those things because it generally doesn't need them.
|
This is a simple and perhaps exaggerated example provided to get a better intuition about the difference of IMGUI vs RMGUI. There are lots of things to say and criticize about this example. It tends to illustrates the shortcoming of RMGUIs more than it illustrates the shortcomings of IMGUIs. But it should illustrate the core benefit that IMGUIs **tends to facilitate data binding, action binding, and creation/destruction of UI components**. It does facilitate those things because it generally doesn't need them.
|
||||||
|
Loading…
Reference in New Issue
Block a user