Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

slothchvnk

2
Posts
A member registered Aug 29, 2024

Recent community posts

(2 edits)

int gui_status_bar_height = 24;
int gui_window_close_button_height = 18;
#define RAYGUI_WINDOWBOX_CLOSEBUTTON_HEIGHT gui_window_close_button_height
#define RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT gui_status_bar_height
#include "raygui.h"
Rectangle GuiLayoutScaleRect(Rectangle rect, Vector2 anchor, float scale) {
   return (Rectangle) {rect.x * scale + anchor.x, rect.y * scale + anchor.y, rect.width * scale, rect.height * scale};
}
GuiLayoutState InitGuiLayout(float screen_width, float screen_height, float padding) {
  GuiLayoutState state = {0};
  float orig_width = 400.f;
  float orig_height = 192.0f;
  float offset_x = 8.0f;
  float offset_y = 32.0f;
  float scale = (screen_width - 2.0f * padding) / orig_width;
  if ((orig_height * scale) > (screen_height - 2.0f * padding))     scale = (screen_height - 2.0f * padding) / orig_height;
  float window_width = orig_width * scale;
  float window_height = orig_height * scale;
  float window_x = (screen_width - window_width) / 2.0f;
  float window_y = (screen_height - window_height) / 2.0f;
  state.Anchor = (Vector2){window_x + offset_x * scale, window_y + offset_y * scale };
  state.LayoutRects[LO_WINDOW] = (Rectangle) {window_x, window_y, window_width, window_height };
  state.LayoutRects[LO_MORE] = GuiLayoutScaleRect((Rectangle){114, -32, 96, 24 }, state.Anchor, scale);
  // ...
  GuiSetStyle(DEFAULT, TEXT_PADDING, (int)(4.0f * scale));
  GuiSetStyle(DEFAULT, TEXT_SIZE, (int)(16.0f * scale));
  GuiSetStyle(DEFAULT, TEXT_SPACING, (int)(1.0f * scale));
  GuiSetStyle(DEFAULT, TEXT_LINE_SPACING, (int)(24.0f * scale));
  GuiSetStyle(VALUEBOX, SPINNER_BUTTON_WIDTH, (int)(24.0f * scale));
  GuiSetStyle(VALUEBOX, SPINNER_BUTTON_SPACING, (int)(2.0f * scale));
  GuiSetStyle(VALUEBOX, TEXT_PADDING, (int)(4.0f * scale));
  GuiSetStyle(SLIDER, SLIDER_WIDTH, (int)(16.0f * scale));
  GuiSetStyle(SLIDER, SLIDER_PADDING, (int)(1.0f * scale));
  GuiSetIconScale((int)scale);
  gui_status_bar_height = (int)(24.0f * scale);
  gui_window_close_button_height = (int)(18.0f * scale);
  return state;
}

Is there a way to re-link a control to an anchor if it was unlinked from an anchor?