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