void BufferView::Pimpl::updateScrollbar()
{
- /* If the text is smaller than the working area, the scrollbar
- * maximum must be the working area height. No scrolling will
- * be possible */
if (!bv_->text) {
+ lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
workarea_.setScrollbar(0, 1.0);
return;
}
long const text_height = bv_->text->height;
long const work_height = workarea_.height();
- if (text_height <= work_height) {
- workarea_.setScrollbarBounds(0.0, 0.0);
- current_scrollbar_value = bv_->text->first_y;
- workarea_.setScrollbar(current_scrollbar_value, 1.0);
- return;
- }
-
double const lineh = bv_->text->defaultHeight();
double const slider_size =
(text_height == 0) ? 1.0 : 1.0 / double(text_height);
- static long old_text_height;
- static double old_lineh;
- static double old_slider_size;
+ lyxerr[Debug::GUI] << "text_height now " << text_height << endl;
+ lyxerr[Debug::GUI] << "work_height " << work_height << endl;
- if (text_height != old_text_height) {
- workarea_.setScrollbarBounds(0.0,
- text_height - work_height);
- old_text_height = text_height;
- }
- if (lineh != old_lineh) {
- workarea_.setScrollbarIncrements(lineh);
- old_lineh = lineh;
- }
- if (current_scrollbar_value != bv_->text->first_y
- || slider_size != old_slider_size) {
+ /* If the text is smaller than the working area, the scrollbar
+ * maximum must be the working area height. No scrolling will
+ * be possible */
+ if (text_height <= work_height) {
+ lyxerr[Debug::GUI] << "doc smaller than workarea !" << endl;
+ workarea_.setScrollbarBounds(0.0, 0.0);
current_scrollbar_value = bv_->text->first_y;
- workarea_.setScrollbar(current_scrollbar_value, slider_size);
- old_slider_size = slider_size;
+ workarea_.setScrollbar(current_scrollbar_value, 1.0);
+ return;
}
+
+ workarea_.setScrollbarBounds(0.0, text_height - work_height);
+ workarea_.setScrollbarIncrements(lineh);
+ current_scrollbar_value = bv_->text->first_y;
+ workarea_.setScrollbar(current_scrollbar_value, slider_size);
}
// Callback for scrollbar slider
void BufferView::Pimpl::scrollCB(double value)
{
+ lyxerr[Debug::GUI] << "scrollCB of " << value << endl;
+
if (!buffer_) return;
current_scrollbar_value = long(value);
paste_internally = true;
}
+ int const screen_first = bv_->text->first_y;
+
if (bv_->theLockingInset()) {
// We are in inset locking mode
selection_possible = true;
screen_->hideCursor();
- int const screen_first = bv_->text->first_y;
-
// Clear the selection
screen_->toggleSelection(bv_->text, bv_);
bv_->text->clearSelection();
selection_possible = false;
owner_->updateLayoutChoice();
owner_->message(inset->editMessage());
- // IMO the inset has to be first in edit-mode and then we send the
- // button press. (Jug 20020222)
- inset->edit(bv_); //, xpos, ypos, button);
+ //inset->edit(bv_, xpos, ypos, button);
+ // We just have to lock the inset before calling a PressEvent on it!
+ // we don't need the edit() call here! (Jug20020329)
+ if (!bv_->lockInset(inset)) {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ }
inset->insetButtonPress(bv_, xpos, ypos, button);
return;
}
+ // I'm not sure we should continue here if we hit an inset (Jug20020403)
// Right click on a footnote flag opens float menu
if (button == 3) {
inset->insetButtonRelease(bv_, x, y, button);
} else {
inset_hit->insetButtonRelease(bv_, x, y, button);
+ // IMO this is a grosshack! Inset's should be changed so that
+ // they call the actions they have to do with the insetButtonRel.
+ // function and not in the edit(). This should be changed
+ // (Jug 20020329)
inset_hit->edit(bv_, x, y, button);
}
return;
x -= b.x1;
// The origin of an inset is on the baseline
- y -= (text.cursor.y());
+ y -= text.cursor.iy();
return inset;
}