1. RayGUI Example

Hi all,

Well after some snags here and there, I've finally been able to wrap RayGUI for Euphoria. However I can't get this example to work correctly. You should be able to drag the gui window inside the main raylib window, but it doesn't move at all.

EuRayGUI Repo: https://github.com/gAndy50/EuRayGUI

Trying to make a euphoria version of this: https://github.com/raysan5/raygui/blob/master/examples/portable_window/portable_window.c

Oh yeah, thanks again Greg!

EDIT: 1/10/24 Alright, still can't figure out why none of the values are changing even though I basically made a euphoria version of portable_window.c

include std/ffi.e 
 
include raylib.e 
include raygui.e 
 
constant WIDTH = 800 
constant HEIGHT = 600 
 
constant TRUE = 1, FALSE = 0 
 
SetConfigFlags(FLAG_WINDOW_UNDECORATED) 
InitWindow(WIDTH,HEIGHT,"RayGUI Example") 
 
sequence mousePos = {0.0,0.0} 
sequence windowPos = {500,200} 
sequence panOffset = mousePos 
 
atom dragWindow = FALSE 
 
SetWindowPosition(windowPos[1],windowPos[2]) 
 
atom exitWindow = FALSE 
 
SetTargetFPS(60) 
 
while exitWindow = FALSE and not WindowShouldClose() do 
 
	GuiEnable() 
 
	mousePos = GetMousePosition() 
	 
	if IsMouseButtonPressed(MOUSE_BUTTON_LEFT) and dragWindow = FALSE then 
		if CheckCollisionPointRec(mousePos,{0,0,WIDTH,20}) then 
			dragWindow = TRUE 
			panOffset = mousePos 
		end if 
	end if 
	 
	if dragWindow = TRUE then 
		windowPos[1] += (mousePos[1] - panOffset[1]) 
		windowPos[2] += (mousePos[2] - panOffset[2]) 
		 
		SetWindowPosition(windowPos[1],windowPos[2]) 
		 
		if IsMouseButtonReleased(MOUSE_BUTTON_LEFT) then 
			dragWindow = FALSE 
		end if 
	end if 
 
	BeginDrawing() 
	 
	ClearBackground(RAYWHITE) 
	 
	exitWindow = GuiWindowBox({0,0,WIDTH,HEIGHT},"GUI Win") 
	 
	DrawText(TextFormat("Mouse: [%f, %f]",mousePos[1]+mousePos[2]),10,40,10,DARKGRAY) 
	DrawText(TextFormat("Win: [%f, %f]",windowPos[1]+windowPos[2]),10,60,10,DARKGRAY) 
	 
	EndDrawing() 
	 
	GuiDisable() 
	 
end while 
 
CloseWindow() 
new topic     » topic index » view message » categorize

2. Re: RayGUI Example

Icy_Viking said...

Alright, still can't figure out why none of the values are changing even though I basically made a euphoria version of portable_window.c

Hallo

little late, but better late than never. textformat() seems to be the culprit. Calling the function seems to be a little more complex due to variable arguments. But you don't need it. It calls sprintf internally. That exists in Euphoria Native.

Just use that:

DrawText(sprintf("Mouse: [%d, %d]",mousePos[1]+mousePos[2]),10,40,10,DARKGRAY) 
DrawText(sprintf("Win: [%d, %d]",windowPos[1]+windowPos[2]),10,60,10,DARKGRAY)  

instead of that:

DrawText(TextFormat("Mouse: [%f, %f]",mousePos[1]+mousePos[2]),10,40,10,DARKGRAY) 
DrawText(TextFormat("Win: [%f, %f]",windowPos[1]+windowPos[2]),10,60,10,DARKGRAY)	 

[/quote]

Hope that helps.

new topic     » goto parent     » topic index » view message » categorize

3. Re: RayGUI Example

andreasWagner said...
Icy_Viking said...

Alright, still can't figure out why none of the values are changing even though I basically made a euphoria version of portable_window.c

Hallo

little late, but better late than never. textformat() seems to be the culprit. Calling the function seems to be a little more complex due to variable arguments. But you don't need it. It calls sprintf internally. That exists in Euphoria Native.

Just use that:

DrawText(sprintf("Mouse: [%d, %d]",mousePos[1]+mousePos[2]),10,40,10,DARKGRAY) 
DrawText(sprintf("Win: [%d, %d]",windowPos[1]+windowPos[2]),10,60,10,DARKGRAY)  

instead of that:

DrawText(TextFormat("Mouse: [%f, %f]",mousePos[1]+mousePos[2]),10,40,10,DARKGRAY) 
DrawText(TextFormat("Win: [%f, %f]",windowPos[1]+windowPos[2]),10,60,10,DARKGRAY)	 

Hope that helps.

[/quote]

Hey, I just saw this. Thanks, it works! The solution was more simple then I thought it'd be.

new topic     » goto parent     » topic index » view message » categorize

4. Re: RayGUI Example

Hallo,

Sorry, I took another look at portable_window.c.

It should probably look more like this:

DrawText(sprintf("Mouse: [%d, %d]",{mousePos[1],mousePos[2]}),10,40,20,BLACK)  
DrawText(sprintf("Win: [%d, %d]",{windowPos[1],windowPos[2]}),10,60,20,BLACK)  

And for this example, you probably don't need GuiDisable() and GuiEnable().

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu