Skip to content

Commit 0a4cf9f

Browse files
committed
Added getters and setters for all settings values and renamed some members.
Some members and functions were named in different ways, now the naming scheme is a bit more unified. Also changed some types to size_t where negative values don't make sense.
1 parent ad313ad commit 0a4cf9f

File tree

15 files changed

+601
-200
lines changed

15 files changed

+601
-200
lines changed

src/libprojectM/ProjectMCWrapper.cpp

Lines changed: 157 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ projectm_handle projectm_create_settings(const projectm_settings* settings, int
135135
cppSettings.titleFontURL = settings->title_font_url ? settings->title_font_url : "";
136136
cppSettings.menuFontURL = settings->menu_font_url ? settings->menu_font_url : "";
137137
cppSettings.datadir = settings->data_dir ? settings->data_dir : "";
138-
cppSettings.smoothPresetDuration = settings->smooth_preset_duration;
138+
cppSettings.softCutDuration = settings->soft_cut_duration;
139139
cppSettings.presetDuration = settings->preset_duration;
140-
cppSettings.hardcutEnabled = settings->hardcut_enabled;
141-
cppSettings.hardcutDuration = settings->hardcut_duration;
142-
cppSettings.hardcutSensitivity = settings->hardcut_sensitivity;
140+
cppSettings.hardCutEnabled = settings->hard_cut_enabled;
141+
cppSettings.hardCutDuration = settings->hard_cut_duration;
142+
cppSettings.hardCutSensitivity = settings->hard_cut_sensitivity;
143143
cppSettings.beatSensitivity = settings->beat_sensitivity;
144144
cppSettings.aspectCorrection = settings->aspect_correction;
145145
cppSettings.easterEgg = settings->easter_egg;
@@ -205,10 +205,16 @@ void projectm_reset_textures(projectm_handle instance)
205205
projectMInstance->projectM_resetTextures();
206206
}
207207

208+
const char* projectm_get_title(projectm_handle instance)
209+
{
210+
auto projectMInstance = handle_to_instance(instance);
211+
return projectm_alloc_string_from_std_string(projectMInstance->getTitle());
212+
}
213+
208214
void projectm_set_title(projectm_handle instance, const char* title)
209215
{
210216
auto projectMInstance = handle_to_instance(instance);
211-
projectMInstance->projectM_setTitle(title);
217+
projectMInstance->setTitle(title);
212218
}
213219

214220
void projectm_render_frame(projectm_handle instance)
@@ -236,28 +242,136 @@ void projectm_default_key_handler(projectm_handle instance, projectMEvent event,
236242
projectMInstance->default_key_handler(event, keycode);
237243
}
238244

239-
void projectm_set_texture_size(projectm_handle instance, int size)
245+
size_t projectm_get_texture_size(projectm_handle instance)
246+
{
247+
auto projectMInstance = handle_to_instance(instance);
248+
return projectMInstance->getTextureSize();
249+
}
250+
251+
void projectm_set_texture_size(projectm_handle instance, size_t size)
252+
{
253+
auto projectMInstance = handle_to_instance(instance);
254+
projectMInstance->setTextureSize(size);
255+
}
256+
257+
double projectm_get_hard_cut_duration(projectm_handle instance)
258+
{
259+
auto projectMInstance = handle_to_instance(instance);
260+
return projectMInstance->getHardCutDuration();
261+
}
262+
263+
void projectm_set_hard_cut_duration(projectm_handle instance, double seconds)
264+
{
265+
auto projectMInstance = handle_to_instance(instance);
266+
projectMInstance->setHardCutDuration(seconds);
267+
}
268+
269+
bool projectm_get_hard_cut_enabled(projectm_handle instance)
270+
{
271+
auto projectMInstance = handle_to_instance(instance);
272+
return projectMInstance->getHardCutEnabled();
273+
}
274+
275+
void projectm_set_hard_cut_enabled(projectm_handle instance, bool enabled)
276+
{
277+
auto projectMInstance = handle_to_instance(instance);
278+
projectMInstance->setHardCutEnabled(enabled);
279+
}
280+
281+
float projectm_get_hard_cut_sensitivity(projectm_handle instance)
282+
{
283+
auto projectMInstance = handle_to_instance(instance);
284+
return projectMInstance->getHardCutSensitivity();
285+
}
286+
287+
void projectm_set_hard_cut_sensitivity(projectm_handle instance, float sensitivity)
288+
{
289+
auto projectMInstance = handle_to_instance(instance);
290+
projectMInstance->setHardCutSensitivity(sensitivity);
291+
}
292+
293+
double projectm_get_soft_cut_duration(projectm_handle instance)
240294
{
241295
auto projectMInstance = handle_to_instance(instance);
242-
projectMInstance->changeTextureSize(size);
296+
return projectMInstance->getSoftCutDuration();
243297
}
244298

245-
void projectm_set_hardcut_duration(projectm_handle instance, double seconds)
299+
void projectm_set_soft_cut_duration(projectm_handle instance, double seconds)
246300
{
247301
auto projectMInstance = handle_to_instance(instance);
248-
projectMInstance->changeHardcutDuration(seconds);
302+
projectMInstance->setSoftCutDuration(seconds);
249303
}
250304

251305
void projectm_set_preset_duration(projectm_handle instance, double seconds)
252306
{
253307
auto projectMInstance = handle_to_instance(instance);
254-
projectMInstance->changePresetDuration(seconds);
308+
projectMInstance->setPresetDuration(seconds);
309+
}
310+
311+
void projectm_get_mesh_size(projectm_handle instance, size_t* width, size_t* height)
312+
{
313+
auto projectMInstance = handle_to_instance(instance);
314+
projectMInstance->getMeshSize(*width, *height);
315+
}
316+
317+
void projectm_set_mesh_size(projectm_handle instance, size_t width, size_t height)
318+
{
319+
auto projectMInstance = handle_to_instance(instance);
320+
projectMInstance->setMeshSize(width, height);
255321
}
256322

257-
void projectm_get_mesh_size(projectm_handle instance, int* width, int* height)
323+
size_t projectm_get_fps(projectm_handle instance)
258324
{
259325
auto projectMInstance = handle_to_instance(instance);
260-
projectMInstance->getMeshSize(width, height);
326+
return projectMInstance->settings().fps;
327+
}
328+
329+
const char* projectm_get_preset_path(projectm_handle instance)
330+
{
331+
auto projectMInstance = handle_to_instance(instance);
332+
return projectm_alloc_string_from_std_string(projectMInstance->settings().presetURL);
333+
}
334+
335+
const char* projectm_get_title_font_filename(projectm_handle instance)
336+
{
337+
auto projectMInstance = handle_to_instance(instance);
338+
return projectm_alloc_string_from_std_string(projectMInstance->settings().titleFontURL);
339+
}
340+
341+
const char* projectm_get_menu_font_filename(projectm_handle instance)
342+
{
343+
auto projectMInstance = handle_to_instance(instance);
344+
return projectm_alloc_string_from_std_string(projectMInstance->settings().menuFontURL);
345+
}
346+
347+
const char* projectm_get_data_dir_path(projectm_handle instance)
348+
{
349+
auto projectMInstance = handle_to_instance(instance);
350+
return projectm_alloc_string_from_std_string(projectMInstance->settings().datadir);
351+
}
352+
353+
void projectm_set_aspect_correction(projectm_handle instance, bool enabled)
354+
{
355+
auto projectMInstance = handle_to_instance(instance);
356+
projectMInstance->setAspectCorrection(enabled);
357+
}
358+
359+
bool projectm_get_aspect_correction(projectm_handle instance)
360+
{
361+
auto projectMInstance = handle_to_instance(instance);
362+
return projectMInstance->getAspectCorrection();
363+
}
364+
365+
void projectm_set_easter_egg(projectm_handle instance, float value)
366+
{
367+
auto projectMInstance = handle_to_instance(instance);
368+
projectMInstance->setEasterEgg(value);
369+
}
370+
371+
float projectm_get_easter_egg(projectm_handle instance)
372+
{
373+
auto projectMInstance = handle_to_instance(instance);
374+
return projectMInstance->getEasterEgg();
261375
}
262376

263377
void projectm_touch(projectm_handle instance, float x, float y, int pressure, projectm_touch_type touch_type)
@@ -322,11 +436,11 @@ projectm_settings* projectm_get_settings(projectm_handle instance)
322436
settingsStruct->title_font_url = projectm_alloc_string_from_std_string(settings.titleFontURL);
323437
settingsStruct->menu_font_url = projectm_alloc_string_from_std_string(settings.menuFontURL);
324438
settingsStruct->data_dir = projectm_alloc_string_from_std_string(settings.datadir);
325-
settingsStruct->smooth_preset_duration = settings.smoothPresetDuration;
439+
settingsStruct->soft_cut_duration = settings.softCutDuration;
326440
settingsStruct->preset_duration = settings.presetDuration;
327-
settingsStruct->hardcut_enabled = settings.hardcutEnabled;
328-
settingsStruct->hardcut_duration = settings.hardcutDuration;
329-
settingsStruct->hardcut_sensitivity = settings.hardcutSensitivity;
441+
settingsStruct->hard_cut_enabled = settings.hardCutEnabled;
442+
settingsStruct->hard_cut_duration = settings.hardCutDuration;
443+
settingsStruct->hard_cut_sensitivity = settings.hardCutSensitivity;
330444
settingsStruct->beat_sensitivity = settings.beatSensitivity;
331445
settingsStruct->aspect_correction = settings.aspectCorrection;
332446
settingsStruct->easter_egg = settings.easterEgg;
@@ -349,11 +463,11 @@ void projectm_write_config(const char* config_file, const projectm_settings* set
349463
cppSettings.titleFontURL = settings->title_font_url ? settings->title_font_url : "";
350464
cppSettings.menuFontURL = settings->menu_font_url ? settings->menu_font_url : "";
351465
cppSettings.datadir = settings->data_dir ? settings->data_dir : "";
352-
cppSettings.smoothPresetDuration = settings->smooth_preset_duration;
466+
cppSettings.softCutDuration = settings->soft_cut_duration;
353467
cppSettings.presetDuration = settings->preset_duration;
354-
cppSettings.hardcutEnabled = settings->hardcut_enabled;
355-
cppSettings.hardcutDuration = settings->hardcut_duration;
356-
cppSettings.hardcutSensitivity = settings->hardcut_sensitivity;
468+
cppSettings.hardCutEnabled = settings->hard_cut_enabled;
469+
cppSettings.hardCutDuration = settings->hard_cut_duration;
470+
cppSettings.hardCutSensitivity = settings->hard_cut_sensitivity;
357471
cppSettings.beatSensitivity = settings->beat_sensitivity;
358472
cppSettings.aspectCorrection = settings->aspect_correction;
359473
cppSettings.easterEgg = settings->easter_egg;
@@ -433,6 +547,12 @@ void projectm_select_preset_by_name(projectm_handle instance, const char* preset
433547
return projectMInstance->selectPresetByName(preset_name, hard_cut);
434548
}
435549

550+
const char* projectm_get_search_text(projectm_handle instance)
551+
{
552+
auto projectMInstance = handle_to_instance(instance);
553+
return projectm_alloc_string_from_std_string(projectMInstance->getSearchText());
554+
}
555+
436556
void projectm_set_search_text(projectm_handle instance, const char* search_text)
437557
{
438558
if (!search_text)
@@ -456,7 +576,7 @@ void projectm_reset_search_text(projectm_handle instance)
456576
return projectMInstance->resetSearchText();
457577
}
458578

459-
bool projectm_selected_preset_index(projectm_handle instance, unsigned int* index)
579+
bool projectm_get_selected_preset_index(projectm_handle instance, unsigned int* index)
460580
{
461581
if (!index)
462582
{
@@ -515,7 +635,7 @@ bool projectm_preset_position_valid(projectm_handle instance)
515635
return projectMInstance->presetPositionValid();
516636
}
517637

518-
const char* projectm_get_preset_url(projectm_handle instance, unsigned int index)
638+
const char* projectm_get_preset_filename(projectm_handle instance, unsigned int index)
519639
{
520640
auto projectMInstance = handle_to_instance(instance);
521641
return projectm_alloc_string_from_std_string(projectMInstance->getPresetURL(index));
@@ -527,7 +647,7 @@ const char* projectm_get_preset_name(projectm_handle instance, unsigned int inde
527647
return projectm_alloc_string_from_std_string(projectMInstance->getPresetName(index));
528648
}
529649

530-
void projectm_change_preset_name(projectm_handle instance, unsigned int index, const char* name)
650+
void projectm_set_preset_name(projectm_handle instance, unsigned int index, const char* name)
531651
{
532652
auto projectMInstance = handle_to_instance(instance);
533653
projectMInstance->changePresetName(index, name);
@@ -539,8 +659,8 @@ int projectm_get_preset_rating(projectm_handle instance, unsigned int index, pro
539659
return projectMInstance->getPresetRating(index, static_cast<PresetRatingType>(rating_type));
540660
}
541661

542-
void projectm_change_preset_rating(projectm_handle instance, unsigned int index, int rating,
543-
projectm_preset_rating_type rating_type)
662+
void projectm_set_preset_rating(projectm_handle instance, unsigned int index, int rating,
663+
projectm_preset_rating_type rating_type)
544664
{
545665
auto projectMInstance = handle_to_instance(instance);
546666
projectMInstance->changePresetRating(index, rating, static_cast<PresetRatingType>(rating_type));
@@ -552,16 +672,16 @@ unsigned int projectm_get_playlist_size(projectm_handle instance)
552672
return projectMInstance->getPlaylistSize();
553673
}
554674

555-
void projectm_set_shuffle_enabled(projectm_handle instance, bool shuffle_enabled)
675+
bool projectm_get_shuffle_enabled(projectm_handle instance)
556676
{
557677
auto projectMInstance = handle_to_instance(instance);
558-
projectMInstance->setShuffleEnabled(shuffle_enabled);
678+
return projectMInstance->isShuffleEnabled();
559679
}
560680

561-
bool projectm_is_shuffle_enabled(projectm_handle instance)
681+
void projectm_set_shuffle_enabled(projectm_handle instance, bool shuffle_enabled)
562682
{
563683
auto projectMInstance = handle_to_instance(instance);
564-
return projectMInstance->isShuffleEnabled();
684+
projectMInstance->setShuffleEnabled(shuffle_enabled);
565685
}
566686

567687
unsigned int projectm_get_search_index(projectm_handle instance, const char* name)
@@ -570,34 +690,35 @@ unsigned int projectm_get_search_index(projectm_handle instance, const char* nam
570690
return projectMInstance->getSearchIndex(name);
571691
}
572692

573-
void projectm_select_previous(projectm_handle instance, bool hard_cut)
693+
void projectm_select_previous_preset(projectm_handle instance, bool hard_cut)
574694
{
575695
auto projectMInstance = handle_to_instance(instance);
576696
projectMInstance->selectPrevious(hard_cut);
577697
}
578698

579-
void projectm_select_next(projectm_handle instance, bool hard_cut)
699+
void projectm_select_next_preset(projectm_handle instance, bool hard_cut)
580700
{
581701
auto projectMInstance = handle_to_instance(instance);
582702
projectMInstance->selectNext(hard_cut);
583703
}
584704

585-
void projectm_select_random(projectm_handle instance, bool hard_cut)
705+
void projectm_select_random_preset(projectm_handle instance, bool hard_cut)
586706
{
587707
auto projectMInstance = handle_to_instance(instance);
588708
projectMInstance->selectRandom(hard_cut);
589709
}
590710

591-
int projectm_get_window_width(projectm_handle instance)
711+
void projectm_get_window_size(projectm_handle instance, size_t* width, size_t* height)
592712
{
593713
auto projectMInstance = handle_to_instance(instance);
594-
return projectMInstance->getWindowWidth();
714+
*width = projectMInstance->getWindowWidth();
715+
*height = projectMInstance->getWindowHeight();
595716
}
596717

597-
int projectm_get_window_height(projectm_handle instance)
718+
void projectm_set_window_size(projectm_handle instance, size_t width, size_t height)
598719
{
599720
auto projectMInstance = handle_to_instance(instance);
600-
return projectMInstance->getWindowHeight();
721+
projectMInstance->projectM_resetGL(width, height);
601722
}
602723

603724
bool projectm_get_error_loading_current_preset(projectm_handle instance)

src/libprojectM/Renderer/Renderer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,11 @@ void Renderer::toggleSearchText() {
814814
}
815815
}
816816

817+
std::string Renderer::getSearchText() const
818+
{
819+
return m_searchText;
820+
}
821+
817822
// search based on new key input
818823
void Renderer::setSearchText(const std::string& theValue)
819824
{

src/libprojectM/Renderer/Renderer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class Renderer
174174
bool touchedWaveform(float x, float y, std::size_t i);
175175

176176
void setToastMessage(const std::string& theValue);
177+
std::string getSearchText() const;
177178
void setSearchText(const std::string& theValue);
178179
void resetSearchText();
179180
void deleteSearchText();

src/libprojectM/TimeKeeper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double hardcutDuration, double easterEgg)
1111
{
12-
_smoothDuration = smoothDuration;
12+
_softCutDuration = smoothDuration;
1313
_presetDuration = presetDuration;
14-
_hardcutDuration = hardcutDuration;
14+
_hardCutDuration = hardcutDuration;
1515
_easterEgg = easterEgg;
1616

1717
#ifndef WIN32
@@ -60,12 +60,12 @@ TimeKeeper::TimeKeeper(double presetDuration, double smoothDuration, double hard
6060

6161
bool TimeKeeper::CanHardCut()
6262
{
63-
return ((_currentTime - _presetTimeA) > _hardcutDuration);
63+
return ((_currentTime - _presetTimeA) > _hardCutDuration);
6464
}
6565

6666
double TimeKeeper::SmoothRatio()
6767
{
68-
return (_currentTime - _presetTimeB) / _smoothDuration;
68+
return (_currentTime - _presetTimeB) / _softCutDuration;
6969
}
7070
bool TimeKeeper::IsSmoothing()
7171
{

src/libprojectM/TimeKeeper.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ class TimeKeeper
4040

4141
double sampledPresetDuration();
4242

43-
void ChangeHardcutDuration(int seconds) { _hardcutDuration = seconds; }
43+
void ChangeHardCutDuration(int seconds) { _hardCutDuration = seconds; }
44+
void ChangeHardCutDuration(double seconds) { _hardCutDuration = seconds; }
45+
void ChangeSoftCutDuration(int seconds) { _softCutDuration = seconds; }
46+
void ChangeSoftCutDuration(double seconds) { _softCutDuration = seconds; }
4447
void ChangePresetDuration(int seconds) { _presetDuration = seconds; }
45-
void ChangeHardcutDuration(double seconds) { _hardcutDuration = seconds; }
4648
void ChangePresetDuration(double seconds) { _presetDuration = seconds; }
49+
void ChangeEasterEgg(float value) { _easterEgg = value; }
4750

4851
#ifndef WIN32
4952
/* The first ticks value of the application */
@@ -58,8 +61,8 @@ class TimeKeeper
5861
double _presetDuration;
5962
double _presetDurationA;
6063
double _presetDurationB;
61-
double _smoothDuration;
62-
double _hardcutDuration;
64+
double _softCutDuration;
65+
double _hardCutDuration;
6366

6467
double _currentTime;
6568
double _presetTimeA;

0 commit comments

Comments
 (0)