summaryrefslogtreecommitdiffstats
path: root/athena/screen/modal_window_controller.h
blob: 71c1dee573ae779b6dbd19fc7e13fc05d97df91e (plain)
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
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ATHENA_SCREEN_MODAL_WINDOW_CONTROLLER_H_
#define ATHENA_SCREEN_MODAL_WINDOW_CONTROLLER_H_

#include "athena/athena_export.h"
#include "ui/aura/window_observer.h"

namespace athena {

// ModalWindow controller manages the modal window and
// its container. This gets created when a modal window is opened
// and deleted when all modal windows are deleted.
class ATHENA_EXPORT ModalWindowController : public aura::WindowObserver {
 public:
  // Returns the ModalWindowController associated with the container.
  static ModalWindowController* Get(aura::Window* container);

  explicit ModalWindowController(int container_priority);
  ~ModalWindowController() override;

  aura::Window* modal_container() { return modal_container_; }

  bool dimmed() const { return dimmed_; }

 private:
  // aura::WindowObserver:
  virtual void OnWindowAdded(aura::Window* child) override;
  virtual void OnWindowVisibilityChanged(aura::Window* window,
                                         bool visible) override;
  virtual void OnWindowBoundsChanged(aura::Window* window,
                                     const gfx::Rect& old_bounds,
                                     const gfx::Rect& new_bounds) override;
  virtual void OnWindowDestroyed(aura::Window* window) override;

  // Tells if the child is not a dimmer window and a child of the modal
  // container.
  bool IsChildWindow(aura::Window* child) const;

  void UpdateDimmerWindowBounds();

  // Change dimming state based on the visible window in the container.
  void UpdateDimming(aura::Window* ignore);

  // Note: changing true -> false will delete the modal_container_.
  void SetDimmed(bool dimmed);

  aura::Window* modal_container_;  // not owned.
  aura::Window* dimmer_window_;    // not owned.

  bool dimmed_;
  DISALLOW_COPY_AND_ASSIGN(ModalWindowController);
};

}  // namespace athena

#endif  // ATHENA_SCREEN_MODAL_WINDOW_CONTROLLER_H_