Skip to content

Commit

Permalink
The great formattening - format all library source code and documents
Browse files Browse the repository at this point in the history
- Format C++ source code (clang-format).
- Remove function definition comments (duplicated from headers).
- Remove macros for unused parameters.
- Make consistent indentation for RML and RCSS files.
- Remove trailing whitespace.
- Update copyright year.
  • Loading branch information
mikke89 committed Apr 12, 2023
1 parent d46d2d5 commit 7492876
Show file tree
Hide file tree
Showing 807 changed files with 14,024 additions and 16,645 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ root = true
[CMakeLists.txt]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.{rcss,rml}]
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 1 addition & 1 deletion Backends/RmlUi_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 5 additions & 6 deletions Backends/RmlUi_Backend_GLFW_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -148,9 +148,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
data->context = context;
data->key_down_callback = key_down_callback;

if(power_save)
if (power_save)
glfwWaitEventsTimeout(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0));
else glfwPollEvents();
else
glfwPollEvents();

data->context = nullptr;
data->key_down_callback = nullptr;
Expand Down Expand Up @@ -220,9 +221,7 @@ static void SetupCallbacks(GLFWwindow* window)
break;
}
break;
case GLFW_RELEASE:
RmlGLFW::ProcessKeyCallback(context, glfw_key, glfw_action, glfw_mods);
break;
case GLFW_RELEASE: RmlGLFW::ProcessKeyCallback(context, glfw_key, glfw_action, glfw_mods); break;
}
});

Expand Down
11 changes: 5 additions & 6 deletions Backends/RmlUi_Backend_GLFW_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -160,9 +160,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
data->context = context;
data->key_down_callback = key_down_callback;

if(power_save)
if (power_save)
glfwWaitEventsTimeout(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0));
else glfwPollEvents();
else
glfwPollEvents();

data->context = nullptr;
data->key_down_callback = nullptr;
Expand Down Expand Up @@ -232,9 +233,7 @@ static void SetupCallbacks(GLFWwindow* window)
break;
}
break;
case GLFW_RELEASE:
RmlGLFW::ProcessKeyCallback(context, glfw_key, glfw_action, glfw_mods);
break;
case GLFW_RELEASE: RmlGLFW::ProcessKeyCallback(context, glfw_key, glfw_action, glfw_mods); break;
}
});

Expand Down
4 changes: 2 additions & 2 deletions Backends/RmlUi_Backend_GLFW_VK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -291,4 +291,4 @@ static void SetupCallbacks(GLFWwindow* window)

glfwSetWindowContentScaleCallback(window,
[](GLFWwindow* /*window*/, float xscale, float /*yscale*/) { RmlGLFW::ProcessContentScaleCallback(data->context, xscale); });
}
}
9 changes: 5 additions & 4 deletions Backends/RmlUi_Backend_SDL_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -265,9 +265,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call

SDL_Event ev;
int has_event = 0;
if(power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000));
else has_event = SDL_PollEvent(&ev);
if (power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000));
else
has_event = SDL_PollEvent(&ev);
while (has_event)
{
switch (ev.type)
Expand Down
9 changes: 5 additions & 4 deletions Backends/RmlUi_Backend_SDL_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -244,9 +244,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call

SDL_Event ev;
int has_event = 0;
if(power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000));
else has_event = SDL_PollEvent(&ev);
if (power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000));
else
has_event = SDL_PollEvent(&ev);
while (has_event)
{
switch (ev.type)
Expand Down
11 changes: 6 additions & 5 deletions Backends/RmlUi_Backend_SDL_SDLrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -129,11 +129,12 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call

bool result = data->running;
SDL_Event ev;

int has_event = 0;
if(power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000));
else has_event = SDL_PollEvent(&ev);
if (power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000));
else
has_event = SDL_PollEvent(&ev);
while (has_event)
{
switch (ev.type)
Expand Down
13 changes: 7 additions & 6 deletions Backends/RmlUi_Backend_SDL_VK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -79,14 +79,14 @@ bool Backend::Initialize(const char* window_name, int width, int height, bool al
Rml::Vector<const char*> extensions;
{
unsigned int count;
if(!SDL_Vulkan_GetInstanceExtensions(window, &count, nullptr))
if (!SDL_Vulkan_GetInstanceExtensions(window, &count, nullptr))
{
data.reset();
fprintf(stderr, "Could not get required vulkan extensions");
return false;
}
extensions.resize(count);
if(!SDL_Vulkan_GetInstanceExtensions(window, &count, extensions.data()))
if (!SDL_Vulkan_GetInstanceExtensions(window, &count, extensions.data()))
{
data.reset();
fprintf(stderr, "Could not get required vulkan extensions");
Expand Down Expand Up @@ -167,9 +167,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
SDL_Event ev;

int has_event = 0;
if(power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000));
else has_event = SDL_PollEvent(&ev);
if (power_save)
has_event = SDL_WaitEventTimeout(&ev, static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000));
else
has_event = SDL_PollEvent(&ev);
while (has_event)
{
switch (ev.type)
Expand Down
14 changes: 4 additions & 10 deletions Backends/RmlUi_Backend_SFML_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -205,9 +205,7 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
{
switch (ev.type)
{
case sf::Event::Resized:
UpdateWindowDimensions(data->window, data->render_interface, context);
break;
case sf::Event::Resized: UpdateWindowDimensions(data->window, data->render_interface, context); break;
case sf::Event::KeyPressed:
{
const Rml::Input::KeyIdentifier key = RmlSFML::ConvertKey(ev.key.code);
Expand All @@ -225,12 +223,8 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
break;
}
break;
case sf::Event::Closed:
result = false;
break;
default:
RmlSFML::InputHandler(context, ev);
break;
case sf::Event::Closed: result = false; break;
default: RmlSFML::InputHandler(context, ev); break;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Backends/RmlUi_Backend_Win32_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -191,12 +191,12 @@ Rml::RenderInterface* Backend::GetRenderInterface()

static bool NextEvent(MSG& message, UINT timeout)
{
if(timeout != 0)
if (timeout != 0)
{
UINT_PTR timer_id = SetTimer(NULL, NULL, timeout, NULL);
BOOL res = GetMessage(&message, NULL, 0, 0);
KillTimer(NULL, timer_id);
if(message.message != WM_TIMER || message.hwnd != nullptr || message.wParam != timer_id)
if (message.message != WM_TIMER || message.hwnd != nullptr || message.wParam != timer_id)
return res;
}
return PeekMessage(&message, nullptr, 0, 0, PM_REMOVE);
Expand All @@ -219,7 +219,7 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
data->key_down_callback = key_down_callback;

MSG message;
bool has_message = NextEvent(message, power_save ? static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000.0) : 0);
bool has_message = NextEvent(message, power_save ? static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000.0) : 0);
while (has_message)
{
// Dispatch the message to our local event handler below.
Expand Down Expand Up @@ -461,4 +461,4 @@ static void DetachFromNative(HWND window_handle, HDC device_context, HGLRC rende
{
ReleaseDC(window_handle, device_context);
}
}
}
12 changes: 6 additions & 6 deletions Backends/RmlUi_Backend_Win32_VK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -193,12 +193,12 @@ Rml::RenderInterface* Backend::GetRenderInterface()

static bool NextEvent(MSG& message, UINT timeout)
{
if(timeout != 0)
if (timeout != 0)
{
UINT_PTR timer_id = SetTimer(NULL, NULL, timeout, NULL);
BOOL res = GetMessage(&message, NULL, 0, 0);
KillTimer(NULL, timer_id);
if(message.message != WM_TIMER || message.hwnd != nullptr || message.wParam != timer_id)
if (message.message != WM_TIMER || message.hwnd != nullptr || message.wParam != timer_id)
return res;
}
return PeekMessage(&message, nullptr, 0, 0, PM_REMOVE);
Expand All @@ -222,10 +222,10 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call

MSG message;
// Process events.
bool has_message = NextEvent(message, power_save ? static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0)*1000.0) : 0);
bool has_message = NextEvent(message, power_save ? static_cast<int>(Rml::Math::Min(context->GetNextUpdateDelay(), 10.0) * 1000.0) : 0);
while (has_message || !data->render_interface.IsSwapchainValid())
{
if(has_message)
if (has_message)
{
// Dispatch the message to our local event handler below.
TranslateMessage(&message);
Expand All @@ -237,7 +237,7 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
// we trap the application inside this loop until we are able to recreate the swapchain and render again.
if (!data->render_interface.IsSwapchainValid())
data->render_interface.RecreateSwapchain();

has_message = NextEvent(message, 0);
}

Expand Down
20 changes: 11 additions & 9 deletions Backends/RmlUi_Backend_X11_GL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
* Copyright (c) 2019-2023 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -39,6 +39,7 @@
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/extensions/xf86vmode.h>
#include <cmath>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
Expand All @@ -48,7 +49,6 @@
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <cmath>

// Attach the OpenGL context to the window.
static bool AttachToNative(GLXContext& out_gl_context, Display* display, Window window, XVisualInfo* visual_info)
Expand Down Expand Up @@ -215,24 +215,26 @@ bool Backend::ProcessEvents(Rml::Context* context, KeyDownCallback key_down_call
bool result = data->running;
data->running = true;

if(power_save && XPending(display) == 0) {
if (power_save && XPending(display) == 0)
{
int display_fd = ConnectionNumber(display);
fd_set fds{};
FD_ZERO(&fds);
FD_SET(display_fd, &fds);
FD_SET(display_fd, &fds);

double timeout = Rml::Math::Min(context->GetNextUpdateDelay(), 10.0);
struct timeval tv{};
struct timeval tv {};
double seconds;
tv.tv_usec = std::modf(timeout, &seconds)*1000000.0;
tv.tv_sec = seconds;
tv.tv_usec = std::modf(timeout, &seconds) * 1000000.0;
tv.tv_sec = seconds;

int ready_fd_count;
do {
do
{
ready_fd_count = select(display_fd + 1, &fds, NULL, NULL, &tv);
// We don't care about the return value as long as select didn't error out
RMLUI_ASSERT(ready_fd_count >= 0);
} while(XPending(display) == 0 && ready_fd_count != 0);
} while (XPending(display) == 0 && ready_fd_count != 0);
}

while (XPending(display) > 0)
Expand Down
Loading

0 comments on commit 7492876

Please sign in to comment.