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

Side by Side Diff: chrome/browser/ui/gtk/bubble/bubble_gtk.cc

Issue 10918275: [gtk] website settings bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: slightly simpler drawing Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/bubble/bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h"
(...skipping 17 matching lines...) Expand all
28 // window. 28 // window.
29 const int kArrowX = 18; 29 const int kArrowX = 18;
30 30
31 // Number of pixels between the tip of the arrow and the region we're 31 // Number of pixels between the tip of the arrow and the region we're
32 // pointing to. 32 // pointing to.
33 const int kArrowToContentPadding = -4; 33 const int kArrowToContentPadding = -4;
34 34
35 // We draw flat diagonal corners, each corner is an NxN square. 35 // We draw flat diagonal corners, each corner is an NxN square.
36 const int kCornerSize = 3; 36 const int kCornerSize = 3;
37 37
38 // Margins around the content.
39 const int kTopMargin = kArrowSize + kCornerSize - 1;
40 const int kBottomMargin = kCornerSize - 1;
41 const int kLeftMargin = kCornerSize - 1;
42 const int kRightMargin = kCornerSize - 1;
43
44 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); 38 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff);
45 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63); 39 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63);
46 40
47 // Helper functions that encapsulate arrow locations. 41 // Helper functions that encapsulate arrow locations.
48 bool HasArrow(BubbleGtk::ArrowLocationGtk location) { 42 bool HasArrow(BubbleGtk::ArrowLocationGtk location) {
49 return location != BubbleGtk::ARROW_LOCATION_NONE && 43 return location != BubbleGtk::ARROW_LOCATION_NONE &&
50 location != BubbleGtk::ARROW_LOCATION_FLOAT; 44 location != BubbleGtk::ARROW_LOCATION_FLOAT;
51 } 45 }
52 46
53 bool IsArrowLeft(BubbleGtk::ArrowLocationGtk location) { 47 bool IsArrowLeft(BubbleGtk::ArrowLocationGtk location) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 i->modifier_type, 148 i->modifier_type,
155 GtkAccelFlags(0), 149 GtkAccelFlags(0),
156 g_cclosure_new(G_CALLBACK(&OnGtkAcceleratorThunk), 150 g_cclosure_new(G_CALLBACK(&OnGtkAcceleratorThunk),
157 this, 151 this,
158 NULL)); 152 NULL));
159 } 153 }
160 154
161 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group_); 155 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group_);
162 156
163 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 157 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
164 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 158 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), kArrowSize, 0, 0, 0);
165 kTopMargin, kBottomMargin,
166 kLeftMargin, kRightMargin);
167 159
168 gtk_container_add(GTK_CONTAINER(alignment), content); 160 gtk_container_add(GTK_CONTAINER(alignment), content);
169 gtk_container_add(GTK_CONTAINER(window_), alignment); 161 gtk_container_add(GTK_CONTAINER(window_), alignment);
170 162
171 // GtkWidget only exposes the bitmap mask interface. Use GDK to more 163 // GtkWidget only exposes the bitmap mask interface. Use GDK to more
172 // efficently mask a GdkRegion. Make sure the window is realized during 164 // efficently mask a GdkRegion. Make sure the window is realized during
173 // OnSizeAllocate, so the mask can be applied to the GdkWindow. 165 // OnSizeAllocate, so the mask can be applied to the GdkWindow.
174 gtk_widget_realize(window_); 166 gtk_widget_realize(window_);
175 167
176 UpdateArrowLocation(true); // Force move and reshape. 168 UpdateArrowLocation(true); // Force move and reshape.
177 StackWindow(); 169 StackWindow();
178 170
179 gtk_widget_add_events(window_, GDK_BUTTON_PRESS_MASK); 171 gtk_widget_add_events(window_, GDK_BUTTON_PRESS_MASK);
180 172
181 signals_.Connect(window_, "expose-event", G_CALLBACK(OnExposeThunk), this); 173 // Connect during the bubbling phase so the border is always on top.
174 signals_.ConnectAfter(window_, "expose-event",
175 G_CALLBACK(OnExposeThunk), this);
182 signals_.Connect(window_, "size-allocate", G_CALLBACK(OnSizeAllocateThunk), 176 signals_.Connect(window_, "size-allocate", G_CALLBACK(OnSizeAllocateThunk),
183 this); 177 this);
184 signals_.Connect(window_, "button-press-event", 178 signals_.Connect(window_, "button-press-event",
185 G_CALLBACK(OnButtonPressThunk), this); 179 G_CALLBACK(OnButtonPressThunk), this);
186 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this); 180 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this);
187 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this); 181 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this);
188 182
189 // If the toplevel window is being used as the anchor, then the signals below 183 // If the toplevel window is being used as the anchor, then the signals below
190 // are enough to keep us positioned correctly. 184 // are enough to keep us positioned correctly.
191 if (anchor_widget_ != toplevel_window_) { 185 if (anchor_widget_ != toplevel_window_) {
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { 661 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) {
668 Close(); 662 Close();
669 return FALSE; 663 return FALSE;
670 } 664 }
671 665
672 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, 666 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget,
673 GtkAllocation* allocation) { 667 GtkAllocation* allocation) {
674 if (!UpdateArrowLocation(false)) 668 if (!UpdateArrowLocation(false))
675 MoveWindow(); 669 MoveWindow();
676 } 670 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.cc ('k') | chrome/browser/ui/gtk/content_setting_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698