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

Unified Diff: chrome/browser/gtk/info_bubble_gtk.h

Issue 316006: GTK: Try to position info bubbles onscreen. (Closed)
Patch Set: merge Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/gtk/info_bubble_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/info_bubble_gtk.h
diff --git a/chrome/browser/gtk/info_bubble_gtk.h b/chrome/browser/gtk/info_bubble_gtk.h
index a92cd3bc8eee2fb6e5bde54b8d9b7c3ec8eef9fe..876cb9ceedb9c07acec6a27acce3e565160540dc 100644
--- a/chrome/browser/gtk/info_bubble_gtk.h
+++ b/chrome/browser/gtk/info_bubble_gtk.h
@@ -72,6 +72,18 @@ class InfoBubbleGtk : public NotificationObserver {
void HandlePointerAndKeyboardUngrabbedByContent();
private:
+ // Where should the arrow be placed relative to the bubble?
+ enum ArrowLocationGtk {
+ // TODO(derat): Support placing arrows on the bottoms of the bubbles.
+ ARROW_LOCATION_TOP_LEFT,
+ ARROW_LOCATION_TOP_RIGHT,
+ };
+
+ enum FrameType {
+ FRAME_MASK,
+ FRAME_STROKE,
+ };
+
explicit InfoBubbleGtk(GtkThemeProvider* provider);
virtual ~InfoBubbleGtk();
@@ -80,6 +92,29 @@ class InfoBubbleGtk : public NotificationObserver {
const gfx::Rect& rect,
GtkWidget* content);
+ // Make the points for our polygon frame, either for fill (the mask), or for
+ // when we stroke the border.
+ static std::vector<GdkPoint> MakeFramePolygonPoints(
+ ArrowLocationGtk arrow_location,
+ int width,
+ int height,
+ FrameType type);
+
+ // Get the location where the arrow should be placed (which is a function of
+ // whether the user's language is LTR/RTL and of the direction that the bubble
+ // should be facing to fit onscreen). |arrow_x| is the X component in screen
+ // coordinates of the point at which the bubble's arrow should be aimed, and
+ // |width| is the bubble's width.
+ static ArrowLocationGtk GetArrowLocation(int arrow_x, int width);
+
+ // Updates |arrow_location_| based on the toplevel window's current position
+ // and the bubble's size. If the location changes, moves and reshapes the
+ // window and returns true.
+ bool UpdateArrowLocation();
+
+ // Reshapes the window and updates |mask_region_|.
+ void UpdateWindowShape();
+
// Calculate the current screen position for the bubble's window (per
// |toplevel_window_|'s position as of its most-recent ConfigureNotify event
// and |rect_|) and move it there.
@@ -108,6 +143,13 @@ class InfoBubbleGtk : public NotificationObserver {
}
gboolean HandleEscape();
+ static gboolean HandleExposeThunk(GtkWidget* widget,
+ GdkEventExpose* event,
+ gpointer user_data) {
+ return reinterpret_cast<InfoBubbleGtk*>(user_data)->HandleExpose();
+ }
+ gboolean HandleExpose();
+
static void HandleSizeAllocateThunk(GtkWidget* widget,
GtkAllocation* allocation,
gpointer user_data) {
@@ -176,6 +218,9 @@ class InfoBubbleGtk : public NotificationObserver {
// not).
GdkRegion* mask_region_;
+ // Where should the arrow be drawn relative to the bubble?
+ ArrowLocationGtk arrow_location_;
+
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(InfoBubbleGtk);
« no previous file with comments | « no previous file | chrome/browser/gtk/info_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698