Browse Source

Added slight delay on tooltips when moving cursor.

merge-requests/365/head
eidheim 11 years ago
parent
commit
0aa2b45b37
  1. 41
      juci/source.cc
  2. 4
      juci/source.h

41
juci/source.cc

@ -9,6 +9,10 @@
#include "selectiondialog.h"
#include "singletons.h"
namespace sigc {
SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
}
bool Source::Config::legal_extension(std::string e) const {
std::transform(e.begin(), e.end(),e.begin(), ::tolower);
if (find(extensions.begin(), extensions.end(), e) != extensions.end()) {
@ -422,6 +426,7 @@ void Source::ClangView::update_types() {
}
bool Source::ClangView::clangview_on_motion_notify_event(GdkEventMotion* event) {
on_mark_set_timeout_connection.disconnect();
if(clang_updated) {
Gdk::Rectangle rectangle(event->x, event->y, 1, 1);
diagnostic_tooltips.init();
@ -438,32 +443,36 @@ bool Source::ClangView::clangview_on_motion_notify_event(GdkEventMotion* event)
void Source::ClangView::clangview_on_mark_set(const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark) {
if(mark->get_name()=="insert") {
if(clang_updated) {
Gdk::Rectangle rectangle;
get_iter_location(iterator, rectangle);
int location_window_x, location_window_y;
buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, rectangle.get_x(), rectangle.get_y(), location_window_x, location_window_y);
rectangle.set_x(location_window_x-2);
rectangle.set_y(location_window_y);
rectangle.set_width(4);
diagnostic_tooltips.init();
type_tooltips.show(rectangle);
diagnostic_tooltips.show(rectangle);
}
else {
type_tooltips.hide();
diagnostic_tooltips.hide();
}
on_mark_set_timeout_connection.disconnect();
on_mark_set_timeout_connection=Glib::signal_timeout().connect([this]() {
if(clang_updated) {
Gdk::Rectangle rectangle;
get_iter_location(get_buffer()->get_insert()->get_iter(), rectangle);
int location_window_x, location_window_y;
buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, rectangle.get_x(), rectangle.get_y(), location_window_x, location_window_y);
rectangle.set_x(location_window_x-2);
rectangle.set_y(location_window_y);
rectangle.set_width(4);
diagnostic_tooltips.init();
type_tooltips.show(rectangle);
diagnostic_tooltips.show(rectangle);
}
return false;
}, 500);
type_tooltips.hide();
diagnostic_tooltips.hide();
}
}
bool Source::ClangView::clangview_on_focus_out_event(GdkEventFocus* event) {
on_mark_set_timeout_connection.disconnect();
type_tooltips.hide();
diagnostic_tooltips.hide();
return false;
}
bool Source::ClangView::clangview_on_scroll_event(GdkEventScroll* event) {
on_mark_set_timeout_connection.disconnect();
type_tooltips.hide();
diagnostic_tooltips.hide();
return false;

4
juci/source.h

@ -85,6 +85,7 @@ namespace Source {
public:
ClangView(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal);
~ClangView();
private:
// inits the syntax highligthing on file open
void init_syntax_highlighting(const std::map<std::string, std::string>
&buffers,
@ -101,13 +102,14 @@ namespace Source {
Tooltips type_tooltips;
bool clangview_on_motion_notify_event(GdkEventMotion* event);
void clangview_on_mark_set(const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark);
sigc::connection on_mark_set_timeout_connection;
bool clangview_on_focus_out_event(GdkEventFocus* event);
bool clangview_on_scroll_event(GdkEventScroll* event);
static clang::Index clang_index;
std::map<std::string, std::string> get_buffer_map() const;
std::mutex parsing_mutex;
private:
std::unique_ptr<clang::TranslationUnit> clang_tu;
std::unique_ptr<clang::Tokens> clang_tokens;
bool clang_updated=false;

Loading…
Cancel
Save