Home | History | Annotate | Download | only in panels
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_STACK_WINDOW_H_
      6 #define CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_STACK_WINDOW_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "base/strings/string16.h"
     10 #include "ui/gfx/image/image.h"
     11 
     12 class Panel;
     13 namespace gfx {
     14 class Rect;
     15 class Vector2d;
     16 }
     17 
     18 class NativePanelStackWindowDelegate {
     19  public:
     20   // Returns the title representing the whole stack.
     21   virtual base::string16 GetTitle() const = 0;
     22 
     23   // Returns the icon denoting the whole stack.
     24   virtual gfx::Image GetIcon() const = 0;
     25 
     26   // Called when the batch bounds update is completed, i.e. animation ends.
     27   virtual void PanelBoundsBatchUpdateCompleted() = 0;
     28 };
     29 
     30 // An interface that encapsulates the platform-specific behaviors that are
     31 // needed to support multiple panels that are stacked together. A native
     32 // window might be created to enclose all the panels in the stack. The lifetime
     33 // of the class that implements this interface is managed by itself.
     34 class NativePanelStackWindow {
     35  public:
     36   // Creates and returns a NativePanelStackWindow instance. Calling Close() will
     37   // destruct the instance.
     38   static NativePanelStackWindow* Create(
     39       NativePanelStackWindowDelegate* delegate);
     40 
     41   virtual ~NativePanelStackWindow() {}
     42 
     43   virtual bool IsMinimized() const = 0;
     44 
     45  protected:
     46   friend class StackedPanelCollection;
     47 
     48   // Called when the stack is to be closed. This will cause this instance to be
     49   // self destructed after the native window closes.
     50   virtual void Close() = 0;
     51 
     52   // Makes |panel| be enclosed by this stack window.
     53 
     54   // Adds |panel| to the set of panels grouped and shown inside this stack
     55   // Window. It does not take ownership of |panel|.
     56   virtual void AddPanel(Panel* panel) = 0;
     57 
     58   // Removes |panel| from the set of panels grouped and shown inside this stack
     59   // window.
     60   virtual void RemovePanel(Panel* panel) = 0;
     61 
     62   // Merges those panels grouped and shown inside |another| stack window into
     63   // the set of panels grouped and shown inside this stack window.
     64   virtual void MergeWith(NativePanelStackWindow* another) = 0;
     65 
     66   // Returns true if no panel is being shown inside this stack window.
     67   virtual bool IsEmpty() const = 0;
     68 
     69   // Returns true if |panel| is being enclosed by this stack window.
     70   virtual bool HasPanel(Panel* panel) const = 0;
     71 
     72   // Moves all panels instantly by |delta|. All the moves should be done
     73   // simulatenously.
     74   virtual void MovePanelsBy(const gfx::Vector2d& delta) = 0;
     75 
     76   // Changes the bounds of a set of panels synchronously.
     77   virtual void BeginBatchUpdatePanelBounds(bool animate) = 0;
     78   virtual void AddPanelBoundsForBatchUpdate(Panel* panel,
     79                                             const gfx::Rect& new_bounds) = 0;
     80   virtual void EndBatchUpdatePanelBounds() = 0;
     81 
     82   // Returns true if some panels within this stack window are still in the
     83   // process of bounds animation.
     84   virtual bool IsAnimatingPanelBounds() const = 0;
     85 
     86   // Minimizes all the panels in the stack as a whole via system.
     87   virtual void Minimize() = 0;
     88 
     89   // Draws or clears the attention via system. The system might choose to
     90   // flash the taskbar icon for attention.
     91   virtual void DrawSystemAttention(bool draw_attention) = 0;
     92 
     93   // Called when the panel is activated.
     94   virtual void OnPanelActivated(Panel* panel) = 0;
     95 };
     96 
     97 #endif  // CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_STACK_WINDOW_H_
     98