Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for animation easings #80

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Add support for animation easings #80

merged 1 commit into from
Jun 24, 2024

Conversation

soreau
Copy link
Member

@soreau soreau commented Jun 16, 2024

Fixes #79.

@mark-herbert42
Copy link

Works well for me. Applied over 0.8

Copy link
Member

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it seems to be working now!

src/wcm.cpp Outdated
}
}

combo_box->set_active(int_type);
Copy link
Collaborator

@NamorNiradnug NamorNiradnug Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using set_active_text here (as well as below)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason? Either way, it just looks like it would be the same thing with more code.

@NamorNiradnug
Copy link
Collaborator

I tested it as well, seems to be working, thanks!

src/wcm.cpp Outdated Show resolved Hide resolved
src/wcm.cpp Outdated
default_value = default_value]
{
std::cout << __func__ << std::endl;
if (easing_type == easing_types[3])
Copy link
Collaborator

@NamorNiradnug NamorNiradnug Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like dangling references: easing_types and easing_type are on stack and captured by reference. Probably easing_types should be made static const. Although capturing it is unnecessary with set_active_text.

UPD: actually I think easing_types list should be provided by wf::animation_description_t.
UPD2: turns out there is such a function: wf::animation::smoothing::get_available_smooth_functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this for you to figure out.

src/wcm.cpp Outdated Show resolved Hide resolved
src/wcm.cpp Outdated Show resolved Hide resolved
set_value.has_value() ? set_value->easing_name : std::get<std::string>(option->
default_value);
std::string animation_value = std::to_string(
widget->get_value_as_int()) + "ms " + easing;
Copy link
Collaborator

@NamorNiradnug NamorNiradnug Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maaaybe a better approach would be to add a Option::set_value overload which takes two parameters (int and std::string). It would simplify code here to option->set_save(default_value, default_easing_type) and allow to avoid code duplication (here and below in reset and combo_box->signal_changed() callbacks).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this for you to do.

@soreau
Copy link
Member Author

soreau commented Jun 19, 2024

@NamorNiradnug Thanks for the review! I have to fix CI, then I'll rebase this on the CI fix and address your concerns.

std::string animation_value = std::to_string(
default_value) + "ms " + widget->get_active_text();
std::cout << animation_value << std::endl;
option->set_save(animation_value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this set_save call is unnecessary because calling widget->set_active(...) emits signal_changed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to set the combobox widgets to the current value.

@soreau
Copy link
Member Author

soreau commented Jun 24, 2024

@NamorNiradnug Thanks for the review. Is there any way you can add commits to this PR, to fix the rest of the things you want to fix?

@soreau
Copy link
Member Author

soreau commented Jun 24, 2024

For what it's worth, there's some bug that keeps setting int options to 0, and also happens on animation easing types. Just adjust an int value and close wcm, it will likely get set to 0. This started happening around the time of the gtkmm port. I would like to fix it because it's quite annoying.

@soreau soreau merged commit 84b1893 into master Jun 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wcm can not change animation duration anymore.
4 participants