The Calculator demo is a GUI application for performing basic arithmetic operations. It utilizes resizing Containers to ensure a structured and dynamic layout. This template is ideal for learning how to create and organize GUI controls, as well as scripting logic.
How it Works
The Calculator demo organizes Buttons and Labels within Containers, which maintain scalability and alignment across various screen/window resolutions. Operations are managed mainly by the DoCalculation and UpdateCalculation functions, both of which use global variables among other APIs and scripting logic to process user inputs.
UI Theming with Stylesheets
The Calculator demo utilizes a "Theme" Stylesheet to define the appearance of its UI elements, such as Buttons, Labels, and Textboxes. Stylesheets are CSS Resources designed to control the visuals of UI elements. They define the colors, fonts, borders, margins, and more for a consistent design across the project.
In this case, the calculator's UI is styled using a custom Stylesheet. This means any changes to the Stylesheet (e.g. font color) affect all corresponding elements in the project dynamically. Attempting to modify the UI appearance directly in the editor (e.g. changing a Button's color) is not recommended, as the Stylesheet will simply override those changes. To make permanent modifications, the Stylesheet itself should be editted.
You may create a new Stylesheet or modify an existing one. For simplicity, it's recommended to click Import from Editor Theme which provides a default setup. Then, you can simply tweak specific parameters, like Button effects, font sizes, or borders. To create a new Stylesheet, click the Create Resource icon in Tools > Resources, specify a name and then select Stylesheet under the General category.
Adding a New Operation: Factorial ("n!")
Follow these steps to add a factorial operation to the Calculator: