raysan5 / raygui Goto Github PK
View Code? Open in Web Editor NEWA simple and easy-to-use immediate-mode gui library
License: zlib License
A simple and easy-to-use immediate-mode gui library
License: zlib License
raylib examples Makefile should be enough, needs some review but.
Help on this is welcome.
Hi,
I'm attempting to use raygui with my raylib project, but after generating the project files for VS2019 or Make on OSX, a ton of errors are generated when trying to compile the raygui header.
It looks like there's an issue related to both casting and just the general C vs C++ syntax.
(copied from Visual Studio)
Error C2065 'RICONS_SIZE': undeclared identifier raylib-proj C:\raylib-proj\include\libs\raygui.h 681 Error C2065 'RICONS_SIZE': undeclared identifier raylib-proj C:\raylib-proj\include\libs\raygui.h 717 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 717 Error C3861 'DrawIcon': identifier not found raylib-proj C:\raylib-proj\include\libs\raygui.h 717 Error C2065 'RICONS_SIZE': undeclared identifier raylib-proj C:\raylib-proj\include\libs\raygui.h 721 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 865 Error C2065 'RICON_CROSS_SMALL': undeclared identifier raylib-proj C:\raylib-proj\include\libs\raygui.h 883 Error C2660 'GuiButton': function does not take 1 arguments raylib-proj C:\raylib-proj\include\libs\raygui.h 883 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 909 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 979 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 980 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1156 Error C2397 conversion from 'int' to 'float' requires a narrowing conversion raylib-proj C:\raylib-proj\include\libs\raygui.h 1156 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1187 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1287 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1440 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1444 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1448 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1453 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1460 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1466 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1481 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1488 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1489 Error C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax raylib-proj C:\raylib-proj\include\libs\raygui.h 1490
Hi,
I am trying to compile raygui/examples using gmake all and I am getting the linker error:
/usr/bin/ld: error: unable to find library -lraylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What should I do to fix this?
FreeBSD 12.0 64-bit
It would be very useful to implement an advance control for file picking (open/save dialog). It could require a lot of work and dealing with OS system calls to read directory contents and info.
Proposed signatures could be:
const char *GuiFileDialog(const char *title, const char *currentPath);
Note that this control could be further customized for Open/Save file modes.
Immediate implementation is not required but just listing it here for future reference.
I was attracted to raygui because it seemed like it would be easier to integrate with my engine than some other imgui implementations, since I could provide the drawing functions myself.
I started off with a simple stub looking like this. (All the seemingly pointless indirections are necessary because the engine isn't written in c.)
However, even that fails to compile, with these errors.
Posting here for clarification, and for anyone else that is trying to overcome this hurdle.
I have a C++ application where the GUI window is launched in main() and then manipulated via other C++ objects via raygui.
Originally, I was getting duplicate definition errors due to the way I was including raygui in all of my code, as seen below:
extern "C" {
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
}
The "correct" implementation for this should be to use the above within main(), and then use the following everywhere else:
extern "C" {
#include "raylib.h"
#define RAYGUI_STATIC
#include "raygui.h"
}
Is this "correct" ?
I'm trying to use Jungle RGS Style , and have an error for the font
WARNING: [(null)/"Pixel.otf"] TTF file could not be opened
the problem is the (null)
If it is, is there a code snippet for it?
Cairo website:
https://www.cairographics.org/
Many thanks!
Multiline text box is a requirement for most GUI systems.
Some work has already been done on implementing GuiTextBoxMulti()
but it's nor fully functional yet.
Similar to GuiTextBox()
proposed implementation would be:
bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode);
Having issues compiling rGuiStyler on linux as there is a missing reference to DrawRectangleT using the latest stable version of raylib (1.7.0)
INFO: Initializing raylib (v1.7.0)
/tmp/ccLbFxB1.o: In function `DrawRectangleRecT':
rguistyler.c:(.text+0x3a): undefined reference to `DrawRectangleT'
Looking at the source i see the following implementation of:
static void DrawRectangleRecT(Rectangle rec, Color color) { DrawRectangleT(rec.x, rec.y, rec.width, rec.height, color); }
But there is no implementation of DrawRectangleT anywhere in raygui or raylib.
Am i doing somthing wrong or is raygui experimental?
PS: compilation options
gcc -o test rguistyler.c external/tinyfiledialogs.c -lraylib -lglfw3 -lX11 -lXxf86vm -lXrandr -ldl -lXinerama -lXcursor -lGL -lGLU -lpthread -lm -std=c99 -Wall
Sincerly Axel Sanner
raygui allows defining RAYGUI_TEXTBOX_EXTENDED
for an advance GuiTextBox()
implementation. Actually, that implementation is a quite complete text editor with cut-copy-paste and advance features. It also implies a bunch of additional usage functions.
I'm considering moving this control to an independent portable module gui_texbox_edit.h
, similar to other windows/layouts I use on my tools development. That way, users could choose to add this advance control jut including:
#define GUI_TEXTBOX_EDITOR_IMPLEMENTATION
#include "gui_textbox_editor.h"
I noticed this when i started using a camera used for rendering textures, where the gui was rendering before everything. Dont really know why this happens, since normal raylib draw calls still work before BeginMode2D
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
int main(void)
{
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raygui");
SetTargetFPS(60);
Camera2D camera;
camera.target = (Vector2) { 0, 0 };
camera.offset = (Vector2) { 0, 0 };
camera.zoom = 1.0f;
while (!WindowShouldClose())
{
BeginDrawing();
if (GuiButton((Rectangle) { 0, 0, 100, 50 }, "Does not Render")) {
printf("still receiving message \n");
}
BeginMode2D(camera);
GuiButton((Rectangle) { 100, 0, 100, 50 }, "Does Render");
ClearBackground(RAYWHITE);
EndMode2D();
EndDrawing();
}
CloseWindow();
return 0;
}
Right now raygui implements following controls:
Here it is a possible list of additional controls:
What do you think?
When i'm tried to compile i received error
The issued in this project is "font.recs" has no member named
Can you add the raygui.dll to the releases the way raylib has its dlls in the same section? It would help me use the raylib bindings without having to compile the dlls from the source.
Hello,
I try to use it with Mingw g ++, and I get a lot of errors.
raygui.h:793:1: error: narrowing conversion of '4126537215' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
and lot of warnings :(
it does not like Mingw g++.
Links to rGuiStyler and rGuiLayout mentionned in README are dead. Are those still active ?
Hello,
First of all, very nice project, and what is the most important (for me), is a beautiful gfx style. :D
However, I have a suggestion. Would it be hard to add a vendor prefix to each public method of the library? That could prevent some name collisions which are theoretically possible right now. Especially for occasions where whole user's project codebase uses "unity builds" approach.
That is a major breaking change in API though. So what do you think about it?
Thank you!
I've been reviewing several controls and I got some doubts about the usefulness and general implementation of INNER_PADDING
property.
This property is used in different ways depending the control, in some controls it's just used as a kind-of text padding, maybe it should be renamed to TEXT_PADDING
or just removed from the global properties list.
Usage in the different controls:
GuiSlider*()
, GuiProgressBar()
> Used as top-botton padding for the controls slider/bars. Additional text padding is required.GuiStatusBar()
> Used for the text left padding.GuiCheckBox()
> Used for text left-right padding to control.GuiTextBoxMulti()
> Used as top-left text padding. Note this control does not support a different text alignment than top-left.GetTextBounds()
, considered on text bounds calculation, usually top-bottom padding does not have much sense...This property should be reviewed or maybe renamed but using it in different ways could be confusing for the users.
The styles readme mentions:
NOTE: Those styles require latest raylib 2.6-dev and latest raygui 2.6-dev.
As far as I can tell, there is no branch that correlates to a 2.6-dev version of raylib? Is there a different repository other than the one found here?
That repo only has 1 branch and it has a PROJECT_VERSION of 2.5.0.
Is this a typo in the readme?
Right now raygui is quite tied to raylib, using a specific set of raylib functions.
Despite being possible to hook other library functions to raygui, I feel current mechanism is not easy enough... or at least, has not been properly tested. It should be reviewed.
raygui required functions include:
The idea is to expose and minimize external required hooks to cover the basic raygui needs.
Can you do a basic project setup, and how to compile de library and use with the raylib?
The right way to put ricon is
"#120#
if you put #120
it works if it is the last draw.
Ricon doesnt take the last delimiter correctly.
you can put #120
or #120a
to show the icon.
or put #120#123
or #120a123
to show the icon + 123 after.
So the default fonts for the tools (rTextPacker, rGuiIcons, rFX, etc.) are too small to see on windows 10 and on linux.
Hello,
I've started using raygui and noticed some immediate compile warnings.
In my projects I compile with cmake and set:
set( CMAKE_CXX_FLAGS " -g -Wall -Wextra -fPIC -std=c++17 " )
This will produce quite a few warnings which I think can be fixed pretty easily.
Should this be addressed?
Thanks :)
It seems TextSplit()
function does not work properly and causes some text flickering on GuiListView()
, that function should be reviewed in raylib...
GuiTextBoxMulti()
has some missing features that should be added:
Some of this new functionality has already been added to raylib with DrawTextRec()
, maybe current implementation of GuiTextBoxMulti()
could be replaced by the new implementation.
In the past weeks raylib has changed a lot, just open this issue to recap all library changes and open possible discussion points on library improvements.
rIcons
, a custom set of simple pixelart icons: Now all text placed in any raygui control can be prefixed with a custom icon just defining its id number (#027#
). This improves a lot raylib visuals for tools development.TEXT_ALIGNMENT
. Text alignment also considers rIcons
.state
was the same, the only change was control color, so, drawing has been simplified by directly choosing drawing color in function of state
. More than 400 code lines have been removed.GuiScrollBar()
and implemented it in GuiScrollPanel()
and GuiListView()
. Thanks to @Demizdor for his work on this improvement.During this big changes process, some issues have been detected and some questions arise:
GuiImageButton()
, do we really need this function? It could seem to be useful but it adds additional dependencies to textures drawing... actually, I never used it. Now with the rIcons
addition maybe it could be removed.
SOL: Keep it for the moment.
GuiCheckBox()
, how text alignment support should be applied to this specific control? Now text is just drawn after the control.
SOL: Use text alignment to place text to left or right of the control.
GuiSlider()
, GuiSliderBar()
, GuiProgressBar()
, On this controls, text is not part of the control bounds, it's just appended before or after the control; how text alignment should work? Also, what about the infamous showValue
parameter? I don't like it, it neither gives margin for value formating... Those functions could require some redesign.
SOL: Functions redesignedm showValue
removed, added two text parameter to functions for custom left and right control text.
GuiTextBox()
, GuiTextBoxMulti()
, those ones need some improvements, as stated in issue #24. Probably they can use directly the new text-rectangle-drawing functionality available on raylib.
SOL: GuiTextBoxMulti()
now uses DrawTextRec()
.
GuiValueBox()
, GuiSpinner()
, maybe those functions could use directly GuiTextBox()
or some base function common to all text-drawing-in-rectangle functions.
SOL: They already use GuiTextBox()
.
GuiListViewEx()
, it depends on GuiListElement()
and it's ugly... maybe it should be redesigned... Seem quite difficult to accomodate all control possibilities.
SOL: GuiListElement()
has been removed, GuiListViewEx()
and GuiComboBox()
have been redesigned from scratch.
Those are just some points, I'll update this list as required...
Also, if someone is working/testing/playing with raygui
, feedback is very welcomed.
Some controls include styling elements in the control function, those styling parameters should be removed or an additional GuiControlS()
function provided for those cases.
Affected controls:
void GuiLine(Rectangle bounds, int thick);
void GuiLabelEx(Rectangle bounds, const char *text, int alignment, int padding);
int GuiToggleGroupEx(Rectangle bounds, const char *text, int active, int padding, int columns);
bool GuiSpinner(Rectangle bounds, int *value, int minValue, int maxValue, int btnWidth, bool editMode);
void GuiStatusBar(Rectangle bounds, const char *text, int offsetX);
Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs);
Need to think carefully about this.
GuiTextBoxMulti() adds line breaks to input text when it is wider than text box. That's not the right behavior, it shouldn't modify the input text string, just break the lines on drawing.
Problem with Guifont to load my personal font:
Example :
Use GuiFont before all GuiSetStyle :
GuiFont(fonte);
GuiSetStyle(DEFAULT,LINE_COLOR,RGBA(GRAY900)); // DEFAULT_BORDER_COLOR_NORMAL
GuiSetStyle(DEFAULT,BASE_COLOR_NORMAL,RGBA(GRAY800)); // DEFAULT_BASE_COLOR_NORMAL
GuiSetStyle(DEFAULT,TEXT_COLOR_NORMAL,RGBA(GRAY100)); // DEFAULT_TEXT_COLOR_NORMAL
GuiSetStyle(DEFAULT,BORDER_COLOR_FOCUSED,0x5f9aa8ff); // DEFAULT_BORDER_COLOR_FOCUSED
GuiSetStyle(DEFAULT,BASE_COLOR_FOCUSED,0x334e57ff); // DEFAULT_BASE_COLOR_FOCUSED
GuiSetStyle(DEFAULT,TEXT_COLOR_FOCUSED,0x6aa9b8ff); // DEFAULT_TEXT_COLOR_FOCUSED
Use GuiFont after all GuiSetStyle :
GuiSetStyle(DEFAULT,LINE_COLOR,RGBA(GRAY900)); // DEFAULT_BORDER_COLOR_NORMAL
GuiSetStyle(DEFAULT,BASE_COLOR_NORMAL,RGBA(GRAY800)); // DEFAULT_BASE_COLOR_NORMAL
GuiSetStyle(DEFAULT,TEXT_COLOR_NORMAL,RGBA(GRAY100)); // DEFAULT_TEXT_COLOR_NORMAL
GuiSetStyle(DEFAULT,BORDER_COLOR_FOCUSED,0x5f9aa8ff); // DEFAULT_BORDER_COLOR_FOCUSED
GuiSetStyle(DEFAULT,BASE_COLOR_FOCUSED,0x334e57ff); // DEFAULT_BASE_COLOR_FOCUSED
GuiSetStyle(DEFAULT,TEXT_COLOR_FOCUSED,0x6aa9b8ff); // DEFAULT_TEXT_COLOR_FOCUSED
GuiFont(fonte);
I think that something reset the font by his font default.
I do not see this anywhere in the docs. Does raygui build/work on android?
While trying to compile examples for ubuntu 16.04 on raygui efe2a42 and raylib f4ca5b3 (today) with raylib statically compiled I get the following:
demo@demo:~/raygui/examples/custom_file_dialog$ gcc custom_file_dialog.c -lraylib -lopengl32 -lgdi32 -std=c99 -I../../src -I.
In file included from custom_file_dialog.c:27:0:
gui_file_dialog.h: In function ‘GuiFileDialog’:
gui_file_dialog.h:246:56: error: ‘ELEMENTS_HEIGHT’ undeclared (first use in this function); did you mean ‘MAP_HEIGHT’?
int prevElementsHeight = GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT);
^~~~~~~~~~~~~~~
MAP_HEIGHT
gui_file_dialog.h:246:56: note: each undeclared identifier is reported only once for each function it appears in
gui_file_dialog.h:251:121: warning: passing argument 2 of ‘GuiListViewEx’ from incompatible pointer type [-Wincompatible-pointer-types]
state->filesListActive = GuiListViewEx((Rectangle){ state->position.x + 10, state->position.y + 70, 460, 164 }, dirFilesIcon, state->dirFilesCount, NULL, &state->filesListScrollIndex, state->filesListActive);
^~~~~~~~~~~~
In file included from custom_file_dialog.c:22:0:
../../src/raygui.h:2366:5: note: expected ‘const char **’ but argument is of type ‘char **’
int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active)
^~~~~~~~~~~~~
custom_file_dialog.c: In function ‘main’:
custom_file_dialog.c:90:71: error: ‘RICON_FILE_OPEN’ undeclared (first use in this function); did you mean ‘_IO_FILE_plus’?
if (GuiButton((Rectangle){ 20, 20, 140, 30 }, GuiIconText(RICON_FILE_OPEN, "Open Image"))) fileDialogState.fileDialogActive = true;
^~~~~~~~~~~~~~~
_IO_FILE_plus
I don't think raygui has one ?
Facebook as a full CSS flexbox one we could use.
Am thinking if trying to integrate but want to check others thoughts in the usefulness
some appliction have menu ,so should add menu function in this lib!
Hi!
I'm having some trouble with raygui in a cpp project. I'm using the Microsoft Visual Studio Compiler and it complains about a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax
In all lines containing object initializations like:
return GuiImageButtonEx(bounds, texture, (Rectangle){ 0, 0, texture.width, texture.height }, NULL);
Am I doing this right?
I tried to run the example code you provide and it runs, as they are ".c" files. But my project is in C++.
Thank you very much :)
There appears to be no build system here unlike raylib
which I've already compiled into a SHARED library on my Raspberry Pi 3B.
How does one build this library or even just one of the provided examples?
I've tried a very basic gcc -I/home/pi/raylib/src controls_review.c
(so it can find raylib.h
) and just get a ton of errors. What else do I need to -D
efine?
It would be very useful to have a panel with scrolling that sizes with its contents and offers scroll bars. This is the proposed implementation:
// Scroll Panel control
Vector2 GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 viewScroll);
Rectangle bounds
define the visible area
Rectangle content
defines size of internal data and will condition scrolling
Vector2 viewScroll
defines the content offset, new offset should be returned in case of scrolling
Note that content.x
and content.y
could be useless... or just use them as scroll offset.
Check GuiListView()
for a temptative implementation of GuiScrollPanel()
.
As the title says, I could not find the Texture2D
structure.
BTW, I think it should be better if you could provide the Makefile
. That would be very convenient.
Hi,
On line 2710 when you insert a character into the GuiTextBox string you should also add a null terminator:
text[keyCount] = (char)key;
keyCount++;
text[keyCount] = '\0'; (this line is currently missing in the code)
Otherwise it works fine only if the unused parts of the string buffer are zero.
Thanks for writing this great library.
thanks,
Simon
in rguilayout.c
line 1767 in ShowSaveLayoutDialog, outFileName is length 64, this causes a crash when saving to path longer than that. Suggest using MAX_PATH or something like that. Also similar issue in ShowExportLayoutDialog
Seria bueno agregar un sistema de layout para ahorrar trabajo de calculo.
Estoy trabajando en un proyecto y creo que es incomodo hacer esto manual y creo que con un layout system se podría mejorar mucho.
Esto lo escribí para ahorrar un poco...
void gui_main_toolbar()
{
int screenWidth = GetScreenWidth();
Rectangle toolbar_bounds = {0,0, screenWidth, 50};
GuiPanel(toolbar_bounds);
gui_layout_row_begin(&toolbar_bounds);
{
gui_layout_row_static(80, 30);
gui_layout_row_offset(5, 10);
if(gui_button("New")){}
if(gui_button("Save")){}
gui_space_horizontal();
if(gui_button("Tile")){}
if(gui_button("Actor")){}
if(gui_button("Animate2d")){}
if(gui_button("Camera")){}
}
gui_layout_row_end();
}
Hello!
So basically, if you use a RenderTexture2D to scale the screen, the controls for raygui remain where they originally were (i.e. rendering the screen x4 larger doesn't make a button's clickable surface 4 times larger).
This is to be expected, but it still might be a good idea to add a function to raygui to scale the positions for the mouse cursor according to scalable values to allow you to resize the screen / GUI elements while still maintaining ability to interact with the raygui elements.
After creating a new control, pressing Ctrl + Z won't destroy it, but will place it where the last deleted control was.
How to reproduce:
-Open rGuiLayout
-Create a new control (probably any type will do) at any point
-Delete the control (get close with the mouse - it turns red - then press delete)
-Create a new control (probably any type will do) at any different point from the previous one
-Press Ctrl+Z
-Notice the secondly created control has now moved the position where the first control was
I have raylib working great. Its awesome!
Want to start using raygui also.
seems the raygui-master folder should be dropped in the raylib folder.. (correct me if im wrong)
when trying to compile an example i get this error.
Thank you
In file included from gui_text_box.c:29:
../../src/raygui.h:1564: error: field not found: recs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.