@@ -319,6 +319,41 @@ void Option::set_save(const ArgTypes &... args)
319
319
WCM::get_instance ()->save_config (plugin);
320
320
}
321
321
322
+ static void update_int_sb_option_value (GtkSpinButton *spin_button, Option *option)
323
+ {
324
+ option->set_save (std::to_string (gtk_spin_button_get_value_as_int (spin_button)));
325
+ }
326
+
327
+ static void update_animate_sb_option_value (GtkSpinButton *spin_button, animate_option *option)
328
+ {
329
+ option->option ->set_save (std::to_string (gtk_spin_button_get_value_as_int (
330
+ spin_button)) + " ms " + gtk_combo_box_text_get_active_text (option->combo_box ->gobj ()));
331
+ }
332
+
333
+ static void update_animate_cb_option_value (GtkComboBoxText *combo_box, animate_option *option)
334
+ {
335
+ option->option ->set_save (std::to_string (gtk_spin_button_get_value_as_int (
336
+ option->spin_button ->gobj ())) + " ms " + gtk_combo_box_text_get_active_text (combo_box));
337
+ }
338
+
339
+ OptionWidget::~OptionWidget ()
340
+ {
341
+ if (int_spin_button)
342
+ {
343
+ g_signal_handler_disconnect (int_spin_button->gobj (), int_sb_handle);
344
+ }
345
+
346
+ if (animate_spin_button)
347
+ {
348
+ g_signal_handler_disconnect (animate_spin_button->gobj (), animate_sb_handle);
349
+ }
350
+
351
+ if (animate_combo_box)
352
+ {
353
+ g_signal_handler_disconnect (animate_combo_box->gobj (), animate_cb_handle);
354
+ }
355
+ }
356
+
322
357
OptionWidget::OptionWidget (Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,
323
358
10 )
324
359
{
@@ -344,20 +379,18 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
344
379
std::get<int >(option->default_value ));
345
380
if (option->int_labels .empty ())
346
381
{
347
- auto spin_button = std::make_unique<Gtk::SpinButton>(
382
+ int_spin_button = std::make_unique<Gtk::SpinButton>(
348
383
Gtk::Adjustment::create (value, option->data .min , option->data .max ,
349
384
1 ));
350
- spin_button->signal_changed ().connect (sigc::track_obj (
351
- [=, widget = spin_button.get ()]
352
- {
353
- option->set_save (widget->get_value_as_int ());
354
- }, tracker));
385
+ int_sb_handle =
386
+ g_signal_connect (int_spin_button->gobj (), " value-changed" , G_CALLBACK (
387
+ update_int_sb_option_value), option);
355
388
reset_button.signal_clicked ().connect (
356
- [=, widget = spin_button .get ()]
389
+ [=, widget = int_spin_button .get ()]
357
390
{
358
391
widget->set_value (std::get<int >(option->default_value ));
359
392
});
360
- pack_end (std::move (spin_button ));
393
+ pack_end (std::move (int_spin_button ));
361
394
} else
362
395
{
363
396
auto combo_box = std::make_unique<Gtk::ComboBoxText>();
@@ -397,9 +430,9 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
397
430
int length_value = set_value ? set_value->length_ms : default_value->length_ms ;
398
431
std::string easing_value = set_value ? set_value->easing_name : default_value->easing_name ;
399
432
400
- auto spin_button = std::make_unique<Gtk::SpinButton>(
433
+ animate_spin_button = std::make_unique<Gtk::SpinButton>(
401
434
Gtk::Adjustment::create (length_value, option->data .min , option->data .max , 1 ));
402
- auto combo_box = std::make_unique<Gtk::ComboBoxText>();
435
+ animate_combo_box = std::make_unique<Gtk::ComboBoxText>();
403
436
for (const auto & easing : wf::animation::smoothing::get_available_smooth_functions ())
404
437
{
405
438
static const std::map<std::string, int > preffered_easing_position = {
@@ -409,30 +442,34 @@ OptionWidget::OptionWidget(Option *option) : Gtk::Box(Gtk::ORIENTATION_HORIZONTA
409
442
};
410
443
if (preffered_easing_position.count (easing) != 0 )
411
444
{
412
- combo_box ->insert (preffered_easing_position.at (easing), easing);
445
+ animate_combo_box ->insert (preffered_easing_position.at (easing), easing);
413
446
} else
414
447
{
415
- combo_box ->append (easing);
448
+ animate_combo_box ->append (easing);
416
449
}
417
450
}
418
451
419
- combo_box->set_active_text (easing_value);
420
-
421
- auto update_option_value = [=, length_widget = spin_button.get (), easing_widget = combo_box.get ()]
422
- {
423
- option->set_save (std::to_string (
424
- length_widget->get_value_as_int ()) + " ms " + easing_widget->get_active_text ().c_str ());
425
- };
426
- spin_button->signal_changed ().connect (sigc::track_obj (update_option_value, tracker));
427
- combo_box->signal_changed ().connect (std::move (update_option_value));
428
- reset_button.signal_clicked ().connect ([=, length_widget = spin_button.get (),
429
- easing_widget = combo_box.get ()]
452
+ ao = {
453
+ .option = option,
454
+ .spin_button = animate_spin_button.get (),
455
+ .combo_box = animate_combo_box.get (),
456
+ };
457
+
458
+ animate_combo_box->set_active_text (easing_value);
459
+ animate_sb_handle =
460
+ g_signal_connect (animate_spin_button->gobj (), " value-changed" , G_CALLBACK (
461
+ update_animate_sb_option_value), &ao);
462
+ animate_cb_handle =
463
+ g_signal_connect (animate_combo_box->gobj (), " changed" , G_CALLBACK (
464
+ update_animate_cb_option_value), &ao);
465
+ reset_button.signal_clicked ().connect ([=, length_widget = animate_spin_button.get (),
466
+ easing_widget = animate_combo_box.get ()]
430
467
{
431
468
length_widget->set_value (default_value->length_ms );
432
469
easing_widget->set_active_text (default_value->easing_name );
433
470
});
434
- pack_end (std::move (spin_button ));
435
- pack_end (std::move (combo_box ));
471
+ pack_end (std::move (animate_spin_button ));
472
+ pack_end (std::move (animate_combo_box ));
436
473
}
437
474
break ;
438
475
@@ -995,8 +1032,8 @@ OptionSubgroupWidget::OptionSubgroupWidget(Option *subgroup)
995
1032
expander.add (expander_layout);
996
1033
for (Option *option : subgroup->options )
997
1034
{
998
- option_widgets.emplace_back ( option);
999
- expander_layout.pack_start (option_widgets.back ());
1035
+ option_widgets.push_back (std::make_unique<OptionWidget>( option) );
1036
+ expander_layout.pack_start (* option_widgets.back ());
1000
1037
}
1001
1038
}
1002
1039
0 commit comments