@@ -22,7 +22,7 @@ void PresetSelectionGui::initialize(Poco::Util::Application& app)
22
22
IMGUI_CHECKVERSION ();
23
23
ImGui::CreateContext ();
24
24
ImGuiIO& io = ImGui::GetIO ();
25
- (void )io;
25
+ (void ) io;
26
26
27
27
ImGui::StyleColorsDark ();
28
28
@@ -91,46 +91,43 @@ void PresetSelectionGui::UpdateFontSize()
91
91
void PresetSelectionGui::ProcessInput (const SDL_Event& event)
92
92
{
93
93
ImGui_ImplSDL2_ProcessEvent (&event);
94
+ unsigned int position;
95
+ projectm_get_selected_preset_index (_projectMWrapper->ProjectM (), &position);
96
+ _playlistPosition = static_cast <int >(position);
97
+ _playlistSize = projectm_get_playlist_size (_projectMWrapper->ProjectM ());
94
98
}
95
99
96
100
void PresetSelectionGui::Draw ()
97
101
{
98
- ImGui_ImplOpenGL3_NewFrame ();
99
102
ImGui_ImplSDL2_NewFrame ();
103
+ ImGui_ImplOpenGL3_NewFrame ();
100
104
ImGui::NewFrame ();
101
105
106
+ if (_settingsVisible)
102
107
{
103
- static float f = 0 .0f ;
104
- static int counter = 0 ;
108
+ DrawSettingsWindow ();
105
109
106
- ImGui::Begin ( " Hello, world! " ); // Create a window called "Hello, world!" and append into it.
110
+ }
107
111
108
- ImGui::Text ( " This is some useful text. " ); // Display some text (you can use a format strings too)
112
+ try {
109
113
110
- ImGui::SliderFloat (" float" , &f, 0 .0f , 1 .0f ); // Edit 1 float using a slider from 0.0f to 1.0f
114
+ if (_fileChooser.Draw ())
115
+ {
116
+ // Preset selected, load & switch.
117
+ std::string presetName = Poco::Path (_fileChooser.SelectedFile ().path ()).getFileName ();
111
118
112
- if (ImGui::Button (" Button" )) // Buttons return true when clicked (most widgets return true when edited/activated)
113
- counter++;
114
- ImGui::SameLine ();
115
- ImGui::Text (" counter = %d" , counter);
119
+ int ratingList[2 ]{};
120
+ projectm_add_preset_url (_projectMWrapper->ProjectM (),
121
+ _fileChooser.SelectedFile ().path ().c_str (),
122
+ presetName.c_str (),
123
+ &ratingList[0 ], 2 );
124
+ projectm_select_preset (_projectMWrapper->ProjectM (), projectm_get_playlist_size (_projectMWrapper->ProjectM ()) - 1 , true );
125
+ }
116
126
117
- ImGui::Text (" Application average %.3f ms/frame (%.1f FPS)" , 1000 .0f / ImGui::GetIO ().Framerate , ImGui::GetIO ().Framerate );
118
-
119
- static char text[1024 * 16 ] =
120
- " /*\n "
121
- " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n "
122
- " the hexadecimal encoding of one offending instruction,\n "
123
- " more formally, the invalid operand with locked CMPXCHG8B\n "
124
- " instruction bug, is a design flaw in the majority of\n "
125
- " Intel Pentium, Pentium MMX, and Pentium OverDrive\n "
126
- " processors (all in the P5 microarchitecture).\n "
127
- " */\n\n "
128
- " label:\n "
129
- " \t lock cmpxchg8b eax\n " ;
130
-
131
- ImGui::InputTextMultiline (" ##source" , text, IM_ARRAYSIZE (text), ImVec2 (-FLT_MIN, ImGui::GetTextLineHeight () * 16 ), ImGuiInputTextFlags_None);
132
-
133
- ImGui::End ();
127
+ }
128
+ catch (Poco::Exception& ex)
129
+ {
130
+ poco_error_f1 (_logger, " Exception in file chooser: %s" , ex.message ());
134
131
}
135
132
136
133
ImGui::Render ();
@@ -148,3 +145,47 @@ bool PresetSelectionGui::WantsMouseInput()
148
145
auto & io = ImGui::GetIO ();
149
146
return io.WantCaptureMouse ;
150
147
}
148
+
149
+ void PresetSelectionGui::DrawSettingsWindow ()
150
+ {
151
+ if (ImGui::Begin (" projectM Settings" , &_settingsVisible))
152
+ {
153
+ ImGui::TextColored (ImVec4 (1 .0f , 0 .0f , 0 .0f , 1 .0f ), " Hint:" );
154
+ ImGui::SameLine ();
155
+ ImGui::Text (" Press <TAB> after clicking on a slider to enter a custom value." );
156
+
157
+ if (ImGui::SliderFloat (" Preset Display Duration" , &_displayDuration, 1 .0f , 60 .0f ))
158
+ {
159
+ projectm_set_preset_duration (_projectMWrapper->ProjectM (), _displayDuration);
160
+ }
161
+
162
+ if (ImGui::SliderInt (" Playlist Position" , &_playlistPosition, 0 , _playlistSize - 1 ))
163
+ {
164
+ projectm_select_preset (_projectMWrapper->ProjectM (), _playlistPosition, true );
165
+ }
166
+
167
+
168
+ ImGui::Text (" Application average %.3f ms/frame (%.1f FPS)" , 1000 .0f / ImGui::GetIO ().Framerate , ImGui::GetIO ().Framerate );
169
+
170
+ if (ImGui::Button (" Toggle Fullscreen" ))
171
+ {
172
+ _sdlRenderingWindow->ToggleFullscreen ();
173
+ }
174
+
175
+ ImGui::SameLine ();
176
+
177
+ if (ImGui::Button (" Random Preset" ))
178
+ {
179
+ projectm_select_random_preset (_projectMWrapper->ProjectM (), true );
180
+ }
181
+
182
+ ImGui::SameLine ();
183
+
184
+ if (ImGui::Button (" Load Preset..." ))
185
+ {
186
+ _fileChooser.Show ();
187
+ }
188
+
189
+ }
190
+ ImGui::End ();
191
+ }
0 commit comments