mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
fix some coordinates (tabular and math missing)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8410 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
38512e8412
commit
09e11f4d38
@ -1,3 +1,9 @@
|
||||
2004-02-06 Alfredo Braunstein <abraunst@lyx.org>
|
||||
|
||||
* text3.C (checkInsetHit): adjust coords
|
||||
* text2.C (getColumnNearX): adjust coords
|
||||
(edit): adjust coords
|
||||
* text.C (getRowNearY): add two asserts
|
||||
|
||||
2004-02-06 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
|
@ -1,4 +1,11 @@
|
||||
|
||||
2004-02-06 Alfredo Braunstein <abraunst@lyx.org>
|
||||
|
||||
* inset.C (setPosCache): switch to absolute coords in insets
|
||||
* insettext.[Ch] (draw, drawFrame): adjust
|
||||
* insetcollapsable.C (draw): adjust
|
||||
(edit): adjust
|
||||
|
||||
2004-02-04 Alfredo Braunstein <abraunst@lyx.org>
|
||||
|
||||
* insettext.C (edit):
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "gettext.h"
|
||||
#include "lyxtext.h"
|
||||
#include "LColor.h"
|
||||
|
||||
#include "metricsinfo.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -87,9 +87,9 @@ int InsetOld::scroll(bool recursive) const
|
||||
}
|
||||
|
||||
|
||||
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
|
||||
void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const
|
||||
{
|
||||
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
yo_ = y + pi.base.bv->top_y();
|
||||
}
|
||||
|
@ -170,8 +170,8 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||
int const aa = ascent();
|
||||
button_dim.x1 = x + 0;
|
||||
button_dim.x2 = x + dimc.width();
|
||||
button_dim.y1 = y - aa;
|
||||
button_dim.y2 = y - aa + dimc.height();
|
||||
button_dim.y1 = y - aa + pi.base.bv->top_y();
|
||||
button_dim.y2 = y - aa + pi.base.bv->top_y() + dimc.height();
|
||||
|
||||
draw_collapsed(pi, x, y);
|
||||
if (status_ == Open) {
|
||||
@ -217,15 +217,17 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
edit(cur, true);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case Open:
|
||||
if (hitButton(cmd)) {
|
||||
case Open: {
|
||||
FuncRequest cmd1 = cmd;
|
||||
// cmd1.y -= cur.bv().top_y();
|
||||
if (hitButton(cmd1)) {
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
||||
setStatus(Collapsed);
|
||||
return DispatchResult(false, FINISHED_RIGHT);
|
||||
}
|
||||
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
||||
return inset.dispatch(cur, cmd);
|
||||
|
||||
}
|
||||
case Inlined:
|
||||
return inset.dispatch(cur, cmd);
|
||||
}
|
||||
@ -310,10 +312,10 @@ void InsetCollapsable::edit(LCursor & cur, int x, int y)
|
||||
//we are not calling edit(x,y) because there are no coordinates in the
|
||||
//inset yet. I personally think it's ok. (ab)
|
||||
} else {
|
||||
if (y <= button_dim.y2)
|
||||
y = 0;
|
||||
else
|
||||
y += inset.ascent() - height_collapsed();
|
||||
// if (y <= yo() + inset.ascent() + button_dim.y2)
|
||||
// y = yo();
|
||||
// else
|
||||
// y += inset.ascent() - height_collapsed();
|
||||
|
||||
inset.edit(cur, x, y);
|
||||
}
|
||||
@ -329,14 +331,16 @@ InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (status_ == Inlined)
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
else if (status_ == Open
|
||||
&& cmd.y > button_dim.y2)
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
if (status_ == Inlined)
|
||||
inset.dispatch(cur, cmd);
|
||||
else if (status_ == Open && cmd.y > button_dim.y2)
|
||||
else if (status_ == Open
|
||||
&& cmd.y > button_dim.y2)
|
||||
inset.dispatch(cur, cmd);
|
||||
return DispatchResult(true, true);
|
||||
|
||||
|
@ -191,6 +191,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
BOOST_ASSERT(!text_.paragraphs().begin()->rows.empty());
|
||||
// update our idea of where we are
|
||||
setPosCache(pi, x, y);
|
||||
|
||||
@ -209,7 +210,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
text_.draw(pi, x, y);
|
||||
|
||||
if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
|
||||
drawFrame(pi.pain, xo_);
|
||||
drawFrame(pi.pain, xo_, yo_ - bv->top_y());
|
||||
}
|
||||
|
||||
|
||||
@ -219,11 +220,11 @@ void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::drawFrame(Painter & pain, int x) const
|
||||
void InsetText::drawFrame(Painter & pain, int x, int y) const
|
||||
{
|
||||
int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
|
||||
int const frame_x = x + ttoD2;
|
||||
int const frame_y = yo_ - dim_.asc + ttoD2;
|
||||
int const frame_y = y - dim_.asc + ttoD2;
|
||||
int const frame_w = dim_.wid - TEXT_TO_INSET_OFFSET;
|
||||
int const frame_h = dim_.asc + dim_.des - TEXT_TO_INSET_OFFSET;
|
||||
pain.rectangle(frame_x, frame_y, frame_w, frame_h, frameColor());
|
||||
@ -283,9 +284,6 @@ void InsetText::sanitizeEmptyText(BufferView & bv)
|
||||
}
|
||||
|
||||
|
||||
extern CursorBase theTempCursor;
|
||||
|
||||
|
||||
void InsetText::edit(LCursor & cur, bool left)
|
||||
{
|
||||
//lyxerr << "InsetText: edit left/right" << endl;
|
||||
|
@ -170,7 +170,7 @@ private:
|
||||
///
|
||||
void removeNewlines();
|
||||
///
|
||||
void drawFrame(Painter &, int x) const;
|
||||
void drawFrame(Painter &, int x, int y) const;
|
||||
///
|
||||
void clearInset(Painter &, int x, int y) const;
|
||||
|
||||
|
@ -1414,9 +1414,12 @@ ParagraphList::iterator LyXText::getPar(int par) const
|
||||
}
|
||||
|
||||
|
||||
// y is relative to this LyXText's top
|
||||
RowList::iterator
|
||||
LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
|
||||
{
|
||||
BOOST_ASSERT(!paragraphs().empty());
|
||||
BOOST_ASSERT(!paragraphs().begin()->rows.empty());
|
||||
#if 1
|
||||
ParagraphList::iterator const
|
||||
pend = boost::prior(paragraphs().end());
|
||||
|
17
src/text2.C
17
src/text2.C
@ -1207,7 +1207,7 @@ void LyXText::setCurrentFont()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// x is an absolute screen coord
|
||||
// returns the column near the specified x-coordinate of the row
|
||||
// x is set to the real beginning of this column
|
||||
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||
@ -1327,7 +1327,8 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
||||
ParagraphList::iterator pit;
|
||||
Row const & row = *getRowNearY(y, pit);
|
||||
bool bound = false;
|
||||
pos_type const pos = row.pos() + getColumnNearX(pit, row, x, bound);
|
||||
int xx = x + xo_; // getRowNearX get absolute x coords
|
||||
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
|
||||
cur.par() = parOffset(pit);
|
||||
cur.pos() = pos;
|
||||
cur.boundary() = bound;
|
||||
@ -1337,10 +1338,11 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
||||
// x,y are absolute screen coordinates
|
||||
void LyXText::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
int xx = x; // is modified by getColumnNearX
|
||||
ParagraphList::iterator pit;
|
||||
Row const & row = *getRowNearY(y, pit);
|
||||
Row const & row = *getRowNearY(y - yo_, pit);
|
||||
bool bound = false;
|
||||
|
||||
int xx = x; // is modified by getColumnNearX
|
||||
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
|
||||
cur.par() = parOffset(pit);
|
||||
cur.pos() = pos;
|
||||
@ -1349,11 +1351,12 @@ void LyXText::edit(LCursor & cur, int x, int y)
|
||||
// try to descend into nested insets
|
||||
InsetBase * inset = checkInsetHit(x, y);
|
||||
if (inset) {
|
||||
// This should be just before or just behind the cursor position
|
||||
// set above.
|
||||
// This should be just before or just behind the
|
||||
// cursor position set above.
|
||||
BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1))
|
||||
|| inset == pit->getInset(pos));
|
||||
// Make sure the cursor points to the position before this inset.
|
||||
// Make sure the cursor points to the position before
|
||||
// this inset.
|
||||
if (inset == pit->getInset(pos - 1))
|
||||
--cur.pos();
|
||||
inset->edit(cur, x, y);
|
||||
|
10
src/text3.C
10
src/text3.C
@ -246,14 +246,15 @@ string const freefont2string()
|
||||
}
|
||||
|
||||
|
||||
//takes absolute x,y coordinates
|
||||
InsetBase * LyXText::checkInsetHit(int x, int y)
|
||||
{
|
||||
ParagraphList::iterator pit;
|
||||
ParagraphList::iterator end;
|
||||
|
||||
getParsInRange(paragraphs(),
|
||||
bv()->top_y(),
|
||||
bv()->top_y() + bv()->workHeight(),
|
||||
bv()->top_y() - yo_,
|
||||
bv()->top_y() - yo_ + bv()->workHeight(),
|
||||
pit, end);
|
||||
|
||||
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
|
||||
@ -269,7 +270,7 @@ InsetBase * LyXText::checkInsetHit(int x, int y)
|
||||
<< " yo: " << inset->yo() - inset->ascent() << "..."
|
||||
<< inset->yo() + inset->descent() << endl;
|
||||
#endif
|
||||
if (inset->covers(x, y - bv()->top_y())) {
|
||||
if (inset->covers(x, y)) {
|
||||
lyxerr << "Hit inset: " << inset << endl;
|
||||
return inset;
|
||||
}
|
||||
@ -1228,7 +1229,8 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
|
||||
setCursorFromCoordinates(cur.current(), cmd.x - xo_,
|
||||
cmd.y - yo_);
|
||||
cur.resetAnchor();
|
||||
finishUndo();
|
||||
cur.x_target() = cursorX(cur.current());
|
||||
|
Loading…
Reference in New Issue
Block a user