Skip to content

Instantly share code, notes, and snippets.

@leptos-null
Created April 26, 2019 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leptos-null/9979acc91cd9fd99aee878f5afbffcaa to your computer and use it in GitHub Desktop.
Save leptos-null/9979acc91cd9fd99aee878f5afbffcaa to your computer and use it in GitHub Desktop.
An idea for maintaining orientation state through notify_state
union UIOrientationPortableState {
struct UIOrientationState {
enum UIOrientation { /* this is UIInterfaceOrientation, but unsigned */
UIOrientationUnknown,
UIOrientationPortrait,
UIOrientationPortraitUpsideDown,
UIOrientationLandscapeRight,
UIOrientationLandscapeLeft
}
current : 3, // may be the orientation the device is transitioning to, if transition != UITransitionPhaseZero
previous : 3; // may be unknown when transition == UITransitionPhaseZero
enum UIAnimationCurve { /* this is UIViewAnimationCurve, but unsigned */
UIAnimationCurveEaseInOut,
UIAnimationCurveEaseIn,
UIAnimationCurveEaseOut,
UIAnimationCurveLinear
} curve : 2; // describes the calculation used for the transition between current and previous
enum UITransitionPhase {
UITransitionPhaseZero, // transition is not is progress
/* transition in progress */
UITransitionPhaseDone = ((1 << 24) - 1)
} transition : 24; // use floating division with UITransitionPhaseDone to get the percent into the transition
float duration; // total duration of the transition in seconds
} state;
uint64_t hash;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment