Home » Developing U++ » U++ Developers corner » styling of widgets ( animation / look and feel)
Re: styling of widgets ( animation / look and feel) [message #59813 is a reply to message #59811] |
Fri, 21 April 2023 07:56   |
 |
mirek
Messages: 14265 Registered: November 2005
|
Ultimate Member |
|
|
dodobar wrote on Thu, 20 April 2023 22:36agreed this was to get the ball rolling:
perhaps:
struct Style : ChStyle<Style> {
Value look[4];
Color monocolor[4], textcolor[4];
Point pressoffset;
int focusmargin;
int overpaint;
Font font;
Image ok, cancel, exit;
bool transparent;
bool focus_use_ok;
// Animation properties
enum AnimationFinishBehavior {
GOTO_FIRST, // Go to the first frame when the animation is interrupted
GOTO_LAST, // Go to the last frame when the animation is interrupted
COMPLETE, // Complete the animation normally when interrupted
COMPLETE_FAST, // Complete the animation quickly when interrupted
HOLD, // Hold the current frame when the animation is interrupted
REVERSE // Reverse the animation when interrupted
};
AnimationFinishBehavior animationFinishBehavior;
double animation_duration; // Duration of the animation in seconds
double (*animation_easing_function)(double); // Easing function for the animation
};
and ChStyle perhaps:
template <class T>
struct ChStyle {
// ...
std::vector<T> animationStates;
double animationDuration;
EasingFunction easingFunction;
// ...
};
obviously the drawing functions like ChPaint, ChPaintEdge, and ChPaintBody would need to incorporate the animation properties.
The BaseAnimation class could still handle animation logic and calculate the intermediate values
certainly the case of handling Mouse event (e.g., OnMouseEnter, OnMouseLeave)
would need to have some form of update to the animation system
void Button::OnMouseEnter() {
// notify Update the animation state
// ...
// notify Start the animation
// ...
}
void Button::OnMouseLeave() {
// notify Update the animation state
// ...
// notify Start the animation
// ...
}
That is not a good design - too much for Button code to do.
However, meanwhile I found an elegant solution. Basically the only thing really needed for the style implementing code to allow it to perform animations is a pointer to widget as another ChPaint / ChLookFn parameter. If you have that, animation engine can hook into process easily (with special Values for look, can keep track of status with those, can even post time callbacks to refresh the look).
Moreover, we can make ChPaint a Ctrl method, which solves the problem without changing a single line of code in CtrlLib.
If this all sounds a bit confusing, do not despair. I will try to implement it over weekend or soon, together with reference example.
Mirek
[Updated on: Fri, 21 April 2023 07:56] Report message to a moderator
|
|
|
 |
|
styling of widgets ( animation / look and feel)
By: dodobar on Sun, 16 April 2023 20:54
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: Novo on Mon, 17 April 2023 15:53
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Tue, 18 April 2023 09:17
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 00:37
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Thu, 20 April 2023 08:58
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 13:00
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 13:06
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Thu, 20 April 2023 14:22
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 19:17
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Thu, 20 April 2023 21:51
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 22:36
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Thu, 20 April 2023 23:55
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Fri, 21 April 2023 07:56
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Fri, 21 April 2023 11:40
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Sat, 22 April 2023 14:44
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Sun, 23 April 2023 16:27
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Mon, 24 April 2023 09:23
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Mon, 09 September 2024 09:10
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Mon, 09 September 2024 10:03
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: dodobar on Sun, 22 September 2024 09:28
|
 |
|
Re: styling of widgets ( animation / look and feel)
By: mirek on Sun, 22 September 2024 09:38
|
Goto Forum:
Current Time: Mon Jul 14 05:53:51 CEST 2025
Total time taken to generate the page: 0.03202 seconds
|