Mercurial
annotate postdog/gui_window_file_dialog.h @ 178:94705b5986b3
[ThirdParty] Added WRK and luajit for load testing.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Thu, 22 Jan 2026 20:10:30 -0800 |
| parents | 7bd795bac997 |
| children |
| 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 * Window File Dialog v1.2 - Modal file dialog to open/save files |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 * MODULE USAGE: |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 * #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
|
7 * #include "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
|
8 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 * INIT: GuiWindowFileDialogState state = GuiInitWindowFileDialog(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 * DRAW: GuiWindowFileDialog(&state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 * NOTE: This module depends on some raylib file system functions: |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 * - LoadDirectoryFiles() |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 * - UnloadDirectoryFiles() |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 * - GetWorkingDirectory() |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 * - DirectoryExists() |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 * - FileExists() |
|
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 * 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
|
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 * Copyright (c) 2019-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
|
22 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 * This software is provided "as-is", without any express or implied warranty. In no event |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
24 * will the authors be held liable for any damages arising from the use of this software. |
|
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 * Permission is granted to anyone to use this software for any purpose, including commercial |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
27 * applications, and to alter it and redistribute it freely, subject to the following restrictions: |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
28 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 * 1. The origin of this software must not be misrepresented; you must not claim that you |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 * wrote the original software. If you use this software in a product, an acknowledgment |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 * in the product documentation would be appreciated but is not required. |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
33 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
34 * as being the original software. |
|
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 * 3. This notice may not be removed or altered from any source distribution. |
|
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 **********************************************************************************************/ |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
39 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
40 #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
|
41 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 #ifndef 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
|
43 #define 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
|
44 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 // Gui file dialog context data |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 typedef struct { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
48 // Window management variables |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
49 bool windowActive; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
50 Rectangle windowBounds; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
51 Vector2 panOffset; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
52 bool dragMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 bool supportDrag; |
|
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 // UI variables |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
56 bool dirPathEditMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
57 char dirPathText[1024]; |
|
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 int filesListScrollIndex; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
60 bool filesListEditMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
61 int filesListActive; |
|
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 bool fileNameEditMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
64 char fileNameText[1024]; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
65 bool SelectFilePressed; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
66 bool CancelFilePressed; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
67 int fileTypeActive; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
68 int itemFocused; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
69 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
70 // Custom state variables |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
71 FilePathList dirFiles; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
72 char filterExt[256]; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
73 char dirPathTextCopy[1024]; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
74 char fileNameTextCopy[1024]; |
|
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 int prevFilesListActive; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
77 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
78 bool saveFileMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
79 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
80 } GuiWindowFileDialogState; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
81 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
82 #ifdef __cplusplus |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
83 extern "C" { // Prevents name mangling of functions |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
84 #endif |
|
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 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
87 // Defines and Macros |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
88 //---------------------------------------------------------------------------------- |
|
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 |
|
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 // Types and Structures Definition |
|
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 // ... |
|
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 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
97 // Global Variables Definition |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
98 //---------------------------------------------------------------------------------- |
|
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 // Module Functions Declaration |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
103 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
104 GuiWindowFileDialogState InitGuiWindowFileDialog(const char *initPath); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
105 void GuiWindowFileDialog(GuiWindowFileDialogState *state); |
|
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 #ifdef __cplusplus |
|
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 #endif |
|
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 #endif // 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
|
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 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
115 * 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
|
116 * |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
117 ************************************************************************************/ |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
118 #if defined(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
|
119 #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
|
120 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
121 #include <string.h> // Required for: strcpy() |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
122 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
123 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
124 // Defines and Macros |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
125 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
126 #define MAX_DIRECTORY_FILES 2048 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
127 #define MAX_ICON_PATH_LENGTH 512 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
128 #ifdef _WIN32 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
129 #define PATH_SEPERATOR "\\" |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
130 #else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
131 #define PATH_SEPERATOR "/" |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
132 #endif |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
133 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
134 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
135 // Types and Structures Definition |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
136 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
137 #if defined(USE_CUSTOM_LISTVIEW_FILEINFO) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
138 // Detailed file info type |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
139 typedef struct FileInfo { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
140 const char *name; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
141 int size; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
142 int modTime; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
143 int type; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
144 int icon; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
145 } FileInfo; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
146 #else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
147 // Filename only |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
148 typedef char *FileInfo; // Files are just a path string |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
149 #endif |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
150 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
151 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
152 // Global Variables Definition |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
153 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
154 FileInfo *dirFilesIcon = NULL; // Path string + icon (for fancy drawing) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
155 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
156 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
157 // Internal Module Functions Definition |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
158 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
159 // Read files in new path |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
160 static void ReloadDirectoryFiles(GuiWindowFileDialogState *state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
161 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
162 #if defined(USE_CUSTOM_LISTVIEW_FILEINFO) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
163 // List View control for files info with extended parameters |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
164 static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *focus, int *scrollIndex, int active); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
165 #endif |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
166 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
167 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
168 // Module Functions Definition |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
169 //---------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
170 GuiWindowFileDialogState InitGuiWindowFileDialog(const char *initPath) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
171 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
172 GuiWindowFileDialogState state = { 0 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
173 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
174 // Init window data |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
175 state.windowBounds = (Rectangle){ GetScreenWidth()/2 - 440/2, GetScreenHeight()/2 - 310/2, 440, 310 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
176 state.windowActive = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
177 state.supportDrag = true; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
178 state.dragMode = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
179 state.panOffset = (Vector2){ 0, 0 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
180 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
181 // Init path data |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
182 state.dirPathEditMode = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
183 state.filesListActive = -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
184 state.prevFilesListActive = state.filesListActive; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
185 state.filesListScrollIndex = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
186 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
187 state.fileNameEditMode = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
188 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
189 state.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
|
190 state.CancelFilePressed = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
191 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
192 state.fileTypeActive = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
193 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
194 strcpy(state.fileNameText, "\0"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
195 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
196 // Custom variables initialization |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
197 if (initPath && DirectoryExists(initPath)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
198 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
199 strcpy(state.dirPathText, initPath); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
200 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
201 else if (initPath && FileExists(initPath)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
202 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
203 strcpy(state.dirPathText, GetDirectoryPath(initPath)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
204 strcpy(state.fileNameText, GetFileName(initPath)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
205 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
206 else strcpy(state.dirPathText, GetWorkingDirectory()); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
207 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
208 // TODO: Why we keep a copy? |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
209 strcpy(state.dirPathTextCopy, state.dirPathText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
210 strcpy(state.fileNameTextCopy, state.fileNameText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
211 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
212 state.filterExt[0] = '\0'; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
213 //strcpy(state.filterExt, "all"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
214 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
215 state.dirFiles.count = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
216 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
217 return state; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
218 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
219 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
220 // Update and draw 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
|
221 void GuiWindowFileDialog(GuiWindowFileDialogState *state) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
222 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
223 if (state->windowActive) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
224 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
225 // Update window dragging |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
226 //---------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
227 if (state->supportDrag) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
228 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
229 Vector2 mousePosition = GetMousePosition(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
230 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
231 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
232 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
233 // Window can be dragged from the top window bar |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
234 if (CheckCollisionPointRec(mousePosition, (Rectangle){ state->windowBounds.x, state->windowBounds.y, (float)state->windowBounds.width, RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT })) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
235 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
236 state->dragMode = true; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
237 state->panOffset.x = mousePosition.x - state->windowBounds.x; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
238 state->panOffset.y = mousePosition.y - state->windowBounds.y; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
239 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
240 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
241 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
242 if (state->dragMode) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
243 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
244 state->windowBounds.x = (mousePosition.x - state->panOffset.x); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
245 state->windowBounds.y = (mousePosition.y - state->panOffset.y); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
246 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
247 // Check screen limits to avoid moving out of screen |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
248 if (state->windowBounds.x < 0) state->windowBounds.x = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
249 else if (state->windowBounds.x > (GetScreenWidth() - state->windowBounds.width)) state->windowBounds.x = GetScreenWidth() - state->windowBounds.width; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
250 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
251 if (state->windowBounds.y < 0) state->windowBounds.y = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
252 else if (state->windowBounds.y > (GetScreenHeight() - state->windowBounds.height)) state->windowBounds.y = GetScreenHeight() - state->windowBounds.height; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
253 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
254 if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) state->dragMode = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
255 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
256 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
257 //---------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
258 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
259 // Load dirFilesIcon and state->dirFiles lazily on windows open |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
260 // NOTE: They are automatically unloaded at fileDialog closing |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
261 //---------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
262 if (dirFilesIcon == NULL) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
263 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
264 dirFilesIcon = (FileInfo *)RL_CALLOC(MAX_DIRECTORY_FILES, sizeof(FileInfo)); // Max files to read |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
265 for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesIcon[i] = (char *)RL_CALLOC(MAX_ICON_PATH_LENGTH, 1); // Max file name length |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
266 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
267 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
268 // Load current directory files |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
269 if (state->dirFiles.paths == NULL) ReloadDirectoryFiles(state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
270 //---------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
271 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
272 // Draw window and controls |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
273 //---------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
274 state->windowActive = !GuiWindowBox(state->windowBounds, "#198# Select 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
|
275 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
276 // Draw previous directory button + logic |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
277 if (GuiButton((Rectangle){ state->windowBounds.x + state->windowBounds.width - 48, state->windowBounds.y + 24 + 12, 40, 24 }, "< ..")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
279 // Move dir path one level up |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
280 strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
281 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
282 // Reload directory files (frees previous list) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
283 ReloadDirectoryFiles(state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
284 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
285 state->filesListActive = -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
286 memset(state->fileNameText, 0, 1024); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
287 memset(state->fileNameTextCopy, 0, 1024); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
288 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
289 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
290 // Draw current directory text box info + path editing logic |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
291 if (GuiTextBox((Rectangle){ state->windowBounds.x + 8, state->windowBounds.y + 24 + 12, state->windowBounds.width - 48 - 16, 24 }, state->dirPathText, 1024, state->dirPathEditMode)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
292 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
293 if (state->dirPathEditMode) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
294 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
295 // Verify if a valid path has been introduced |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
296 if (DirectoryExists(state->dirPathText)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
297 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
298 // Reload directory files (frees previous list) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
299 ReloadDirectoryFiles(state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
300 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
301 strcpy(state->dirPathTextCopy, state->dirPathText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
302 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
303 else strcpy(state->dirPathText, state->dirPathTextCopy); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
304 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
305 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
306 state->dirPathEditMode = !state->dirPathEditMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
307 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
308 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
309 // List view elements are aligned left |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
310 int prevTextAlignment = GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
311 int prevElementsHeight = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
312 GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
313 GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
314 # if defined(USE_CUSTOM_LISTVIEW_FILEINFO) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
315 state->filesListActive = GuiListViewFiles((Rectangle){ state->position.x + 8, state->position.y + 48 + 20, state->windowBounds.width - 16, state->windowBounds.height - 60 - 16 - 68 }, fileInfo, state->dirFiles.count, &state->itemFocused, &state->filesListScrollIndex, state->filesListActive); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
316 # else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
317 GuiListViewEx((Rectangle){ state->windowBounds.x + 8, state->windowBounds.y + 48 + 20, state->windowBounds.width - 16, state->windowBounds.height - 60 - 16 - 68 }, |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
318 (const char**)dirFilesIcon, state->dirFiles.count, &state->filesListScrollIndex, &state->filesListActive, &state->itemFocused); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
319 # endif |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
320 GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, prevTextAlignment); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
321 GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, prevElementsHeight); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
322 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
323 // Check if a path has been selected, if it is a directory, move to that directory (and reload paths) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
324 if ((state->filesListActive >= 0) && (state->filesListActive != state->prevFilesListActive)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
325 //&& (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_ENTER) || IsKeyPressed(KEY_DPAD_A))) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
326 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
327 strcpy(state->fileNameText, GetFileName(state->dirFiles.paths[state->filesListActive])); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
328 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
329 if (DirectoryExists(TextFormat("%s/%s", state->dirPathText, state->fileNameText))) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
330 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
331 if (TextIsEqual(state->fileNameText, "..")) strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
332 else strcpy(state->dirPathText, TextFormat("%s/%s", (strcmp(state->dirPathText, "/") == 0)? "" : state->dirPathText, state->fileNameText)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
333 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
334 strcpy(state->dirPathTextCopy, state->dirPathText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
335 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
336 // Reload directory files (frees previous list) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
337 ReloadDirectoryFiles(state); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
338 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
339 strcpy(state->dirPathTextCopy, state->dirPathText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
340 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
341 state->filesListActive = -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
342 strcpy(state->fileNameText, "\0"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
343 strcpy(state->fileNameTextCopy, state->fileNameText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
344 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
345 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
346 state->prevFilesListActive = state->filesListActive; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
347 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
348 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
349 // Draw bottom controls |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
350 //-------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
351 GuiLabel((Rectangle){ state->windowBounds.x + 8, state->windowBounds.y + state->windowBounds.height - 68, 60, 24 }, "File name:"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
352 if (GuiTextBox((Rectangle){ state->windowBounds.x + 72, state->windowBounds.y + state->windowBounds.height - 68, state->windowBounds.width - 184, 24 }, state->fileNameText, 128, state->fileNameEditMode)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
353 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
354 if (*state->fileNameText) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
355 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
356 // Verify if a valid filename has been introduced |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
357 if (FileExists(TextFormat("%s/%s", state->dirPathText, state->fileNameText))) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
358 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
359 // Select filename from list view |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
360 for (unsigned int i = 0; i < state->dirFiles.count; i++) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
361 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
362 if (TextIsEqual(state->fileNameText, state->dirFiles.paths[i])) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
363 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
364 state->filesListActive = i; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
365 strcpy(state->fileNameTextCopy, state->fileNameText); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
366 break; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
367 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
368 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
369 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
370 else if (!state->saveFileMode) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
371 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
372 strcpy(state->fileNameText, state->fileNameTextCopy); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
373 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
374 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
375 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
376 state->fileNameEditMode = !state->fileNameEditMode; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
377 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
378 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
379 GuiLabel((Rectangle){ state->windowBounds.x + 8, state->windowBounds.y + state->windowBounds.height - 24 - 12, 68, 24 }, "File filter:"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
380 GuiComboBox((Rectangle){ state->windowBounds.x + 72, state->windowBounds.y + state->windowBounds.height - 24 - 12, state->windowBounds.width - 184, 24 }, "All files", &state->fileTypeActive); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
381 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
382 state->SelectFilePressed = GuiButton((Rectangle){ state->windowBounds.x + state->windowBounds.width - 96 - 8, state->windowBounds.y + state->windowBounds.height - 68, 96, 24 }, "Select"); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
383 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
384 if (GuiButton((Rectangle){ state->windowBounds.x + state->windowBounds.width - 96 - 8, state->windowBounds.y + state->windowBounds.height - 24 - 12, 96, 24 }, "Cancel")) state->windowActive = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
385 //-------------------------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
386 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
387 // Exit on file selected |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
388 if (state->SelectFilePressed) state->windowActive = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
389 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
390 // File dialog has been closed, free all memory before exit |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
391 if (!state->windowActive) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
392 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
393 // Free dirFilesIcon memory |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
394 for (int i = 0; i < MAX_DIRECTORY_FILES; i++) RL_FREE(dirFilesIcon[i]); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
395 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
396 RL_FREE(dirFilesIcon); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
397 dirFilesIcon = NULL; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
398 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
399 // Unload directory file paths |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
400 UnloadDirectoryFiles(state->dirFiles); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
401 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
402 // Reset state variables |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
403 state->dirFiles.count = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
404 state->dirFiles.capacity = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
405 state->dirFiles.paths = NULL; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
406 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
407 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
408 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
409 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
410 // Compare two files from a directory |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
411 static inline int FileCompare(const char *d1, const char *d2, const char *dir) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
412 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
413 const bool b1 = DirectoryExists(TextFormat("%s/%s", dir, d1)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
414 const bool b2 = DirectoryExists(TextFormat("%s/%s", dir, d2)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
415 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
416 if (b1 && !b2) return -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
417 if (!b1 && b2) return 1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
418 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
419 if (!FileExists(TextFormat("%s/%s", dir, d1))) return 1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
420 if (!FileExists(TextFormat("%s/%s", dir, d2))) return -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
421 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
422 return strcmp(d1, d2); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
423 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
424 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
425 // Read files in new path |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
426 static void ReloadDirectoryFiles(GuiWindowFileDialogState *state) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
427 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
428 UnloadDirectoryFiles(state->dirFiles); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
429 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
430 state->dirFiles = LoadDirectoryFilesEx(state->dirPathText, (state->filterExt[0] == '\0')? NULL : state->filterExt, false); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
431 state->itemFocused = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
432 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
433 // Reset dirFilesIcon memory |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
434 for (int i = 0; i < MAX_DIRECTORY_FILES; i++) memset(dirFilesIcon[i], 0, MAX_ICON_PATH_LENGTH); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
435 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
436 // Copy paths as icon + fileNames into dirFilesIcon |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
437 for (unsigned int i = 0; i < state->dirFiles.count; i++) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
438 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
439 if (IsPathFile(state->dirFiles.paths[i])) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
440 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
441 // Path is a file, a file icon for convenience (for some recognized extensions) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
442 if (IsFileExtension(state->dirFiles.paths[i], ".png;.bmp;.tga;.gif;.jpg;.jpeg;.psd;.hdr;.qoi;.dds;.pkm;.ktx;.pvr;.astc")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
443 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
444 strcpy(dirFilesIcon[i], TextFormat("#12#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
445 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
446 else if (IsFileExtension(state->dirFiles.paths[i], ".wav;.mp3;.ogg;.flac;.xm;.mod;.it;.wma;.aiff")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
447 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
448 strcpy(dirFilesIcon[i], TextFormat("#11#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
449 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
450 else if (IsFileExtension(state->dirFiles.paths[i], ".txt;.info;.md;.nfo;.xml;.json;.c;.cpp;.cs;.lua;.py;.glsl;.vs;.fs")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
451 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
452 strcpy(dirFilesIcon[i], TextFormat("#10#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
453 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
454 else if (IsFileExtension(state->dirFiles.paths[i], ".exe;.bin;.raw;.msi")) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
455 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
456 strcpy(dirFilesIcon[i], TextFormat("#200#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
457 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
458 else strcpy(dirFilesIcon[i], TextFormat("#218#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
459 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
460 else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
461 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
462 // Path is a directory, add a directory icon |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
463 strcpy(dirFilesIcon[i], TextFormat("#1#%s", GetFileName(state->dirFiles.paths[i]))); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
464 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
465 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
466 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
467 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
468 #if defined(USE_CUSTOM_LISTVIEW_FILEINFO) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
469 // List View control for files info with extended parameters |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
470 static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *focus, int *scrollIndex, int *active) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
471 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
472 int result = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
473 GuiState state = guiState; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
474 int itemFocused = (focus == NULL)? -1 : *focus; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
475 int itemSelected = *active; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
476 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
477 // Check if we need a scroll bar |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
478 bool useScrollBar = false; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
479 if ((GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING))*count > bounds.height) useScrollBar = true; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
480 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
481 // Define base item rectangle [0] |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
482 Rectangle itemBounds = { 0 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
483 itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
484 itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
485 itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) - GuiGetStyle(DEFAULT, BORDER_WIDTH); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
486 itemBounds.height = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
487 if (useScrollBar) itemBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
488 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
489 // Get items on the list |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
490 int visibleItems = bounds.height/(GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
491 if (visibleItems > count) visibleItems = count; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
492 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
493 int startIndex = (scrollIndex == NULL)? 0 : *scrollIndex; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
494 if ((startIndex < 0) || (startIndex > (count - visibleItems))) startIndex = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
495 int endIndex = startIndex + visibleItems; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
496 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
497 // Update control |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
498 //-------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
499 if ((state != GUI_STATE_DISABLED) && !guiLocked) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
500 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
501 Vector2 mousePoint = GetMousePosition(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
502 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
503 // Check mouse inside list view |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
504 if (CheckCollisionPointRec(mousePoint, bounds)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
505 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
506 state = GUI_STATE_FOCUSED; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
507 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
508 // Check focused and selected item |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
509 for (int i = 0; i < visibleItems; i++) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
510 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
511 if (CheckCollisionPointRec(mousePoint, itemBounds)) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
512 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
513 itemFocused = startIndex + i; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
514 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) itemSelected = startIndex + i; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
515 break; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
516 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
517 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
518 // Update item rectangle y position for next item |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
519 itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
520 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
521 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
522 if (useScrollBar) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
523 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
524 int wheelMove = GetMouseWheelMove(); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
525 startIndex -= wheelMove; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
526 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
527 if (startIndex < 0) startIndex = 0; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
528 else if (startIndex > (count - visibleItems)) startIndex = count - visibleItems; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
529 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
530 endIndex = startIndex + visibleItems; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
531 if (endIndex > count) endIndex = count; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
532 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
533 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
534 else itemFocused = -1; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
535 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
536 // Reset item rectangle y to [0] |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
537 itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
538 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
539 //-------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
540 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
541 // Draw control |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
542 //-------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
543 DrawRectangleRec(bounds, GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); // Draw background |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
544 DrawRectangleLinesEx(bounds, GuiGetStyle(DEFAULT, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
545 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
546 // TODO: Draw list view header with file sections: icon+name | size | type | modTime |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
547 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
548 // Draw visible items |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
549 for (int i = 0; i < visibleItems; i++) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
550 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
551 if (state == GUI_STATE_DISABLED) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
552 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
553 if ((startIndex + i) == itemSelected) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
554 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
555 DrawRectangleRec(itemBounds, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_DISABLED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
556 DrawRectangleLinesEx(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_DISABLED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
557 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
558 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
559 // TODO: Draw full file info line: icon+name | size | type | modTime |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
560 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
561 GuiDrawText(files[startIndex + i].name, GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_DISABLED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
562 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
563 else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
564 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
565 if ((startIndex + i) == itemSelected) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
566 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
567 // Draw item selected |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
568 DrawRectangleRec(itemBounds, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_PRESSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
569 DrawRectangleLinesEx(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_PRESSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
570 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
571 GuiDrawText(files[startIndex + i].name, GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_PRESSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
572 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
573 else if ((startIndex + i) == itemFocused) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
574 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
575 // Draw item focused |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
576 DrawRectangleRec(itemBounds, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_FOCUSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
577 DrawRectangleLinesEx(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_FOCUSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
578 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
579 GuiDrawText(files[startIndex + i].name, GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_FOCUSED)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
580 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
581 else |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
582 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
583 // Draw item normal |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
584 GuiDrawText(files[startIndex + i].name, GetTextBounds(DEFAULT, itemBounds), GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_NORMAL)), guiAlpha)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
585 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
586 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
587 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
588 // Update item rectangle y position for next item |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
589 itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
590 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
591 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
592 if (useScrollBar) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
593 { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
594 Rectangle scrollBarBounds = { |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
595 bounds.x + bounds.width - GuiGetStyle(LISTVIEW, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH), |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
596 bounds.y + GuiGetStyle(LISTVIEW, BORDER_WIDTH), (float)GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH), |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
597 bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
598 }; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
599 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
600 // Calculate percentage of visible items and apply same percentage to scrollbar |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
601 float percentVisible = (float)(endIndex - startIndex)/count; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
602 float sliderSize = bounds.height*percentVisible; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
603 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
604 int prevSliderSize = GuiGetStyle(SCROLLBAR, SLIDER_WIDTH); // Save default slider size |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
605 int prevScrollSpeed = GuiGetStyle(SCROLLBAR, SCROLL_SPEED); // Save default scroll speed |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
606 GuiSetStyle(SCROLLBAR, SLIDER_WIDTH, sliderSize); // Change slider size |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
607 GuiSetStyle(SCROLLBAR, SCROLL_SPEED, count - visibleItems); // Change scroll speed |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
608 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
609 startIndex = GuiScrollBar(scrollBarBounds, startIndex, 0, count - visibleItems); |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
610 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
611 GuiSetStyle(SCROLLBAR, SCROLL_SPEED, prevScrollSpeed); // Reset scroll speed to default |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
612 GuiSetStyle(SCROLLBAR, SLIDER_WIDTH, prevSliderSize); // Reset slider size to default |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
613 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
614 //-------------------------------------------------------------------- |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
615 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
616 if (focus != NULL) *focus = itemFocused; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
617 if (scrollIndex != NULL) *scrollIndex = startIndex; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
618 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
619 *active = itemSelected; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
620 return result; |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
621 } |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
622 #endif // USE_CUSTOM_LISTVIEW_FILEINFO |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
623 |
|
7bd795bac997
[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
624 #endif // GUI_FILE_DIALOG_IMPLEMENTATION |