Home | History | Annotate | Download | only in cocoa
      1 // Copyright (c) 2011 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_COCOA_TABPOSE_WINDOW_H_
      6 #define CHROME_BROWSER_UI_COCOA_TABPOSE_WINDOW_H_
      7 #pragma once
      8 
      9 #import <Cocoa/Cocoa.h>
     10 
     11 #include "base/mac/scoped_cftyperef.h"
     12 
     13 #include "base/memory/scoped_nsobject.h"
     14 #include "base/memory/scoped_ptr.h"
     15 #include "base/memory/scoped_vector.h"
     16 
     17 namespace tabpose {
     18 
     19 class Tile;
     20 class TileSet;
     21 
     22 }
     23 
     24 namespace tabpose {
     25 
     26 enum WindowState {
     27   kFadingIn,
     28   kFadedIn,
     29   kFadingOut,
     30 };
     31 
     32 }  // namespace tabpose
     33 
     34 class TabStripModel;
     35 class TabStripModelObserverBridge;
     36 
     37 // A TabposeWindow shows an overview of open tabs and lets the user select a new
     38 // active tab. The window blocks clicks on the tab strip and the download
     39 // shelf. Every open browser window has its own overlay, and they are
     40 // independent of each other.
     41 @interface TabposeWindow : NSWindow {
     42  @private
     43   tabpose::WindowState state_;
     44 
     45   // The root layer added to the content view. Covers the whole window.
     46   CALayer* rootLayer_;  // weak
     47 
     48   // The layer showing the background layer. Covers the whole visible area.
     49   CALayer* bgLayer_;  // weak
     50 
     51   // Top gradient.
     52   CALayer* topGradient_;  // weak
     53 
     54   // The layer drawn behind the currently selected tile.
     55   CALayer* selectionHighlight_;  // weak
     56 
     57   // Colors used by the layers.
     58   base::mac::ScopedCFTypeRef<CGColorRef> gray_;
     59   base::mac::ScopedCFTypeRef<CGColorRef> darkBlue_;
     60 
     61   TabStripModel* tabStripModel_;  // weak
     62 
     63   // Stores all preview layers. The order in here matches the order in
     64   // the tabstrip model.
     65   scoped_nsobject<NSMutableArray> allThumbnailLayers_;
     66 
     67   scoped_nsobject<NSMutableArray> allFaviconLayers_;
     68   scoped_nsobject<NSMutableArray> allTitleLayers_;
     69 
     70   // Manages the state of all layers.
     71   scoped_ptr<tabpose::TileSet> tileSet_;
     72 
     73   // The rectangle of the window that contains all layers. This is the
     74   // rectangle occupied by |bgLayer_|.
     75   NSRect containingRect_;
     76 
     77   // Informs us of added/removed/updated tabs.
     78   scoped_ptr<TabStripModelObserverBridge> tabStripModelObserverBridge_;
     79 
     80   // The icon used for the closebutton layers.
     81   base::mac::ScopedCFTypeRef<CGImageRef> closeIcon_;
     82 
     83   // True if all close layers should be shown (as opposed to just the close
     84   // layer of the currently selected thumbnail).
     85   BOOL showAllCloseLayers_;
     86 }
     87 
     88 // Shows a TabposeWindow on top of |parent|, with |rect| being the active area.
     89 // If |slomo| is YES, then the appearance animation is shown in slow motion.
     90 // The window blocks all keyboard and mouse events and releases itself when
     91 // closed.
     92 + (id)openTabposeFor:(NSWindow*)parent
     93                 rect:(NSRect)rect
     94                slomo:(BOOL)slomo
     95        tabStripModel:(TabStripModel*)tabStripModel;
     96 @end
     97 
     98 @interface TabposeWindow (TestingAPI)
     99 - (void)selectTileAtIndexWithoutAnimation:(int)newIndex;
    100 - (NSUInteger)thumbnailLayerCount;
    101 - (int)selectedIndex;
    102 @end
    103 
    104 #endif  // CHROME_BROWSER_UI_COCOA_TABPOSE_WINDOW_H_
    105