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

4
juci/source.h

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

Loading…
Cancel
Save