Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions examples/emscripten/main-GLFW_GLES2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <TGUI/TGUI.hpp>

#include <TGUI/Backend/GLFW-GLES2.hpp>
#include <TGUI/Backend/Renderer/OpenGL.hpp>

#include <emscripten/emscripten.h>
#include <iostream>

Expand All @@ -17,7 +19,8 @@ void init()
{
glfwInit();

std::cout << "glfwGetVersionString PROG " << glfwGetVersionString() << " " << GLFW_VERSION_MAJOR << "." << GLFW_VERSION_MINOR << "." << GLFW_VERSION_REVISION << "\n";
std::cout << "glfwGetVersionString PROG " << glfwGetVersionString() << " " << GLFW_VERSION_MAJOR << "." << GLFW_VERSION_MINOR
<< "." << GLFW_VERSION_REVISION << "\n";

glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
Expand All @@ -35,34 +38,38 @@ std::cout << "glfwGetVersionString PROG " << glfwGetVersionString() << " " << GL
glfwSetWindowUserPointer(window, gui.get());

// When we receive an event callback from GLFW, we need to pass the event to TGUI
glfwSetWindowFocusCallback(window, [](GLFWwindow* wnd, int focused) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->windowFocusCallback(focused);
});
glfwSetFramebufferSizeCallback(window, [](GLFWwindow* wnd, int width, int height) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->sizeCallback(width, height);
});
glfwSetCharCallback(window, [](GLFWwindow* wnd, unsigned int codepoint) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->charCallback(codepoint);
});
glfwSetKeyCallback(window, [](GLFWwindow* wnd, int key, int scancode, int action, int mods) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->keyCallback(key, scancode, action, mods);
});
glfwSetScrollCallback(window, [](GLFWwindow* wnd, double xoffset, double yoffset) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->scrollCallback(xoffset, yoffset);
});
glfwSetCursorPosCallback(window, [](GLFWwindow* wnd, double xpos, double ypos) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->cursorPosCallback(xpos, ypos);
});
glfwSetMouseButtonCallback(window, [](GLFWwindow* wnd, int button, int action, int mods) {
std::cout << glfwGetWindowUserPointer(wnd) << "\n";
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->mouseButtonCallback(button, action, mods);
});
glfwSetCursorEnterCallback(window, [](GLFWwindow* wnd, int entered) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->cursorEnterCallback(entered);
});
glfwSetMouseButtonCallback(window, [](GLFWwindow* wnd, int button, int action, int mods) {
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->mouseButtonCallback(button, action, mods);
});
glfwSetWindowFocusCallback(window,
[](GLFWwindow* wnd, int focused)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->windowFocusCallback(focused); });
glfwSetFramebufferSizeCallback(window,
[](GLFWwindow* wnd, int width, int height)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->sizeCallback(width, height); });
glfwSetCharCallback(window,
[](GLFWwindow* wnd, unsigned int codepoint)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->charCallback(codepoint); });
glfwSetKeyCallback(window,
[](GLFWwindow* wnd, int key, int scancode, int action, int mods)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->keyCallback(key, scancode, action, mods); });
glfwSetScrollCallback(window,
[](GLFWwindow* wnd, double xoffset, double yoffset)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->scrollCallback(xoffset, yoffset); });
glfwSetCursorPosCallback(window,
[](GLFWwindow* wnd, double xpos, double ypos)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->cursorPosCallback(xpos, ypos); });
glfwSetMouseButtonCallback(window,
[](GLFWwindow* wnd, int button, int action, int mods)
{
std::cout << glfwGetWindowUserPointer(wnd) << "\n";
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->mouseButtonCallback(button, action, mods);
});
glfwSetCursorEnterCallback(window,
[](GLFWwindow* wnd, int entered)
{ static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->cursorEnterCallback(entered); });
glfwSetMouseButtonCallback(window,
[](GLFWwindow* wnd, int button, int action, int mods)
{
static_cast<tgui::Gui*>(glfwGetWindowUserPointer(wnd))->mouseButtonCallback(button, action, mods);
});

auto picture = tgui::Picture::create("data/background.jpg");
picture->setSize({400, 300});
Expand Down
2 changes: 2 additions & 0 deletions examples/emscripten/main-RAYLIB.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <TGUI/TGUI.hpp>

#include <TGUI/Backend/raylib.hpp>

#include <emscripten/emscripten.h>
#include <iostream>

Expand Down
5 changes: 4 additions & 1 deletion examples/emscripten/main-SDL_GLES2.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <TGUI/TGUI.hpp>

#include <TGUI/Backend/SDL-GLES2.hpp>
#include <emscripten/emscripten.h>

#include <SDL3/SDL_main.h>
#include <SDL3/SDL_opengles2.h>

#include <emscripten/emscripten.h>
#include <iostream>

EM_JS(int, canvas_get_width, (), { return canvas.width; });
Expand Down
2 changes: 2 additions & 0 deletions examples/emscripten/main-SDL_RENDERER.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <TGUI/TGUI.hpp>

#include <TGUI/Backend/SDL-Renderer.hpp>

#include <emscripten/emscripten.h>
#include <iostream>

Expand Down
5 changes: 4 additions & 1 deletion examples/emscripten/main-SDL_TTF_GLES2.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <TGUI/TGUI.hpp>

#include <TGUI/Backend/SDL-TTF-GLES2.hpp>
#include <emscripten/emscripten.h>

#include <SDL3/SDL_main.h>
#include <SDL3/SDL_opengles2.h>

#include <emscripten/emscripten.h>
#include <iostream>

EM_JS(int, canvas_get_width, (), { return canvas.width; });
Expand Down
6 changes: 3 additions & 3 deletions gui-builder/src/Form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace
{
for (const auto& pair : node->propertyValuePairs)
{
if (((pair.first.size() >= 7) && (pair.first.starts_with(U"Texture"))) || (pair.first == U"Font")
if (((pair.first.size() >= 7) && pair.first.starts_with(U"Texture")) || (pair.first == U"Font")
|| (pair.first == U"Image"))
{
if (pair.second->value.empty() || pair.second->value.equalIgnoreCase(U"none")
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace
{
for (const auto& pair : node->propertyValuePairs)
{
if (((pair.first.size() >= 7) && (pair.first.starts_with(U"Texture"))) || (pair.first == U"Font")
if (((pair.first.size() >= 7) && pair.first.starts_with(U"Texture")) || (pair.first == U"Font")
|| (pair.first == U"Image"))
{
if (pair.second->value.empty() || pair.second->value.equalIgnoreCase(U"none")
Expand Down Expand Up @@ -1008,7 +1008,7 @@ void Form::save()
if (formPath.back() != '/')
formPath.push_back('/');

tgui::String guiBuilderPath = (tgui::getResourcePath()).getParentPath().asString();
tgui::String guiBuilderPath = tgui::getResourcePath().getParentPath().asString();
if (guiBuilderPath.back() != '/')
guiBuilderPath.push_back('/');

Expand Down
4 changes: 2 additions & 2 deletions gui-builder/src/GuiBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ void GuiBuilder::addPropertyValueLayout(const tgui::String& property, const tgui
const tgui::Layout layout(value);

assert(property == U"Left" || property == U"Top" || property.ends_with(U"Width") || property.ends_with(U"Height"));
const bool isHorizontal = (property == U"Left") || (property.ends_with(U"Width"));
const bool isHorizontal = (property == U"Left") || property.ends_with(U"Width");

const bool layoutIsConstant = layout.isConstant();
const bool layoutIsPercentage = !layoutIsConstant && value.ends_with(U'%') && layout.getLeftOperand() && layout.getRightOperand()
Expand Down Expand Up @@ -3186,7 +3186,7 @@ bool GuiBuilder::fillWidgetHierarchy(std::vector<tgui::String>& hierarchy, tgui:
const size_t widgetCount = parent->getWidgets().size();
for (size_t i = 0; i < widgetCount; ++i)
{
if ((parent->getWidgets()[i]).get() == widget)
if (parent->getWidgets()[i].get() == widget)
{
wasFound = fillWidgetHierarchy(hierarchy, parent);
break;
Expand Down
Loading
Loading