Browse Source

scroll_to hopefully working 100% now.

merge-requests/365/head
eidheim 11 years ago
parent
commit
2161c9ce09
  1. 5
      juci/notebook.cc
  2. 14
      juci/source.cc
  3. 4
      juci/source.h

5
juci/notebook.cc

@ -82,6 +82,11 @@ void Notebook::Controller::CreateKeybindings() {
open_file(location.first);
CurrentSourceView()->get_buffer()->place_cursor(CurrentSourceView()->get_buffer()->get_iter_at_offset(location.second));
CurrentSourceView()->scroll_to(CurrentSourceView()->get_buffer()->get_insert(), 0.0, 1.0, 0.5);
/*CurrentSourceView()->signal_size_allocate().connect([this](Gtk::Allocation& allocation){
auto adj=scrolled_windows.at(CurrentPage())->get_vadjustment();
cout << adj->get_upper() << ", " << adj->get_page_size() << endl;
});*/
}
}
}

14
juci/source.cc

@ -49,9 +49,15 @@ file_path(file_path), project_path(project_path) {
get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0));
signal_size_allocate().connect([this](Gtk::Allocation& allocation){
if(!user_input_started)
if(!after_user_input)
scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5);
});
signal_event().connect([this](GdkEvent* event){
if(event->type==GDK_KEY_PRESS || event->type==GDK_BUTTON_PRESS || event->type==GDK_SCROLL)
after_user_input=true;
return false;
});
}
string Source::View::get_line(size_t line_number) {
@ -72,7 +78,6 @@ string Source::View::get_line_before_insert() {
//Basic indentation
bool Source::View::on_key_press_event(GdkEventKey* key) {
user_input_started=true;
auto config=Singleton::Config::source();
const std::regex spaces_regex(std::string("^(")+config->tab_char+"*).*$");
//Indent as in next or previous line
@ -151,11 +156,6 @@ bool Source::View::on_key_press_event(GdkEventKey* key) {
return Gsv::View::on_key_press_event(key);
}
bool Source::View::on_button_press_event(GdkEventButton *event) {
user_input_started=true;
return Gsv::View::on_button_press_event(event);
}
/////////////////////////
//// ClangViewParse ///
/////////////////////////

4
juci/source.h

@ -54,11 +54,9 @@ public:
Gtk::TextIter search_start, search_end;
std::function<std::pair<std::string, unsigned>()> get_declaration_location;
bool after_user_input=false;
protected:
bool on_key_press_event(GdkEventKey* key);
bool on_button_press_event(GdkEventButton *event);
private:
bool user_input_started=false;
}; // class View
class GenericView : public View {

Loading…
Cancel
Save