diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 20:43:09 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 20:43:09 +0000 |
commit | bef76ead355bfb64d93336a548b8b16602a853c1 (patch) | |
tree | c4b4bcc9e7c00040164b816f59956217fb242594 /chrome/browser/gtk/tabs | |
parent | 039e0675aa04aa3b9643641a5410ec89244e18d4 (diff) | |
download | chromium_src-bef76ead355bfb64d93336a548b8b16602a853c1.zip chromium_src-bef76ead355bfb64d93336a548b8b16602a853c1.tar.gz chromium_src-bef76ead355bfb64d93336a548b8b16602a853c1.tar.bz2 |
Remove the no-longer used TabButtonGtk class.
Review URL: http://codereview.chromium.org/108035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tabs')
-rw-r--r-- | chrome/browser/gtk/tabs/tab_button_gtk.cc | 93 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_button_gtk.h | 106 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 2 |
3 files changed, 0 insertions, 201 deletions
diff --git a/chrome/browser/gtk/tabs/tab_button_gtk.cc b/chrome/browser/gtk/tabs/tab_button_gtk.cc deleted file mode 100644 index db36717..0000000 --- a/chrome/browser/gtk/tabs/tab_button_gtk.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/gtk/tabs/tab_button_gtk.h" - -TabButtonGtk::TabButtonGtk(Delegate* delegate) - : state_(BS_NORMAL), - mouse_pressed_(false), - delegate_(delegate) { -} - -TabButtonGtk::~TabButtonGtk() { -} - -bool TabButtonGtk::IsPointInBounds(const gfx::Point& point) { - GdkRegion* region = delegate_->MakeRegionForButton(this); - if (!region) - return bounds_.Contains(point); - - bool in_bounds = (gdk_region_point_in(region, point.x(), point.y()) == TRUE); - gdk_region_destroy(region); - return in_bounds; -} - -bool TabButtonGtk::OnMotionNotify(GdkEventMotion* event) { - ButtonState state; - - gfx::Point point(event->x, event->y); - if (IsPointInBounds(point)) { - if (mouse_pressed_) { - state = BS_PUSHED; - } else { - state = BS_HOT; - } - } else { - state = BS_NORMAL; - } - - bool need_redraw = (state_ != state); - state_ = state; - return need_redraw; -} - -bool TabButtonGtk::OnMousePress() { - if (state_ == BS_HOT) { - mouse_pressed_ = true; - state_ = BS_PUSHED; - return true; - } - - return false; -} - -void TabButtonGtk::OnMouseRelease() { - mouse_pressed_ = false; - - if (state_ == BS_PUSHED) { - delegate_->OnButtonActivate(this); - - // Jiggle the mouse so we re-highlight the Tab button. - HighlightTabButton(); - } - - state_ = BS_NORMAL; -} - -bool TabButtonGtk::OnLeaveNotify() { - bool paint = (state_ != BS_NORMAL); - state_ = BS_NORMAL; - return paint; -} - -void TabButtonGtk::Paint(ChromeCanvasPaint* canvas) { - canvas->DrawBitmapInt(images_[state_], bounds_.x(), bounds_.y()); -} - -void TabButtonGtk::SetImage(ButtonState state, SkBitmap* bitmap) { - images_[state] = bitmap ? *bitmap : SkBitmap(); -} - -void TabButtonGtk::HighlightTabButton() { - // Get default display and screen. - GdkDisplay* display = gdk_display_get_default(); - GdkScreen* screen = gdk_display_get_default_screen(display); - - // Get cursor position. - int x, y; - gdk_display_get_pointer(display, NULL, &x, &y, NULL); - - // Reset cusor position. - gdk_display_warp_pointer(display, screen, x, y); -} diff --git a/chrome/browser/gtk/tabs/tab_button_gtk.h b/chrome/browser/gtk/tabs/tab_button_gtk.h deleted file mode 100644 index 17fb5a5..0000000 --- a/chrome/browser/gtk/tabs/tab_button_gtk.h +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2009 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 CHROME_BROWSER_GTK_TABS_TAB_BUTTON_GTK_H_ -#define CHROME_BROWSER_GTK_TABS_TAB_BUTTON_GTK_H_ - -#include <gdk/gdk.h> - -#include "base/gfx/rect.h" -#include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/common/gfx/chrome_canvas.h" -#include "skia/include/SkBitmap.h" - -/////////////////////////////////////////////////////////////////////////////// -// TabButtonGtk -// -// Performs hit-testing and rendering of a Tab button. -// -class TabButtonGtk { - public: - // Possible button states - enum ButtonState { - BS_NORMAL, - BS_HOT, - BS_PUSHED, - BS_COUNT - }; - - class Delegate { - public: - // Creates a clickable region of the button's visual representation used - // for hit-testing. Caller is responsible for destroying the region. If - // NULL is returned, the bounds of the button will be used for hit-testing. - virtual GdkRegion* MakeRegionForButton( - const TabButtonGtk* button) const = 0; - - // Sent when the user activates the button, which is defined as a press - // and release of a mouse click over the button. - virtual void OnButtonActivate(const TabButtonGtk* button) = 0; - }; - - explicit TabButtonGtk(Delegate* delegate); - virtual ~TabButtonGtk(); - - // Returns the bounds of the button. - int x() const { return bounds_.x(); } - int y() const { return bounds_.y(); } - int width() const { return bounds_.width(); } - int height() const { return bounds_.height(); } - - const gfx::Rect& bounds() const { return bounds_; } - - // Sets the bounds of the button. - void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; } - - // Checks whether |point| is inside the bounds of the button. - bool IsPointInBounds(const gfx::Point& point); - - // Sent by the tabstrip when the mouse moves within this button. Mouse state - // is in |event|. Returns true if the tabstrip needs to be redrawn as a - // result of the motion. - bool OnMotionNotify(GdkEventMotion* event); - - // Sent by the tabstrip when the mouse clicks within this button. Returns - // true if the tabstrip needs to be redrawn as a result of the click. - bool OnMousePress(); - - // Sent by the tabstrip when the mouse click is released. - void OnMouseRelease(); - - // Sent by the tabstrip when the mouse leaves this button. Returns true - // if the tabstrip needs to be redrawn as a result of the movement. - bool OnLeaveNotify(); - - // Paints the Tab button into |canvas|. - void Paint(ChromeCanvasPaint* canvas); - - // Sets the image the button should use for the provided state. - void SetImage(ButtonState state, SkBitmap* bitmap); - - private: - // When the tab animation completes, we send the widget a message to - // simulate a mouse moved event at the current mouse position. This tickles - // the button to show the "hot" state. - void HighlightTabButton(); - - // The images used to render the different states of this button. - SkBitmap images_[BS_COUNT]; - - // The current state of the button. - ButtonState state_; - - // The current bounds of the button. - gfx::Rect bounds_; - - // Set if the mouse is pressed anywhere inside the button. - bool mouse_pressed_; - - // Delegate to receive button messages. - Delegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(TabButtonGtk); -}; - -#endif // CHROME_BROWSER_GTK_TABS_TAB_BUTTON_GTK_H_ diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 6631764..3bc5834 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -11,7 +11,6 @@ #include "chrome/browser/browser.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" -#include "chrome/browser/gtk/tabs/tab_button_gtk.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" @@ -979,7 +978,6 @@ void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation, // static gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event, TabStripGtk* tabstrip) { - if (gdk_region_empty(event->region)) return TRUE; |