Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1729)

Side by Side Diff: chrome/browser/gtk/browser_actions_toolbar_gtk.cc

Issue 2861040: Hide the browser actions gripper when it's not in use. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix fixme Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h" 5 #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 model_(NULL), 343 model_(NULL),
344 hbox_(gtk_hbox_new(FALSE, 0)), 344 hbox_(gtk_hbox_new(FALSE, 0)),
345 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), 345 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)),
346 overflow_button_(browser->profile()), 346 overflow_button_(browser->profile()),
347 separator_(theme_provider_->CreateToolbarSeparator()), 347 separator_(theme_provider_->CreateToolbarSeparator()),
348 drag_button_(NULL), 348 drag_button_(NULL),
349 drop_index_(-1), 349 drop_index_(-1),
350 resize_animation_(this), 350 resize_animation_(this),
351 desired_width_(0), 351 desired_width_(0),
352 start_width_(0), 352 start_width_(0),
353 draw_gripper_(false),
353 method_factory_(this) { 354 method_factory_(this) {
354 ExtensionsService* extension_service = profile_->GetExtensionsService(); 355 ExtensionsService* extension_service = profile_->GetExtensionsService();
355 // The |extension_service| can be NULL in Incognito. 356 // The |extension_service| can be NULL in Incognito.
356 if (!extension_service) 357 if (!extension_service)
357 return; 358 return;
358 359
359 GtkWidget* gripper = gtk_button_new(); 360 GtkWidget* gripper = gtk_button_new();
360 GTK_WIDGET_UNSET_FLAGS(gripper, GTK_CAN_FOCUS); 361 GTK_WIDGET_UNSET_FLAGS(gripper, GTK_CAN_FOCUS);
361 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK); 362 gtk_widget_add_events(gripper, GDK_POINTER_MOTION_MASK);
362 signals_.Connect(gripper, "motion-notify-event", 363 signals_.Connect(gripper, "motion-notify-event",
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 -event->x : 747 -event->x :
747 event->x - widget->allocation.width; 748 event->x - widget->allocation.width;
748 gint new_width = button_hbox_->allocation.width - distance_dragged; 749 gint new_width = button_hbox_->allocation.width - distance_dragged;
749 SetButtonHBoxWidth(new_width); 750 SetButtonHBoxWidth(new_width);
750 751
751 return FALSE; 752 return FALSE;
752 } 753 }
753 754
754 gboolean BrowserActionsToolbarGtk::OnGripperExpose(GtkWidget* gripper, 755 gboolean BrowserActionsToolbarGtk::OnGripperExpose(GtkWidget* gripper,
755 GdkEventExpose* expose) { 756 GdkEventExpose* expose) {
757 if (!draw_gripper_)
758 return TRUE;
759
756 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(expose->window)); 760 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(expose->window));
757 761
758 CairoCachedSurface* surface = theme_provider_->GetSurfaceNamed( 762 CairoCachedSurface* surface = theme_provider_->GetSurfaceNamed(
759 IDR_RESIZE_GRIPPER, gripper); 763 IDR_RESIZE_GRIPPER, gripper);
760 gfx::Point center = gfx::Rect(gripper->allocation).CenterPoint(); 764 gfx::Point center = gfx::Rect(gripper->allocation).CenterPoint();
761 center.Offset(-surface->Width() / 2, -surface->Height() / 2); 765 center.Offset(-surface->Width() / 2, -surface->Height() / 2);
762 surface->SetSource(cr, center.x(), center.y()); 766 surface->SetSource(cr, center.x(), center.y());
763 gdk_cairo_rectangle(cr, &expose->area); 767 gdk_cairo_rectangle(cr, &expose->area);
764 cairo_fill(cr); 768 cairo_fill(cr);
765 769
766 cairo_destroy(cr); 770 cairo_destroy(cr);
767 771
768 return TRUE; 772 return TRUE;
769 } 773 }
770 774
771 // These three signal handlers (EnterNotify, LeaveNotify, and ButtonRelease) 775 // These three signal handlers (EnterNotify, LeaveNotify, and ButtonRelease)
772 // are used to give the gripper the resize cursor. Since it doesn't have its 776 // are used to give the gripper the resize cursor. Since it doesn't have its
773 // own window, we have to set the cursor whenever the pointer moves into the 777 // own window, we have to set the cursor whenever the pointer moves into the
774 // button or leaves the button, and be sure to leave it on when the user is 778 // button or leaves the button, and be sure to leave it on when the user is
775 // dragging. 779 // dragging.
776 gboolean BrowserActionsToolbarGtk::OnGripperEnterNotify( 780 gboolean BrowserActionsToolbarGtk::OnGripperEnterNotify(
777 GtkWidget* gripper, GdkEventCrossing* event) { 781 GtkWidget* gripper, GdkEventCrossing* event) {
778 gdk_window_set_cursor(gripper->window, 782 gdk_window_set_cursor(gripper->window,
779 gtk_util::GetCursor(GDK_SB_H_DOUBLE_ARROW)); 783 gtk_util::GetCursor(GDK_SB_H_DOUBLE_ARROW));
784 draw_gripper_ = true;
sky 2010/07/01 16:40:14 How come you don't queue_draw here and @ 793?
Evan Stade 2010/07/01 17:35:08 GtkButtons already queue_draw when the mouse enter
785
780 return FALSE; 786 return FALSE;
781 } 787 }
782 788
783 gboolean BrowserActionsToolbarGtk::OnGripperLeaveNotify( 789 gboolean BrowserActionsToolbarGtk::OnGripperLeaveNotify(
784 GtkWidget* gripper, GdkEventCrossing* event) { 790 GtkWidget* gripper, GdkEventCrossing* event) {
785 if (!(event->state & GDK_BUTTON1_MASK)) 791 if (!(event->state & GDK_BUTTON1_MASK)) {
786 gdk_window_set_cursor(gripper->window, NULL); 792 gdk_window_set_cursor(gripper->window, NULL);
793 draw_gripper_ = false;
794 }
795
787 return FALSE; 796 return FALSE;
788 } 797 }
789 798
790 gboolean BrowserActionsToolbarGtk::OnGripperButtonRelease( 799 gboolean BrowserActionsToolbarGtk::OnGripperButtonRelease(
791 GtkWidget* gripper, GdkEventButton* event) { 800 GtkWidget* gripper, GdkEventButton* event) {
792 gfx::Rect gripper_rect(0, 0, 801 gfx::Rect gripper_rect(0, 0,
793 gripper->allocation.width, gripper->allocation.height); 802 gripper->allocation.width, gripper->allocation.height);
794 gfx::Point release_point(event->x, event->y); 803 gfx::Point release_point(event->x, event->y);
795 if (!gripper_rect.Contains(release_point)) 804 if (!gripper_rect.Contains(release_point)) {
796 gdk_window_set_cursor(gripper->window, NULL); 805 gdk_window_set_cursor(gripper->window, NULL);
806 draw_gripper_ = false;
807 gtk_widget_queue_draw(gripper);
808 }
797 809
798 // After the user resizes the toolbar, we want to smartly resize it to be 810 // After the user resizes the toolbar, we want to smartly resize it to be
799 // the perfect size to fit the buttons. 811 // the perfect size to fit the buttons.
800 int visible_icon_count = 812 int visible_icon_count =
801 gtk_chrome_shrinkable_hbox_get_visible_child_count( 813 gtk_chrome_shrinkable_hbox_get_visible_child_count(
802 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); 814 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get()));
803 AnimateToShowNIcons(visible_icon_count); 815 AnimateToShowNIcons(visible_icon_count);
804 model_->SetVisibleIconCount(visible_icon_count); 816 model_->SetVisibleIconCount(visible_icon_count);
805 817
806 return FALSE; 818 return FALSE;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 } 887 }
876 888
877 it->second.get()->GetContextMenu()->PopupAsContext(event->time); 889 it->second.get()->GetContextMenu()->PopupAsContext(event->time);
878 return TRUE; 890 return TRUE;
879 } 891 }
880 892
881 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 893 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
882 if (!resize_animation_.is_animating()) 894 if (!resize_animation_.is_animating())
883 UpdateChevronVisibility(); 895 UpdateChevronVisibility();
884 } 896 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698