CTTabView.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) 2009 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-chromium file.
  4. #ifndef CHROME_BROWSER_COCOA_TAB_VIEW_H_
  5. #define CHROME_BROWSER_COCOA_TAB_VIEW_H_
  6. #pragma once
  7. #import <Cocoa/Cocoa.h>
  8. #import <ApplicationServices/ApplicationServices.h>
  9. //#import <map>
  10. //#import "scoped_nsobject.h"
  11. #import "BackgroundGradientView.h"
  12. // Nomenclature:
  13. // Tabs _glow_ under two different circumstances, when they are _hovered_ (by
  14. // the mouse) and when they are _alerted_ (to show that the tab's title has
  15. // changed).
  16. // The state of alerting (to show a title change on an inactive, pinned tab).
  17. // This is more complicated than a simple on/off since we want to allow the
  18. // alert glow to go through a full rise-hold-fall cycle to avoid flickering (or
  19. // always holding).
  20. typedef enum {
  21. kAlertNone = 0, // Obj-C initializes to this.
  22. kAlertRising,
  23. kAlertHolding,
  24. kAlertFalling
  25. } AlertState;
  26. @class CTTabController;
  27. // A view that handles the event tracking (clicking and dragging) for a tab
  28. // on the tab strip. Relies on an associated CTTabController to provide a
  29. // target/action for selecting the tab.
  30. @interface CTTabView : BackgroundGradientView
  31. @property (nonatomic,copy) void (^moveCallback) (BOOL mouseEntered);
  32. @property(assign, nonatomic) NSCellStateValue state;
  33. @property(assign, nonatomic) CGFloat hoverAlpha;
  34. @property(assign, nonatomic) CGFloat alertAlpha;
  35. // Determines if the tab is in the process of animating closed. It may still
  36. // be visible on-screen, but should not respond to/initiate any events. Upon
  37. // setting to NO, clears the target/action of the close button to prevent
  38. // clicks inside it from sending messages.
  39. @property(assign, nonatomic, setter = setClosing:) BOOL isClosing;
  40. // Returns the inset multiplier used to compute the inset of the top of the tab.
  41. + (CGFloat)insetMultiplier;
  42. // Enables/Disables tracking regions for the tab.
  43. - (void)setTrackingEnabled:(BOOL)enabled;
  44. // Begin showing an "alert" glow (shown to call attention to an inactive
  45. // pinned tab whose title changed).
  46. - (void)startAlert;
  47. // Stop showing the "alert" glow; this won't immediately wipe out any glow, but
  48. // will make it fade away.
  49. - (void)cancelAlert;
  50. @end
  51. // The CTTabController |tabController_| is not the only owner of this view. If the
  52. // controller is released before this view, then we could be hanging onto a
  53. // garbage pointer. To prevent this, the CTTabController uses this interface to
  54. // clear the |tabController_| pointer when it is dying.
  55. @interface CTTabView (TabControllerInterface)
  56. - (void)setController:(CTTabController*)controller;
  57. - (CTTabController*)controller;
  58. @end
  59. #endif // CHROME_BROWSER_COCOA_TAB_VIEW_H_