Commit Graph

62 Commits

Author SHA1 Message Date
Juergen Spitzmueller
2f2102d0ba Paint nospell mark lower than foeign mark, since these can appear both
Also, assure that misspelled mark is not shown when nospellcheck()
2018-05-07 08:41:28 +02:00
Juergen Spitzmueller
57dc817581 Add \nospellcheck font property
This revives a ten year old idea (and patch) by Dov.

You can now mark in the character dialog text and exclude it from spell
checking.

Fixes: #1042

File format change

Remaining issue: The instant spell checking marks are not immediately
removed, but only after some editing.
2018-05-06 19:48:21 +02:00
Juergen Spitzmueller
9987adb2a7 Revert "Mark follow-up paragraphs in a paragraph group as nested."
This reverts commit 761a542551.
2018-02-08 17:00:41 +01:00
Jean-Marc Lasgouttes
76a8ca27a7 Set endlabel color correctly when there is a selection
Current code would change the color of static endlabel when the
_start_ of line is selected. This is only used with hollywood and
broadway layouts, though.

Change the box endlabel painting code to use Color_selectiontext as needed.

Follow-up to bug #10972.
2018-01-16 14:10:30 +01:00
Juergen Spitzmueller
da57a6135e Amend 761a542551 once more.
As it is designed now, Static label is the only case that makes sense.
2018-01-03 08:55:35 +01:00
Juergen Spitzmueller
55349823f0 Limit 761a542551 to the case where we have a label. 2018-01-02 18:05:43 +01:00
Juergen Spitzmueller
761a542551 Mark follow-up paragraphs in a paragraph group as nested.
This gives a more consistent indication of what belongs to an environment
(and semantically, such paragraphs are synonymous to nested standard
paragraphs)

Addresses part of #9261.
2017-12-31 10:37:35 +01:00
Jean-Marc Lasgouttes
8eb736b23b Remove duplicate variable
Fixes bug #10922
2017-12-14 16:03:30 +01:00
Jean-Marc Lasgouttes
4858bb3bb6 Store change bar information in row element
It is wrong to compute this at paint time. In general, painting a row
should not require any access to a paragraph object, but we are far
from there now.
2017-11-11 13:24:08 +01:00
Jean-Marc Lasgouttes
efc7359015 three-stage drawing: add a nodraw stage
Normally the two stages of drawing are
1/ compute metrics of insets/rows/paragraphs/mathrow...
2/ draw the elements and cache their positions

Now the three stages are
1/ metrics
2/ nodraw: do not draw the elements, but cache their position
3/ draw the elements (and store again their position; it does not
   seems to hurt performance).

Revive the NullPainter: this replaces the setDrawingEnabled mechanism
with a painter that does nothing. The advantage is that updatePosCache
(renamed from setPosCache) does not need anymore to be invoked from
the frontend.

updatePosCache (the nodraw stage) is called at the end of
BufferView::updateMetrics.
2017-08-29 16:37:07 +02:00
Richard Heck
75bfed5507 Fix trailing whitespace in cpp files. 2017-07-03 13:53:14 -04:00
Jean-Marc Lasgouttes
71563835c7 Avoid rounding issue when painting selection
This is the same issue that was addressed in the all_sel case at
695b0cc3. The rounding issue only happens at specific zoom and
jusification values.

Fixes part of #8883.
2017-06-12 14:39:03 +02:00
Jean-Marc Lasgouttes
57c3a94730 Add RtL information to Row
This allows to somewhat simplify the text and avoid some uses of
Paragraph (in the long term, RowPainter should not have to access
these things).

At the same time do a small cleanup to RowPainter: rename
text_metrics_ to tm_, remove pm_ and width_.
2017-02-02 14:53:01 +01:00
Jean-Marc Lasgouttes
75fce32556 Round values properly when drawing right margin selection
This fixes a compiler warning reported by Uwe.
2016-11-04 15:58:54 +01:00
Jean-Marc Lasgouttes
695b0cc33b Some tweaks to selection painting
1/ simplify logic that triggers margin selection painting

2/ fix logic for end of paragraph markers. They are now selected when
   there is an end row margin selection.

3/ avoid rounding problems due to int/double conversions.
2016-10-26 14:27:57 +02:00
Jean-Marc Lasgouttes
4159cf97c1 Fix compiler warnings spotted by Uwe 2016-10-26 10:52:55 +02:00
Jean-Marc Lasgouttes
2037cc5ef5 Fixup a700d657 : holes in right margin selection 2016-10-25 16:17:21 +02:00
Jean-Marc Lasgouttes
a700d657b3 Reimplement RowPainter::paintSelection() using row elements
The code is much simpler now and can be actually understood.

As a byproduct, fix bug #10424.
2016-10-25 10:01:37 +02:00
Jean-Marc Lasgouttes
07c7dae367 Move correctly the end of proof marker when row is large
This was a regression from 2.1.x in LtR mode, and it never worked correctly in RtL mode.

Fixes bug #10344.
2016-08-23 17:45:21 +02:00
Jean-Marc Lasgouttes
c73923c519 When painting only insets, paint also change and language marks
Fixes bug #8133.
2016-07-20 23:25:17 +02:00
Jean-Marc Lasgouttes
9940acc506 Try to fix #4889 in the right way
For reference, the bug was that quote insets grew bolder because, when
painted over themselves, anti-aliasing made them darker.

It turned out that the fix there created others than were
painstakingly fixed: #7164, #7165, #7174, #7193... More recently, it
created other problems:
http://article.gmane.org/gmane.editors.lyx.devel/163471

We use the right fix here:
* draw background of quote inset when not doing full repaint
* draw background of math macro template when not doing full repaint
* remove hack that grew from #4889 fix.
2016-07-20 00:24:24 +02:00
Stephan Witt
6c4f30b193 Add missing include for abs(int) 2016-07-04 20:36:16 +02:00
Richard Heck
bc1672f6a0 Squash some warnings. 2016-07-02 14:12:49 -04:00
Richard Heck
499fc04c9a Use const &. 2016-06-29 12:51:55 -04:00
Guillaume Munch
760bca8265 Change tracking cue: paint over labels in text and prepare for further work
* Inset::canTrackChange() had two meanings: can it deal with change tracking?
  Will it paint its own CT status? The latter information is now given by
  Inset::canPaintChange().

* Line thickness computation is moved from RowPainter to MetricsBase.

* Painting function for Changes moved to lyx::Change. (One new, that strikes
  diagonally.)
2016-06-13 08:46:15 +01:00
Jean-Marc Lasgouttes
e39e4cf96b Do not require an extra pit parameter when a row is available
Now that Row has a pit() member, it is possible to use it instead of passing an extra pit_type parameter to a function which already has access to a Row.
2016-05-30 14:55:41 +02:00
Jean-Marc Lasgouttes
4c19c5149d RowPainter const cleanup
Change the various paint* helpers to take a single row element as argument.

Do not update x_ in the various paint* helpers. Constify them. Update x_ in paintText and paintOnlyInsets instead.

Remove an empty call to paintForeignMark in paintInset (the call did nothing since orig_x == x_ at this point).
2016-05-30 14:55:41 +02:00
Jean-Marc Lasgouttes
598f7e4a45 Cleanup Painter text() API
* remove optional arguments to the helpers that use a FontInfo
* add a textwidth argument to the text() methods that are used by rowpainter.

Now textwidth is only computed if a null value was passed to the
text() method. This means that in the use case of rowpainter, no
textwidth needs to be computed.
2016-05-30 14:55:41 +02:00
Jean-Marc Lasgouttes
77ef48d093 Only add inset postion to cache in paintInset
It was also added in paintText and paintOnlyInsets.
2016-05-30 14:55:41 +02:00
Jean-Marc Lasgouttes
5792606ff9 Directly pass a Row::Element to RowPainter::paintInset 2016-05-29 17:55:45 -04:00
Jean-Marc Lasgouttes
f3cdf74e68 Remember the last used QTextLayout object
This crude caching mecanism is useful in the particular case of a screen with many misspelling dotted lines. In this case, it is necessary to build a QTextLayout in order to know where to put the start/end of the spell line. Since rows typically contains text snippets longer than a word, we may be in a situation where the same QTextLayout is constructed repeatedly.

This commit is useful in this particular use case, and should not be costly in other cases. A better fix would be to remember the QTextLayout associated to each row element. This is a bit more work, so this fix should be sufficient for now.

Additionally, do not paint misspelled marks when painting is disabled.

Fixes bug #9890.
2015-12-09 11:57:52 +01:00
Jean-Marc Lasgouttes
1546b91f27 Make spellchecker dotted underlines thicker. 2015-12-02 21:49:54 +01:00
Jean-Marc Lasgouttes
febbcf7f6c Fix painting of selection with change tracking
When partially selecting an element, the selected text color was not
the same as when selecting it completely.

Fixes bug #9809.
2015-10-28 10:40:10 +01:00
Jean-Marc Lasgouttes
26eb5092fb Get rid of ParagraphMetrics::insetDimension
We already have a CoordCache of insets dimensions. It is not necessary
to store the same information in two places.

Give a name to CoordCache tables types to improve code readability.

Remove ParagraphMetrics::singleWidth, which is not used anymore.
2015-10-19 13:17:16 +02:00
Jean-Marc Lasgouttes
44acd4a3cb Remove variable y_top that was computed but not used. 2015-10-12 11:55:38 +02:00
Jean-Marc Lasgouttes
8b89709fc9 New helper method Row::Element::isRTL() 2015-09-21 14:03:54 +02:00
Jean-Marc Lasgouttes
4ede231ef1 Fix continuous spell checking
The extra check became useless after 4796e6b3, but its presence only
broke continuous spell checking after f65f3adb.
2015-08-26 14:01:45 +02:00
Jean-Marc Lasgouttes
371bd2b1e5 Get rid of SEPARATOR row element type
It is not used anymore.

Also get rid of a comment made irrelevant by recent changes.
2015-07-21 09:51:52 +02:00
Jean-Marc Lasgouttes
b68f391232 Re-implement text justification
* GuiFontMetrics::pos2x, x2pos: add support for inter-word spacing.
* GuiPainter::text: idem

* Row::Element::countSeparators:
  Row::countSeparators: new methods that count spaces in strings.
  Row::setSeparatorExtraWidth: new method (code lifted from TextMetrics.cpp).

* TextMetrics::computeRowMetrics: rely on the above methods.

* RowPainter::paintMispelledMarked: pass only a Row::Element object reference
  RowPainter::paintStringAndSel: idem; do not rely on values returned by
      Painter::text (trailing spaces do not honor wordspacing value).
2015-07-20 23:43:05 +02:00
Jean-Marc Lasgouttes
038f003be6 Rewrite RowPainter::paintOnlyInsets to use row elements 2015-07-18 20:37:53 +02:00
Jean-Marc Lasgouttes
412a724aaf Some fixups to row margins
In breakRow set left and right margin properly for RTL paragraphs.
Remove corresponding code from ComputeRowMetrics.

In row painter, check the use of left and right margin depending on
context. The problem in the original text is that the various
leftMargin() methods actually represent right margin for RTL
paragraphs. This should be fixed eventually.
2015-07-18 00:17:00 +02:00
Jean-Marc Lasgouttes
f750d9b5cf Remove old cruft
There are many things that are not necessary anymore:

* remove methods paintText2, paintFromPos, leftMargin, paintInlineCompletion

* Remove use of Bidi class.

* add a Font and a Change parameter to paintInset.

Also remove a comment that describes what we have just done.
2015-07-16 23:56:24 +02:00
Jean-Marc Lasgouttes
83afe2e547 Rely on Row elements to draw rows.
The new version of paintText is quite short. Elements are treated one
by one. They are already in the right ordering.

The other changes are:

* a new paintChange method is added (using code lifted from old version)

* in paintLast, the support for end of paragraph markers is removed
  (this is already part of the Row object.
2015-07-16 23:24:45 +02:00
Jean-Marc Lasgouttes
1de0d2a19b Code cleanup in RowPainter
* move some code that handle selection to paintInset()

* change the arguments of paintSeparator()
2015-07-16 23:24:28 +02:00
Jean-Marc Lasgouttes
6c8520f100 Rename paintTextAndSel to paintStringAndSel 2015-07-15 22:47:47 +02:00
Jean-Marc Lasgouttes
cb0dbfdadb Avoid crash when inserting space in the middle of misspelled character
This is a fixup to commit 4796e6b3.
2015-07-15 20:38:07 +02:00
Jean-Marc Lasgouttes
4796e6b337 Avoid breaking kerning with continuous spell checking
There is a mismatch between the way text is tokenized in Row objects
and the way it is shown on screen. When metrics are computed,
continuous spell checking has not been done yet. Yet, the row painter
explicitly breaks words at spell status boundaries. This creates
problem with a text like "PMP," (see bug #9649), where there is a
negative kerning before the comma.

This is solved by not taking in account spell status when drawing
text, and drawing spell underlines separately.

* replace Paragraph::isSameSpellRange with new method getSpellRange.

* merge RowPainter::paintChars into RowPainter::paintFromPos

* move the actual text painting code into the new paintTextAndSel.

* merge some code from paintFromPos to paintMisspelledMark

* in paintMisspelledMark, scan the string which needs to be annotated
  and add dashed line below text marked as misspelled.

Fixes bug #9649.
2015-07-15 12:13:24 +02:00
Jean-Marc Lasgouttes
1136bc4fb2 Convert a few more variables to int
This avoids warnings with windows compiler. It is a pity that even
clang does not give those. Maybe I missed them with the large amount
of boost warnings that it spits.
2015-07-15 10:16:42 +02:00
Jean-Marc Lasgouttes
8f73d1e56b Fix comment. 2015-07-14 18:03:58 +02:00
Jean-Marc Lasgouttes
463bd17d75 Use integer line thickness in painter
There is no need for real-valued line width in painters. Actually, this even leads to uneven dashes for continuous spell checker.

The new code is supposed to be equivalent to the old one, just more readable. From this, we can try to see whether some lines need to be made thicker on HiDPI screens.
2015-07-14 17:42:45 +02:00