-
Notifications
You must be signed in to change notification settings - Fork 12
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
1 parent
dd1987a
commit fa365bc
Showing
3 changed files
with
67 additions
and
34 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
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,36 @@ | ||
#include "ssGUI/HeaderGroups/StandardGroup.hpp" | ||
#include "ssGUI/Extensions/Layout.hpp" | ||
|
||
//Readme example | ||
using namespace ssGUI::Enums; | ||
int main() | ||
{ | ||
ssGUI::MainWindow mainWindow; //Create the main window for showing content | ||
mainWindow.SetRenderSize(glm::vec2(450, 80)); | ||
auto* layout = ssGUI::Factory::Create<ssGUI::Extensions::Layout>(); | ||
mainWindow.AddExtension(layout); //Add layout for auto sizing child GUI objects | ||
|
||
ssGUI::Text text; //Create a text widget and set the respective properties | ||
text.SetNewCharacterFontSize(17); | ||
text.SetText("Click on the button to show the message"); | ||
text.SetAlignment(AlignmentHorizontal::CENTER, AlignmentVertical::CENTER); //We center the text right above the button we will be adding later | ||
text.SetParent(&mainWindow); //Attach text to main window, the layout will control its size. | ||
|
||
ssGUI::StandardButton button; //Create a standard button, just a more fancier button. | ||
button.SetSize(glm::vec2(50, 30)); | ||
layout->AddChildWithAlignment(&button, AlignmentHorizontal::CENTER, //Attach button to main window with alignment, so that the size | ||
AlignmentVertical::CENTER); // stays the same and won't be changed by layout | ||
|
||
ssGUI::ssGUIManager guiManager; //Create the GUIManager, which manages the flow of the program. | ||
guiManager.AddGUIObject((ssGUI::GUIObject*)&mainWindow); //Add the main window (which has both text and button parented to it) | ||
guiManager.AddPostGUIUpdateEventListener | ||
( | ||
[&]() | ||
{ | ||
if(button.GetButtonState() == ssGUI::Enums::ButtonState::CLICKED) //Then we want to check if the button is pressed every frame | ||
text.SetText(L"(`oωo´)"); //If it is, we change the text to a cute little face :) | ||
} | ||
); | ||
guiManager.StartRunning(); //Finally we start running the program | ||
return 0; | ||
} |