Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: ash/common/shelf/shelf_layout_manager.h

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/shelf_item_types.cc ('k') | ash/common/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/shelf_layout_manager.h
diff --git a/ash/common/shelf/shelf_layout_manager.h b/ash/common/shelf/shelf_layout_manager.h
deleted file mode 100644
index 87f598a8bd6267c271b5aa9a1230e5e023772d4b..0000000000000000000000000000000000000000
--- a/ash/common/shelf/shelf_layout_manager.h
+++ /dev/null
@@ -1,365 +0,0 @@
-// Copyright 2012 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 ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_
-#define ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_
-
-#include <memory>
-
-#include "ash/ash_export.h"
-#include "ash/common/session/session_state_observer.h"
-#include "ash/common/shelf/wm_shelf.h"
-#include "ash/common/shell_observer.h"
-#include "ash/common/wm/dock/docked_window_layout_manager_observer.h"
-#include "ash/common/wm/lock_state_observer.h"
-#include "ash/common/wm/wm_snap_to_pixel_layout_manager.h"
-#include "ash/common/wm/workspace/workspace_types.h"
-#include "ash/common/wm_activation_observer.h"
-#include "ash/public/cpp/shelf_types.h"
-#include "base/macros.h"
-#include "base/observer_list.h"
-#include "base/timer/timer.h"
-#include "ui/gfx/geometry/insets.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/keyboard/keyboard_controller_observer.h"
-
-namespace ui {
-class ImplicitAnimationObserver;
-class MouseEvent;
-}
-
-namespace ash {
-
-enum class AnimationChangeType;
-class PanelLayoutManagerTest;
-class ShelfLayoutManagerObserver;
-class ShelfLayoutManagerTest;
-class ShelfWidget;
-class WmShelf;
-
-// ShelfLayoutManager is the layout manager responsible for the shelf and
-// status widgets. The shelf is given the total available width and told the
-// width of the status area. This allows the shelf to draw the background and
-// layout to the status area.
-// To respond to bounds changes in the status area StatusAreaLayoutManager works
-// closely with ShelfLayoutManager.
-// On mus, widget bounds management is handled by the window manager.
-class ASH_EXPORT ShelfLayoutManager
- : public ShellObserver,
- public WmActivationObserver,
- public DockedWindowLayoutManagerObserver,
- public keyboard::KeyboardControllerObserver,
- public LockStateObserver,
- public wm::WmSnapToPixelLayoutManager,
- public SessionStateObserver {
- public:
- ShelfLayoutManager(ShelfWidget* shelf_widget, WmShelf* wm_shelf);
- ~ShelfLayoutManager() override;
-
- bool updating_bounds() const { return updating_bounds_; }
-
- // Clears internal data for shutdown process.
- void PrepareForShutdown();
-
- // Returns whether the shelf and its contents (shelf, status) are visible
- // on the screen.
- bool IsVisible() const;
-
- // Returns the ideal bounds of the shelf assuming it is visible.
- gfx::Rect GetIdealBounds();
-
- // Returns the preferred size of the shelf for the target visibility state.
- gfx::Size GetPreferredSize();
-
- // Returns the docked area bounds.
- const gfx::Rect& dock_bounds() const { return dock_bounds_; }
-
- // Returns the bounds within the root window not occupied by the shelf nor the
- // virtual keyboard.
- const gfx::Rect& user_work_area_bounds() const {
- return user_work_area_bounds_;
- }
-
- // Stops any animations and sets the bounds of the shelf and status widgets.
- void LayoutShelfAndUpdateBounds(bool change_work_area);
-
- // Stops any animations, sets the bounds of the shelf and status widgets, and
- // changes the work area
- void LayoutShelf();
-
- // Returns shelf visibility state based on current value of auto hide
- // behavior setting.
- ShelfVisibilityState CalculateShelfVisibility();
-
- // Updates the visibility state.
- void UpdateVisibilityState();
-
- // Invoked by the shelf when the auto-hide state may have changed.
- void UpdateAutoHideState();
-
- // Updates the auto-hide state for certain events.
- // TODO(mash): Add similar event handling support for mash.
- void UpdateAutoHideForMouseEvent(ui::MouseEvent* event, WmWindow* target);
- void UpdateAutoHideForGestureEvent(ui::GestureEvent* event, WmWindow* target);
-
- ShelfVisibilityState visibility_state() const {
- return state_.visibility_state;
- }
- ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
-
- ShelfWidget* shelf_widget() { return shelf_widget_; }
-
- // Sets whether any windows overlap the shelf. If a window overlaps the shelf
- // the shelf renders slightly differently.
- void SetWindowOverlapsShelf(bool value);
- bool window_overlaps_shelf() const { return window_overlaps_shelf_; }
-
- void AddObserver(ShelfLayoutManagerObserver* observer);
- void RemoveObserver(ShelfLayoutManagerObserver* observer);
-
- // Processes a gesture event and updates the status of the shelf when
- // appropriate. Returns true if the gesture has been handled and it should not
- // be processed any further, false otherwise.
- bool ProcessGestureEvent(const ui::GestureEvent& event);
-
- // Set an animation duration override for the show / hide animation of the
- // shelf. Specifying 0 leads to use the default.
- void SetAnimationDurationOverride(int duration_override_in_ms);
-
- // Overridden from wm::WmSnapToPixelLayoutManager:
- void OnWindowResized() override;
- void SetChildBounds(WmWindow* child,
- const gfx::Rect& requested_bounds) override;
-
- // Overridden from ShellObserver:
- void OnShelfAutoHideBehaviorChanged(WmWindow* root_window) override;
- void OnPinnedStateChanged(WmWindow* pinned_window) override;
-
- // Overridden from WmActivationObserver:
- void OnWindowActivated(WmWindow* gained_active,
- WmWindow* lost_active) override;
-
- // Overridden from keyboard::KeyboardControllerObserver:
- void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
- void OnKeyboardClosed() override;
-
- // Overridden from LockStateObserver:
- void OnLockStateEvent(LockStateObserver::EventType event) override;
-
- // Overridden from SessionStateObserver:
- void SessionStateChanged(session_manager::SessionState state) override;
-
- // TODO(harrym|oshima): These templates will be moved to a new Shelf class.
- // A helper function for choosing values specific to a shelf alignment.
- template <typename T>
- T SelectValueForShelfAlignment(T bottom, T left, T right) const {
- switch (wm_shelf_->GetAlignment()) {
- case SHELF_ALIGNMENT_BOTTOM:
- case SHELF_ALIGNMENT_BOTTOM_LOCKED:
- return bottom;
- case SHELF_ALIGNMENT_LEFT:
- return left;
- case SHELF_ALIGNMENT_RIGHT:
- return right;
- }
- NOTREACHED();
- return right;
- }
-
- template <typename T>
- T PrimaryAxisValue(T horizontal, T vertical) const {
- return wm_shelf_->IsHorizontalAlignment() ? horizontal : vertical;
- }
-
- // Returns how the shelf background should be painted.
- ShelfBackgroundType GetShelfBackgroundType() const;
-
- // Set the height of the ChromeVox panel, which takes away space from the
- // available work area from the top of the screen.
- void SetChromeVoxPanelHeight(int height);
-
- private:
- class UpdateShelfObserver;
- friend class PanelLayoutManagerTest;
- friend class ShelfLayoutManagerTest;
- friend class WebNotificationTrayTest;
-
- struct TargetBounds {
- TargetBounds();
- ~TargetBounds();
-
- float opacity;
- float status_opacity;
- gfx::Rect shelf_bounds_in_root;
- gfx::Rect shelf_bounds_in_shelf;
- gfx::Rect status_bounds_in_shelf;
- gfx::Insets work_area_insets;
- };
-
- struct State {
- State();
-
- // Returns true when a secondary user is being added to an existing session.
- bool IsAddingSecondaryUser() const;
-
- bool IsScreenLocked() const;
-
- // Returns true if the two states are considered equal. As
- // |auto_hide_state| only matters if |visibility_state| is
- // |SHELF_AUTO_HIDE|, Equals() ignores the |auto_hide_state| as
- // appropriate.
- bool Equals(const State& other) const;
-
- ShelfVisibilityState visibility_state;
- ShelfAutoHideState auto_hide_state;
- wm::WorkspaceWindowState window_state;
- // True when the system is in the cancelable, pre-lock screen animation.
- bool pre_lock_screen_animation_active;
- session_manager::SessionState session_state;
- };
-
- // Sets the visibility of the shelf to |state|.
- void SetState(ShelfVisibilityState visibility_state);
-
- // Updates the bounds and opacity of the shelf and status widgets.
- // If |observer| is specified, it will be called back when the animations, if
- // any, are complete. |change_work_area| specifies whether or not to update
- // the work area of the screen.
- void UpdateBoundsAndOpacity(const TargetBounds& target_bounds,
- bool animate,
- bool change_work_area,
- ui::ImplicitAnimationObserver* observer);
-
- // Stops any animations and progresses them to the end.
- void StopAnimating();
-
- // Calculates the target bounds assuming visibility of |visible|.
- void CalculateTargetBounds(const State& state, TargetBounds* target_bounds);
-
- // Updates the target bounds if a gesture-drag is in progress. This is only
- // used by |CalculateTargetBounds()|.
- void UpdateTargetBoundsForGesture(TargetBounds* target_bounds) const;
-
- // Updates the background of the shelf if it has changed.
- void MaybeUpdateShelfBackground(AnimationChangeType change_type);
-
- // Updates the auto hide state immediately.
- void UpdateAutoHideStateNow();
-
- // Stops the auto hide timer and clears
- // |mouse_over_shelf_when_auto_hide_timer_started_|.
- void StopAutoHideTimer();
-
- // Returns the bounds of an additional region which can trigger showing the
- // shelf. This region exists to make it easier to trigger showing the shelf
- // when the shelf is auto hidden and the shelf is on the boundary between
- // two displays.
- gfx::Rect GetAutoHideShowShelfRegionInScreen() const;
-
- // Returns the AutoHideState. This value is determined from the shelf and
- // tray.
- ShelfAutoHideState CalculateAutoHideState(
- ShelfVisibilityState visibility_state) const;
-
- // Returns true if |window| is a descendant of the shelf.
- bool IsShelfWindow(WmWindow* window);
-
- int GetWorkAreaInsets(const State& state, int size) const;
-
- // Overridden from DockedWindowLayoutManagerObserver:
- void OnDockBoundsChanging(
- const gfx::Rect& dock_bounds,
- DockedWindowLayoutManagerObserver::Reason reason) override;
-
- // Called when the LoginUI changes from visible to invisible.
- void UpdateShelfVisibilityAfterLoginUIChange();
-
- // Compute |target_bounds| opacity based on gesture and shelf visibility.
- float ComputeTargetOpacity(const State& state);
-
- // Returns true if there is a fullscreen window open that causes the shelf
- // to be hidden.
- bool IsShelfHiddenForFullscreen() const;
-
- // Gesture related functions:
- void StartGestureDrag(const ui::GestureEvent& gesture);
- void UpdateGestureDrag(const ui::GestureEvent& gesture);
- void CompleteGestureDrag(const ui::GestureEvent& gesture);
- void CancelGestureDrag();
-
- // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling
- // UpdateBoundsAndOpacity() again from SetChildBounds().
- bool updating_bounds_;
-
- bool in_shutdown_ = false;
-
- // True if the last mouse event was a mouse drag.
- bool in_mouse_drag_ = false;
-
- // Current state.
- State state_;
-
- ShelfWidget* shelf_widget_;
- WmShelf* wm_shelf_;
-
- // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
- bool window_overlaps_shelf_;
-
- base::OneShotTimer auto_hide_timer_;
-
- // Whether the mouse was over the shelf when the auto hide timer started.
- // False when neither the auto hide timer nor the timer task are running.
- bool mouse_over_shelf_when_auto_hide_timer_started_;
-
- base::ObserverList<ShelfLayoutManagerObserver> observers_;
-
- // The shelf reacts to gesture-drags, and can be set to auto-hide for certain
- // gestures. Some shelf behaviour (e.g. visibility state, background color
- // etc.) are affected by various stages of the drag. The enum keeps track of
- // the present status of the gesture drag.
- enum GestureDragStatus {
- GESTURE_DRAG_NONE,
- GESTURE_DRAG_IN_PROGRESS,
- GESTURE_DRAG_CANCEL_IN_PROGRESS,
- GESTURE_DRAG_COMPLETE_IN_PROGRESS
- };
- GestureDragStatus gesture_drag_status_;
-
- // Tracks the amount of the drag. The value is only valid when
- // |gesture_drag_status_| is set to GESTURE_DRAG_IN_PROGRESS.
- float gesture_drag_amount_;
-
- // Manage the auto-hide state during the gesture.
- ShelfAutoHideState gesture_drag_auto_hide_state_;
-
- // Used to delay updating shelf background.
- UpdateShelfObserver* update_shelf_observer_;
-
- // The bounds of the keyboard.
- gfx::Rect keyboard_bounds_;
-
- // The bounds of the dock.
- gfx::Rect dock_bounds_;
-
- // The bounds within the root window not occupied by the shelf nor the virtual
- // keyboard.
- gfx::Rect user_work_area_bounds_;
-
- // The height of the ChromeVox panel at the top of the screen, which
- // needs to be removed from the available work area.
- int chromevox_panel_height_;
-
- // The show hide animation duration override or 0 for default.
- int duration_override_in_ms_;
-
- // The current shelf background. Should not be assigned to directly, use
- // MaybeUpdateShelfBackground() instead.
- ShelfBackgroundType shelf_background_type_;
-
- DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
-};
-
-} // namespace ash
-
-#endif // ASH_COMMON_SHELF_SHELF_LAYOUT_MANAGER_H_
« no previous file with comments | « ash/common/shelf/shelf_item_types.cc ('k') | ash/common/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698