annotate postdog/slider_example.c @ 118:249881ceff7b

[PostDog] Updated some core logic. Will create a bookmark for postdog until the launch as this is annoying to deal with.
author June Park <parkjune1995@gmail.com>
date Wed, 07 Jan 2026 13:24:38 -0800
parents 7bd795bac997
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
116
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2 /*******************************************************************************************
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4 * raygui - custom file dialog to load image
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
6 * DEPENDENCIES:
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
7 * raylib 4.0 - Windowing/input management and drawing.
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
8 * raygui 3.0 - Immediate-mode GUI controls.
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
9 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
10 * COMPILATION (Windows - MinGW):
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
11 * gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
12 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
13 * LICENSE: zlib/libpng
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
14 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
15 * Copyright (c) 2016-2024 Ramon Santamaria (@raysan5)
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
16 *
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
17 **********************************************************************************************/
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
18
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
19 #include "third_party/raylib/include/raylib.h"
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
20
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
21 #define RAYGUI_IMPLEMENTATION
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
22 #include "third_party/raylib/include/raygui.h"
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
23
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
24 #undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
25
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
26 #define GUI_WINDOW_FILE_DIALOG_IMPLEMENTATION
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
27 #include "postdog/gui_window_file_dialog.h"
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
28 #define POSTDOG_PATHS "/Users/mrjunejune/zenbu/postdog/history"
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
29
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
30
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
31 //------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
32 // Program main entry point
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
33 //------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
34 int main()
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
35 {
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
36 // Initialization
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
37 //---------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
38 int screenWidth = 800;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
39 int screenHeight = 560;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
40
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
41 InitWindow(screenWidth, screenHeight, "raygui - custom modal dialog");
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
42 SetExitKey(0);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
43
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
44 // Custom file dialog
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
45 GuiWindowFileDialogState fileDialogState = InitGuiWindowFileDialog(POSTDOG_PATHS);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
46
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
47 bool exitWindow = false;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
48
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
49 char fileNameToLoad[512] = { 0 };
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
50
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
51 Texture texture = { 0 };
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
52
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
53 SetTargetFPS(60);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
54 //--------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
55
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
56 // Main game loop
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
57 while (!exitWindow) // Detect window close button or ESC key
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
58 {
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
59 // Update
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
60 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
61 exitWindow = WindowShouldClose();
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
62
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
63 if (fileDialogState.SelectFilePressed)
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
64 {
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
65 // Load image file (if supported extension)
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
66 if (IsFileExtension(fileDialogState.fileNameText, ".png"))
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
67 {
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
68 strcpy(fileNameToLoad, TextFormat("%s" PATH_SEPERATOR "%s", fileDialogState.dirPathText, fileDialogState.fileNameText));
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
69 UnloadTexture(texture);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
70 texture = LoadTexture(fileNameToLoad);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
71 }
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
72
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
73 fileDialogState.SelectFilePressed = false;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
74 }
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
75 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
76
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
77 // Draw
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
78 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
79 BeginDrawing();
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
80
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
81 ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
82
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
83 DrawTexture(texture, GetScreenWidth()/2 - texture.width/2, GetScreenHeight()/2 - texture.height/2 - 5, WHITE);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
84 DrawRectangleLines(GetScreenWidth()/2 - texture.width/2, GetScreenHeight()/2 - texture.height/2 - 5, texture.width, texture.height, BLACK);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
85
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
86 DrawText(fileNameToLoad, 208, GetScreenHeight() - 20, 10, GRAY);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
87
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
88 // raygui: controls drawing
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
89 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
90 if (fileDialogState.windowActive) GuiLock();
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
91
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
92 if (GuiButton((Rectangle){ 20, 20, 140, 30 }, GuiIconText(ICON_FILE_OPEN, "Open Image"))) fileDialogState.windowActive = true;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
93
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
94 GuiUnlock();
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
95
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
96 // GUI: Dialog Window
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
97 //--------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
98 GuiWindowFileDialog(&fileDialogState);
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
99 //--------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
100
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
101 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
102
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
103 EndDrawing();
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
104 //----------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
105 }
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
106
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
107 // De-Initialization
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
108 //--------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
109 UnloadTexture(texture); // Unload texture
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
110
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
111 CloseWindow(); // Close window and OpenGL context
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
112 //--------------------------------------------------------------------------------------
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
113
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
114 return 0;
7bd795bac997 [Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
115 }