File: window_animations.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (119 lines) | stat: -rw-r--r-- 4,349 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_WM_CORE_WINDOW_ANIMATIONS_H_
#define UI_WM_CORE_WINDOW_ANIMATIONS_H_

#include "base/component_export.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/wm/core/window_properties.h"

namespace aura {
class Window;
}
namespace base {
class TimeDelta;
}

namespace wm {

using WindowVisibilityAnimationCallback =
    base::RepeatingCallback<void(aura::Window*, bool visible)>;

// A variety of canned animations for window transitions.
enum WindowVisibilityAnimationType {
  WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT = 0,  // Default. Lets the system
                                                 // decide based on window
                                                 // type.
  WINDOW_VISIBILITY_ANIMATION_TYPE_DROP,         // Window shrinks in.
  WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL,     // Vertical Glenimation.
  WINDOW_VISIBILITY_ANIMATION_TYPE_FADE,         // Fades in/out.
  WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE,       // Window rotates in.
  WINDOW_VISIBILITY_ANIMATION_TYPE_CUSTOM,       // Custom animation.

  // Downstream library animations start above this point.
  WINDOW_VISIBILITY_ANIMATION_MAX
};

// Canned animations that take effect once but don't have a symmetric pair as
// visibility animations do.
enum WindowAnimationType {
  WINDOW_ANIMATION_TYPE_BOUNCE = 0,  // Window scales up and down.
};

// These two methods use int for type rather than WindowVisibilityAnimationType
// since downstream libraries can extend the set of animations.
COMPONENT_EXPORT(UI_WM)
void SetWindowVisibilityAnimationType(aura::Window* window, int type);
COMPONENT_EXPORT(UI_WM)
int GetWindowVisibilityAnimationType(aura::Window* window);

COMPONENT_EXPORT(UI_WM)
void SetWindowVisibilityCustomAnimation(
    aura::Window* window,
    WindowVisibilityAnimationCallback callback);

COMPONENT_EXPORT(UI_WM)
void SetWindowVisibilityAnimationTransition(
    aura::Window* window,
    WindowVisibilityAnimationTransition transition);

COMPONENT_EXPORT(UI_WM)
bool HasWindowVisibilityAnimationTransition(
    aura::Window* window,
    WindowVisibilityAnimationTransition transition);

COMPONENT_EXPORT(UI_WM)
void SetWindowVisibilityAnimationDuration(aura::Window* window,
                                          const base::TimeDelta& duration);

COMPONENT_EXPORT(UI_WM)
base::TimeDelta GetWindowVisibilityAnimationDuration(
    const aura::Window& window);

COMPONENT_EXPORT(UI_WM)
void SetWindowVisibilityAnimationVerticalPosition(aura::Window* window,
                                                  float position);

class ImplicitHidingWindowAnimationObserver;
// A wrapper of ui::ScopedLayerAnimationSettings for implicit hiding animations.
// Use this to ensure that the hiding animation is visible even after
// the window is deleted or deactivated, instead of using
// ui::ScopedLayerAnimationSettings directly.
class COMPONENT_EXPORT(UI_WM) ScopedHidingAnimationSettings {
 public:
  explicit ScopedHidingAnimationSettings(aura::Window* window);

  ScopedHidingAnimationSettings(const ScopedHidingAnimationSettings&) = delete;
  ScopedHidingAnimationSettings& operator=(
      const ScopedHidingAnimationSettings&) = delete;

  ~ScopedHidingAnimationSettings();

  // Returns the wrapped ScopedLayeAnimationSettings instance.
  ui::ScopedLayerAnimationSettings* layer_animation_settings() {
    return &layer_animation_settings_;
  }

 private:
  ui::ScopedLayerAnimationSettings layer_animation_settings_;
  raw_ptr<ImplicitHidingWindowAnimationObserver> observer_;
};

// Returns false if the |window| didn't animate.
COMPONENT_EXPORT(UI_WM)
bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible);
COMPONENT_EXPORT(UI_WM)
bool AnimateWindow(aura::Window* window, WindowAnimationType type);

// Returns true if window animations are disabled for |window|. Window
// animations are enabled by default. If |window| is nullptr, this just checks
// if the global flag disabling window animations is present.
COMPONENT_EXPORT(UI_WM) bool WindowAnimationsDisabled(aura::Window* window);

}  // namespace wm

#endif  // UI_WM_CORE_WINDOW_ANIMATIONS_H_