Browse Source

Dialog and tooltip placement corrections

merge-requests/365/head
eidheim 10 years ago committed by Ole Christian Eidheim
parent
commit
4771ef0d0d
  1. 10
      src/selectiondialog.cc
  2. 17
      src/tooltips.cc

10
src/selectiondialog.cc

@ -131,10 +131,12 @@ void SelectionDialogBase::hide() {
} }
void SelectionDialogBase::move() { void SelectionDialogBase::move() {
Gdk::Rectangle rectangle; Gdk::Rectangle iter_rect;
text_view.get_iter_location(start_mark->get_iter(), rectangle); text_view.get_iter_location(start_mark->get_iter(), iter_rect);
int buffer_x=rectangle.get_x(); Gdk::Rectangle visible_rect;
int buffer_y=rectangle.get_y()+rectangle.get_height(); text_view.get_visible_rect(visible_rect);
int buffer_x=std::max(iter_rect.get_x(), visible_rect.get_x());
int buffer_y=iter_rect.get_y()+iter_rect.get_height();
int window_x, window_y; int window_x, window_y;
text_view.buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, buffer_x, buffer_y, window_x, window_y); text_view.buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, buffer_x, buffer_y, window_x, window_y);
int root_x, root_y; int root_x, root_y;

17
src/tooltips.cc

@ -37,6 +37,12 @@ void Tooltip::update() {
activation_rectangle.join(rectangle); activation_rectangle.join(rectangle);
} }
} }
//Correct if activation_rectangle is left of text_view
Gdk::Rectangle visible_rect;
text_view.get_visible_rect(visible_rect);
activation_rectangle.set_x(std::max(activation_rectangle.get_x(), visible_rect.get_x()));
int location_window_x, location_window_y; int location_window_x, location_window_y;
text_view.buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, activation_rectangle.get_x(), activation_rectangle.get_y(), location_window_x, location_window_y); text_view.buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, activation_rectangle.get_x(), activation_rectangle.get_y(), location_window_x, location_window_y);
activation_rectangle.set_x(location_window_x); activation_rectangle.set_x(location_window_x);
@ -80,14 +86,19 @@ void Tooltip::adjust(bool disregard_drawn) {
text_view.get_window(Gtk::TextWindowType::TEXT_WINDOW_TEXT)->get_root_coords(activation_rectangle.get_x(), activation_rectangle.get_y(), root_x, root_y); text_view.get_window(Gtk::TextWindowType::TEXT_WINDOW_TEXT)->get_root_coords(activation_rectangle.get_x(), activation_rectangle.get_y(), root_x, root_y);
Gdk::Rectangle rectangle; Gdk::Rectangle rectangle;
rectangle.set_x(root_x); rectangle.set_x(root_x);
rectangle.set_y(root_y-tooltip_height); rectangle.set_y(std::max(0, root_y-tooltip_height));
rectangle.set_width(tooltip_width); rectangle.set_width(tooltip_width);
rectangle.set_height(tooltip_height); rectangle.set_height(tooltip_height);
if(!disregard_drawn) { if(!disregard_drawn) {
if(Tooltips::drawn_tooltips_rectangle.get_width()!=0) { if(Tooltips::drawn_tooltips_rectangle.get_width()!=0) {
if(rectangle.intersects(Tooltips::drawn_tooltips_rectangle)) if(rectangle.intersects(Tooltips::drawn_tooltips_rectangle)) {
rectangle.set_y(Tooltips::drawn_tooltips_rectangle.get_y()-tooltip_height); int new_y=Tooltips::drawn_tooltips_rectangle.get_y()-tooltip_height;
if(new_y>=0)
rectangle.set_y(new_y);
else
rectangle.set_x(Tooltips::drawn_tooltips_rectangle.get_x()+Tooltips::drawn_tooltips_rectangle.get_width());
}
Tooltips::drawn_tooltips_rectangle.join(rectangle); Tooltips::drawn_tooltips_rectangle.join(rectangle);
} }
else else

Loading…
Cancel
Save