view third_party/raylib/custom.c @ 143:276bb3555034

Should work now.
author June Park <parkjune1995@gmail.com>
date Fri, 09 Jan 2026 13:13:27 -0800
parents 7bd795bac997
children 87d8d3eb3491
line wrap: on
line source

#include "third_party/raylib/include/raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "third_party/raylib/include/raygui.h"

// -- forward declarations --//

// --- Default Behaviour that should be part of all raylib gui ---/
void DefaultBehaviours();
// --- Increase Font Sizes on key press --- //
void IncreaseFontSize();
// --- Decrease Font Sizes on key press --- //
void DecreaseFontSize();


void DefaultBehaviours()
{
  // Font sizes 
  IncreaseFontSize();
  DecreaseFontSize();
}

void IncreaseFontSize()
{
  if ((IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyDown(KEY_EQUAL))
    GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetStyle(DEFAULT, TEXT_SIZE) + 1);
}

void DecreaseFontSize()
{
  if ((IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_LEFT_CONTROL)) && IsKeyDown(KEY_MINUS))
    GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetStyle(DEFAULT, TEXT_SIZE) - 1);
}


// --- Layout helper --- //
Rectangle RightOf(Rectangle ref, float padding)
{
  return (Rectangle){
    .x = ref.x + ref.width + padding,
    .y = ref.y,
    .width = 0,
    .height = ref.height
  };
}

Rectangle Below(Rectangle ref, float padding)
{
  return (Rectangle){
    .x = ref.x,
    .y = ref.y + ref.height + padding,
    .width = ref.width,
    .height = 0
  };
}

Rectangle LeftColumn(Rectangle container, float ratio, float padding)
{
  return (Rectangle){
    .x = container.x + padding,
    .y = container.y + padding,
    .width = (container.width * ratio) - padding,
    .height = container.height - (2 * padding)
  };
}

Rectangle RightColumn(Rectangle container, Rectangle leftCol, float padding)
{
  return (Rectangle){
    .x = leftCol.x + leftCol.width + padding,
    .y = container.y + padding,
    .width = container.width - leftCol.width - (3 * padding),
    .height = container.height - (2 * padding)
  };
}

Rectangle HorizontalSplit(Rectangle container, float ratio)
{
  return (Rectangle){
    .x = container.x,
    .y = container.y,
    .width = container.width * ratio,
    .height = container.height
  };
}