mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Transfer rowpainter.cpp:paintText() to BufferView::draw()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19843 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
55f184563e
commit
a43e822c98
@ -21,6 +21,7 @@
|
|||||||
#include "BufferList.h"
|
#include "BufferList.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "bufferview_funcs.h"
|
#include "bufferview_funcs.h"
|
||||||
|
#include "callback.h" // added for Dispatch functions
|
||||||
#include "CoordCache.h"
|
#include "CoordCache.h"
|
||||||
#include "CutAndPaste.h"
|
#include "CutAndPaste.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -35,25 +36,25 @@
|
|||||||
#include "InsetIterator.h"
|
#include "InsetIterator.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "LaTeXFeatures.h"
|
#include "LaTeXFeatures.h"
|
||||||
#include "callback.h" // added for Dispatch functions
|
|
||||||
#include "LyX.h"
|
#include "LyX.h"
|
||||||
#include "lyxfind.h"
|
#include "lyxfind.h"
|
||||||
#include "LyXFunc.h"
|
#include "LyXFunc.h"
|
||||||
#include "Layout.h"
|
#include "Layout.h"
|
||||||
#include "Text.h"
|
|
||||||
#include "TextClass.h"
|
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "Session.h"
|
#include "MetricsInfo.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
#include "ParIterator.h"
|
#include "ParIterator.h"
|
||||||
|
#include "rowpainter.h"
|
||||||
|
#include "Session.h"
|
||||||
#include "TexRow.h"
|
#include "TexRow.h"
|
||||||
|
#include "Text.h"
|
||||||
|
#include "TextClass.h"
|
||||||
#include "toc.h"
|
#include "toc.h"
|
||||||
#include "Undo.h"
|
#include "Undo.h"
|
||||||
#include "VSpace.h"
|
#include "VSpace.h"
|
||||||
#include "WordLangTuple.h"
|
#include "WordLangTuple.h"
|
||||||
#include "MetricsInfo.h"
|
|
||||||
|
|
||||||
#include "insets/InsetBibtex.h"
|
#include "insets/InsetBibtex.h"
|
||||||
#include "insets/InsetCommand.h" // ChangeRefs
|
#include "insets/InsetCommand.h" // ChangeRefs
|
||||||
@ -63,6 +64,7 @@
|
|||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
#include "frontends/FileDialog.h"
|
#include "frontends/FileDialog.h"
|
||||||
#include "frontends/FontMetrics.h"
|
#include "frontends/FontMetrics.h"
|
||||||
|
#include "frontends/Painter.h"
|
||||||
#include "frontends/Selection.h"
|
#include "frontends/Selection.h"
|
||||||
|
|
||||||
#include "graphics/Previews.h"
|
#include "graphics/Previews.h"
|
||||||
@ -1085,7 +1087,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
//metrics_info_.y1 = ymin of button;
|
//metrics_info_.y1 = ymin of button;
|
||||||
//metrics_info_.y2 = ymax of button;
|
//metrics_info_.y2 = ymax of button;
|
||||||
//
|
//
|
||||||
// Unfortunately, rowpainter.cpp:paintText() does not distinguish
|
// Unfortunately, BufferView::draw() does not distinguish
|
||||||
// between background updates and text updates. So we use the hammer
|
// between background updates and text updates. So we use the hammer
|
||||||
// solution for now. We could also avoid the updateMetrics() below
|
// solution for now. We could also avoid the updateMetrics() below
|
||||||
// by using the first and last pit of the CoordCache. Have a look
|
// by using the first and last pit of the CoordCache. Have a look
|
||||||
@ -1527,4 +1529,49 @@ void BufferView::menuInsertLyXFile(string const & filenm)
|
|||||||
updateMetrics(false);
|
updateMetrics(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BufferView::draw(frontend::Painter & pain)
|
||||||
|
{
|
||||||
|
Text & text = buffer_.text();
|
||||||
|
bool const select = cursor_.selection();
|
||||||
|
|
||||||
|
PainterInfo pi(this, pain);
|
||||||
|
// Should the whole screen, including insets, be refreshed?
|
||||||
|
// FIXME: We should also distinguish DecorationUpdate to avoid text
|
||||||
|
// drawing if possible. This is not possible to do easily right now
|
||||||
|
// because of the single backing pixmap.
|
||||||
|
bool repaintAll = select
|
||||||
|
|| metrics_info_.update_strategy != SingleParUpdate;
|
||||||
|
|
||||||
|
if (repaintAll)
|
||||||
|
// Clear background (if not delegated to rows)
|
||||||
|
pain.fillRectangle(0, metrics_info_.y1, width_,
|
||||||
|
metrics_info_.y2 - metrics_info_.y1, text.backgroundColor());
|
||||||
|
|
||||||
|
if (select)
|
||||||
|
text.drawSelection(pi, 0, 0);
|
||||||
|
|
||||||
|
int yy = metrics_info_.y1;
|
||||||
|
// draw contents
|
||||||
|
for (pit_type pit = metrics_info_.p1; pit <= metrics_info_.p2; ++pit) {
|
||||||
|
ParagraphMetrics const & pm = parMetrics(&text, pit);
|
||||||
|
yy += pm.ascent();
|
||||||
|
paintPar(pi, text, pit, 0, yy, repaintAll);
|
||||||
|
yy += pm.descent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// and grey out above (should not happen later)
|
||||||
|
// lyxerr << "par ascent: " << text.getPar(metrics_info_.p1).ascent() << endl;
|
||||||
|
if (metrics_info_.y1 > 0
|
||||||
|
&& metrics_info_.update_strategy == FullScreenUpdate)
|
||||||
|
pain.fillRectangle(0, 0, width_, metrics_info_.y1, Color::bottomarea);
|
||||||
|
|
||||||
|
// and possibly grey out below
|
||||||
|
// lyxerr << "par descent: " << text.getPar(metrics_info_.p1).ascent() << endl;
|
||||||
|
if (metrics_info_.y2 < height_
|
||||||
|
&& metrics_info_.update_strategy == FullScreenUpdate)
|
||||||
|
pain.fillRectangle(0, metrics_info_.y2, width_,
|
||||||
|
height_ - metrics_info_.y2, Color::bottomarea);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -35,6 +35,8 @@ namespace lyx {
|
|||||||
|
|
||||||
namespace support { class FileName; }
|
namespace support { class FileName; }
|
||||||
|
|
||||||
|
namespace frontend { class Painter; }
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class Change;
|
class Change;
|
||||||
class DocIterator;
|
class DocIterator;
|
||||||
@ -211,6 +213,10 @@ public:
|
|||||||
CoordCache const & coordCache() const {
|
CoordCache const & coordCache() const {
|
||||||
return coord_cache_;
|
return coord_cache_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void draw(frontend::Painter & pain);
|
||||||
|
|
||||||
/// get this view's keyboard map handler.
|
/// get this view's keyboard map handler.
|
||||||
Intl & getIntl() { return *intl_.get(); }
|
Intl & getIntl() { return *intl_.get(); }
|
||||||
///
|
///
|
||||||
|
@ -490,7 +490,7 @@ void GuiWorkArea::updateScreen()
|
|||||||
{
|
{
|
||||||
QLPainter pain(&screen_);
|
QLPainter pain(&screen_);
|
||||||
verticalScrollBar()->show();
|
verticalScrollBar()->show();
|
||||||
paintText(*buffer_view_, pain);
|
buffer_view_->draw(pain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
|||||||
|
|
||||||
QLPainter pain(&screen_);
|
QLPainter pain(&screen_);
|
||||||
buffer_view_->updateMetrics(false);
|
buffer_view_->updateMetrics(false);
|
||||||
paintText(*buffer_view_, pain);
|
buffer_view_->draw(pain);
|
||||||
Font font = buffer_view_->cursor().getFont();
|
Font font = buffer_view_->cursor().getFont();
|
||||||
FontMetrics const & fm = theFontMetrics(font);
|
FontMetrics const & fm = theFontMetrics(font);
|
||||||
int height = fm.maxHeight();
|
int height = fm.maxHeight();
|
||||||
|
@ -950,49 +950,4 @@ void paintPar
|
|||||||
LYXERR(Debug::PAINTING) << "." << endl;
|
LYXERR(Debug::PAINTING) << "." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void paintText(BufferView & bv,
|
|
||||||
Painter & pain)
|
|
||||||
{
|
|
||||||
Buffer const & buffer = bv.buffer();
|
|
||||||
Text & text = buffer.text();
|
|
||||||
bool const select = bv.cursor().selection();
|
|
||||||
ViewMetricsInfo const & vi = bv.viewMetricsInfo();
|
|
||||||
|
|
||||||
PainterInfo pi(const_cast<BufferView *>(&bv), pain);
|
|
||||||
// Should the whole screen, including insets, be refreshed?
|
|
||||||
// FIXME: We should also distinguish DecorationUpdate to avoid text
|
|
||||||
// drawing if possible. This is not possible to do easily right now
|
|
||||||
// because of the single backing pixmap.
|
|
||||||
bool repaintAll = select || vi.update_strategy != SingleParUpdate;
|
|
||||||
|
|
||||||
if (repaintAll) {
|
|
||||||
// Clear background (if not delegated to rows)
|
|
||||||
pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
|
|
||||||
text.backgroundColor());
|
|
||||||
}
|
|
||||||
if (select) {
|
|
||||||
text.drawSelection(pi, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int yy = vi.y1;
|
|
||||||
// draw contents
|
|
||||||
for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
|
|
||||||
ParagraphMetrics const & pm = bv.parMetrics(&text, pit);
|
|
||||||
yy += pm.ascent();
|
|
||||||
paintPar(pi, text, pit, 0, yy, repaintAll);
|
|
||||||
yy += pm.descent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// and grey out above (should not happen later)
|
|
||||||
// lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
|
|
||||||
if (vi.y1 > 0 && vi.update_strategy == FullScreenUpdate)
|
|
||||||
pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, Color::bottomarea);
|
|
||||||
|
|
||||||
// and possibly grey out below
|
|
||||||
// lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
|
|
||||||
if (vi.y2 < bv.workHeight() && vi.update_strategy == FullScreenUpdate)
|
|
||||||
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, Color::bottomarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -25,9 +25,6 @@ class ViewMetricsInfo;
|
|||||||
|
|
||||||
namespace frontend { class Painter; }
|
namespace frontend { class Painter; }
|
||||||
|
|
||||||
/// paint visible paragraph of main text
|
|
||||||
void paintText(BufferView & bv, frontend::Painter & painter);
|
|
||||||
|
|
||||||
/// paint paragraph.
|
/// paint paragraph.
|
||||||
void paintPar
|
void paintPar
|
||||||
(PainterInfo & pi, Text const & text, pit_type pit, int x, int y,
|
(PainterInfo & pi, Text const & text, pit_type pit, int x, int y,
|
||||||
|
Loading…
Reference in New Issue
Block a user