Formatting review
This commit is contained in:
parent
2efb50cc63
commit
7f2a071c51
4 changed files with 29 additions and 25 deletions
17
src/core.c
17
src/core.c
|
@ -5102,17 +5102,20 @@ static void ErrorCallback(int error, const char *description)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "GLFW: Error: %i Description: %s", error, description);
|
TRACELOG(LOG_WARNING, "GLFW: Error: %i Description: %s", error, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
EM_JS(int, CanvasGetWidth, (), { return canvas.clientWidth; });
|
EM_JS(int, GetCanvasWidth, (), { return canvas.clientWidth; });
|
||||||
EM_JS(int, CanvasGetHeight, (), { return canvas.clientHeight; });
|
EM_JS(int, GetCanvasHeight, (), { return canvas.clientHeight; });
|
||||||
|
|
||||||
static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *e, void *userData)
|
static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *e, void *userData)
|
||||||
{
|
{
|
||||||
// Don't resize non-resizeable windows
|
// Don't resize non-resizeable windows
|
||||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) return true;
|
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) return true;
|
||||||
// This event is called whenever the window changes sizes, so the size of
|
|
||||||
// the canvas object is explicitly retrieved below
|
// This event is called whenever the window changes sizes,
|
||||||
int width = CanvasGetWidth();
|
// so the size of the canvas object is explicitly retrieved below
|
||||||
int height = CanvasGetHeight();
|
int width = GetCanvasWidth();
|
||||||
|
int height = GetCanvasHeight();
|
||||||
emscripten_set_canvas_element_size("#canvas",width,height);
|
emscripten_set_canvas_element_size("#canvas",width,height);
|
||||||
|
|
||||||
SetupViewport(width, height); // Reset viewport and projection matrix for new size
|
SetupViewport(width, height); // Reset viewport and projection matrix for new size
|
||||||
|
@ -5126,9 +5129,11 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *
|
||||||
// Set current screen size
|
// Set current screen size
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
|
|
||||||
// NOTE: Postprocessing texture is not scaled to new size
|
// NOTE: Postprocessing texture is not scaled to new size
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
|
||||||
// NOTE: Window resizing not allowed by default
|
// NOTE: Window resizing not allowed by default
|
||||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
|
|
13
src/text.c
13
src/text.c
|
@ -929,10 +929,9 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
|
||||||
float glyphWidth = 0;
|
float glyphWidth = 0;
|
||||||
if (codepoint != '\n')
|
if (codepoint != '\n')
|
||||||
{
|
{
|
||||||
glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width * scaleFactor : font.chars[index].advanceX * scaleFactor;
|
glyphWidth = (font.chars[index].advanceX == 0) ? font.recs[index].width*scaleFactor : font.chars[index].advanceX*scaleFactor;
|
||||||
|
|
||||||
if (i + 1 < length)
|
if (i + 1 < length) glyphWidth = glyphWidth + spacing;
|
||||||
glyphWidth = glyphWidth + spacing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
// NOTE: When wordWrap is ON we first measure how much of the text we can draw before going outside of the rec container
|
||||||
|
@ -979,7 +978,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
|
||||||
{
|
{
|
||||||
if (!wordWrap)
|
if (!wordWrap)
|
||||||
{
|
{
|
||||||
textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor;
|
textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
|
||||||
textOffsetX = 0;
|
textOffsetX = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -987,7 +986,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
|
||||||
{
|
{
|
||||||
if (!wordWrap && ((textOffsetX + glyphWidth) > rec.width))
|
if (!wordWrap && ((textOffsetX + glyphWidth) > rec.width))
|
||||||
{
|
{
|
||||||
textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor;
|
textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
|
||||||
textOffsetX = 0;
|
textOffsetX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +997,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
|
||||||
bool isGlyphSelected = false;
|
bool isGlyphSelected = false;
|
||||||
if ((selectStart >= 0) && (k >= selectStart) && (k < (selectStart + selectLength)))
|
if ((selectStart >= 0) && (k >= selectStart) && (k < (selectStart + selectLength)))
|
||||||
{
|
{
|
||||||
DrawRectangleRec((Rectangle){ rec.x + textOffsetX - 1, rec.y + textOffsetY, glyphWidth, (float)font.baseSize * scaleFactor }, selectBackTint);
|
DrawRectangleRec((Rectangle){ rec.x + textOffsetX - 1, rec.y + textOffsetY, glyphWidth, (float)font.baseSize*scaleFactor }, selectBackTint);
|
||||||
isGlyphSelected = true;
|
isGlyphSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,7 +1010,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
|
||||||
|
|
||||||
if (wordWrap && (i == endLine))
|
if (wordWrap && (i == endLine))
|
||||||
{
|
{
|
||||||
textOffsetY += (font.baseSize + font.baseSize / 2) * scaleFactor;
|
textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
|
||||||
textOffsetX = 0;
|
textOffsetX = 0;
|
||||||
startLine = endLine;
|
startLine = endLine;
|
||||||
endLine = -1;
|
endLine = -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue