mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
refactor topCursorVisible() prototype a little. Compile fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4378 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9699643848
commit
021ad027a9
@ -233,7 +233,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
||||
updateScreen();
|
||||
updateScrollbar();
|
||||
}
|
||||
bv_->text->first_y = screen().topCursorVisible(bv_->text);
|
||||
bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
|
||||
owner_->updateMenubar();
|
||||
owner_->updateToolbar();
|
||||
// Similarly, buffer-dependent dialogs should be updated or
|
||||
@ -390,7 +390,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
||||
bv_->theLockingInset(the_locking_inset);
|
||||
}
|
||||
|
||||
bv_->text->first_y = screen().topCursorVisible(bv_->text);
|
||||
bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
|
||||
|
||||
// this will scroll the screen such that the cursor becomes visible
|
||||
updateScrollbar();
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* BufferView_pimpl.C: topCursorVisible
|
||||
prototype change
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* screen.h:
|
||||
* screen.C: change topCursorVisible() prototype
|
||||
|
||||
2002-06-12 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* font_metrics.h: remove trailing semi-colon after the brace closing
|
||||
|
@ -395,38 +395,39 @@ void LScreen::cursorToggle(BufferView * bv) const
|
||||
|
||||
|
||||
/* returns a new top so that the cursor is visible */
|
||||
unsigned int LScreen::topCursorVisible(LyXText const * text)
|
||||
unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
|
||||
{
|
||||
int newtop = text->first_y;
|
||||
int const vheight = owner.workHeight();
|
||||
int newtop = top_y;
|
||||
|
||||
Row * row = text->cursor.row();
|
||||
Row * row = cursor.row();
|
||||
|
||||
// Is this a hack? Yes, probably... (Lgb)
|
||||
if (!row)
|
||||
return max(newtop, 0);
|
||||
|
||||
if (text->cursor.y() - row->baseline() + row->height()
|
||||
- text->first_y >= owner.workHeight()) {
|
||||
if (row->height() < owner.workHeight()
|
||||
&& row->height() > owner.workHeight() / 4) {
|
||||
newtop = text->cursor.y()
|
||||
if (cursor.y() - row->baseline() + row->height()
|
||||
- top_y >= vheight) {
|
||||
if (row->height() < vheight
|
||||
&& row->height() > vheight / 4) {
|
||||
newtop = cursor.y()
|
||||
+ row->height()
|
||||
- row->baseline() - owner.workHeight();
|
||||
- row->baseline() - vheight;
|
||||
} else {
|
||||
// scroll down
|
||||
newtop = text->cursor.y()
|
||||
- owner.workHeight() / 2; /* the scroll region must be so big!! */
|
||||
newtop = cursor.y()
|
||||
- vheight / 2; /* the scroll region must be so big!! */
|
||||
}
|
||||
|
||||
} else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
|
||||
text->first_y && text->first_y > 0) {
|
||||
if (row->height() < owner.workHeight()
|
||||
&& row->height() > owner.workHeight() / 4) {
|
||||
newtop = text->cursor.y() - row->baseline();
|
||||
} else if (static_cast<int>(cursor.y() - row->baseline()) <
|
||||
top_y && top_y > 0) {
|
||||
if (row->height() < vheight
|
||||
&& row->height() > vheight / 4) {
|
||||
newtop = cursor.y() - row->baseline();
|
||||
} else {
|
||||
// scroll up
|
||||
newtop = text->cursor.y() - owner.workHeight() / 2;
|
||||
newtop = min(newtop, text->first_y);
|
||||
newtop = cursor.y() - vheight / 2;
|
||||
newtop = min(newtop, top_y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +442,7 @@ unsigned int LScreen::topCursorVisible(LyXText const * text)
|
||||
bool LScreen::fitCursor(LyXText * text, BufferView * bv)
|
||||
{
|
||||
// Is a change necessary?
|
||||
int const newtop = topCursorVisible(text);
|
||||
int const newtop = topCursorVisible(text->cursor, text->first_y);
|
||||
bool const result = (newtop != text->first_y);
|
||||
if (result)
|
||||
draw(text, bv, newtop);
|
||||
|
@ -1,13 +1,12 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of
|
||||
* ======================================================
|
||||
/**
|
||||
* \file screen.h
|
||||
* Copyright 1995-2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2001 The LyX Team
|
||||
*
|
||||
* ====================================================== */
|
||||
* \author unknown
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef LYXSCREEN_H
|
||||
#define LYXSCREEN_H
|
||||
@ -19,16 +18,24 @@
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
class LyXText;
|
||||
class LyXCursor;
|
||||
class WorkArea;
|
||||
class Buffer;
|
||||
class BufferView;
|
||||
|
||||
struct Row;
|
||||
|
||||
/** The class LScreen is used for the main Textbody.
|
||||
Concretely, the screen is held in a pixmap. This pixmap is kept up to
|
||||
date and used to optimize drawing on the screen.
|
||||
This class also handles the drawing of the cursor and partly the selection.
|
||||
/**
|
||||
* LScreen - document rendering management
|
||||
*
|
||||
* This class is used to manage the on-screen rendering inside the
|
||||
* work area; it is responsible for deciding which LyXText rows
|
||||
* need re-drawing.
|
||||
*
|
||||
* This class will arrange for LyXText to paint onto a pixmap
|
||||
* provided by the WorkArea widget.
|
||||
*
|
||||
* The blinking cursor is also handled here.
|
||||
*/
|
||||
class LScreen {
|
||||
public:
|
||||
@ -60,8 +67,17 @@ public:
|
||||
/// Redraws the screen, without using existing pixmap
|
||||
void redraw(LyXText *, BufferView *);
|
||||
|
||||
/// Returns a new top so that the cursor is visible
|
||||
unsigned int topCursorVisible(LyXText const *);
|
||||
/**
|
||||
* topCursorVisible - get a new "top" to make the cursor visible
|
||||
* @param c the cursor
|
||||
* @param top_y the current y location of the containing region
|
||||
*
|
||||
* This helper function calculates a new y co-ordinate for
|
||||
* the top of the containing region such that the cursor contained
|
||||
* within the LyXText is "nicely" visible.
|
||||
*/
|
||||
unsigned int topCursorVisible(LyXCursor const & c, int top_y);
|
||||
|
||||
/// Redraws the screen such that the cursor is visible
|
||||
bool fitCursor(LyXText *, BufferView *);
|
||||
///
|
||||
|
@ -1,3 +1,7 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GraphicsCache.C: use right colormap incantation
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GraphicsCache.C: use lyx_gui namespace
|
||||
|
@ -613,7 +613,7 @@ void mapcolor(char const * c_color, char ** g_color_ptr, char ** m_color_ptr)
|
||||
return;
|
||||
|
||||
Display * display = fl_get_display();
|
||||
Colormap cmap = fl_colormap;
|
||||
Colormap cmap = fl_state[fl_get_vclass()].colormap;
|
||||
XColor xcol;
|
||||
XColor ccol;
|
||||
if (XLookupColor(display, cmap, c_color, &xcol, &ccol) == 0)
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* insettext.C: change of topCursorVisible()
|
||||
prototype
|
||||
|
||||
2002-06-12 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* insettext.h:
|
||||
|
@ -2374,7 +2374,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
|
||||
inset_y = ciy(bv) + drawTextYOffset;
|
||||
}
|
||||
|
||||
t->first_y = bv->screen().topCursorVisible(t);
|
||||
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
|
||||
if (!owner()) {
|
||||
updateLocal(bv, FULL, false);
|
||||
// this will scroll the screen such that the cursor becomes visible
|
||||
@ -2412,7 +2412,7 @@ void InsetText::reinitLyXText() const
|
||||
inset_x = cix(bv) - top_x + drawTextXOffset;
|
||||
inset_y = ciy(bv) + drawTextYOffset;
|
||||
}
|
||||
t->first_y = bv->screen().topCursorVisible(t);
|
||||
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
|
||||
if (!owner()) {
|
||||
updateLocal(bv, FULL, false);
|
||||
// this will scroll the screen such that the cursor becomes visible
|
||||
|
Loading…
Reference in New Issue
Block a user