mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-25 09:35:39 +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>
|
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>
|
2004-02-04 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
* insettext.C (edit):
|
* insettext.C (edit):
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
|
||||||
using std::string;
|
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;
|
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
|
||||||
xo_ = x;
|
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();
|
int const aa = ascent();
|
||||||
button_dim.x1 = x + 0;
|
button_dim.x1 = x + 0;
|
||||||
button_dim.x2 = x + dimc.width();
|
button_dim.x2 = x + dimc.width();
|
||||||
button_dim.y1 = y - aa;
|
button_dim.y1 = y - aa + pi.base.bv->top_y();
|
||||||
button_dim.y2 = y - aa + dimc.height();
|
button_dim.y2 = y - aa + pi.base.bv->top_y() + dimc.height();
|
||||||
|
|
||||||
draw_collapsed(pi, x, y);
|
draw_collapsed(pi, x, y);
|
||||||
if (status_ == Open) {
|
if (status_ == Open) {
|
||||||
@ -217,15 +217,17 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
|||||||
edit(cur, true);
|
edit(cur, true);
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
case Open:
|
case Open: {
|
||||||
if (hitButton(cmd)) {
|
FuncRequest cmd1 = cmd;
|
||||||
|
// cmd1.y -= cur.bv().top_y();
|
||||||
|
if (hitButton(cmd1)) {
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
||||||
setStatus(Collapsed);
|
setStatus(Collapsed);
|
||||||
return DispatchResult(false, FINISHED_RIGHT);
|
return DispatchResult(false, FINISHED_RIGHT);
|
||||||
}
|
}
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
||||||
return inset.dispatch(cur, cmd);
|
return inset.dispatch(cur, cmd);
|
||||||
|
}
|
||||||
case Inlined:
|
case Inlined:
|
||||||
return inset.dispatch(cur, cmd);
|
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
|
//we are not calling edit(x,y) because there are no coordinates in the
|
||||||
//inset yet. I personally think it's ok. (ab)
|
//inset yet. I personally think it's ok. (ab)
|
||||||
} else {
|
} else {
|
||||||
if (y <= button_dim.y2)
|
// if (y <= yo() + inset.ascent() + button_dim.y2)
|
||||||
y = 0;
|
// y = yo();
|
||||||
else
|
// else
|
||||||
y += inset.ascent() - height_collapsed();
|
// y += inset.ascent() - height_collapsed();
|
||||||
|
|
||||||
inset.edit(cur, x, y);
|
inset.edit(cur, x, y);
|
||||||
}
|
}
|
||||||
@ -329,14 +331,16 @@ InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
if (status_ == Inlined)
|
if (status_ == Inlined)
|
||||||
inset.dispatch(cur, cmd);
|
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);
|
inset.dispatch(cur, cmd);
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
|
|
||||||
case LFUN_MOUSE_MOTION:
|
case LFUN_MOUSE_MOTION:
|
||||||
if (status_ == Inlined)
|
if (status_ == Inlined)
|
||||||
inset.dispatch(cur, cmd);
|
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);
|
inset.dispatch(cur, cmd);
|
||||||
return DispatchResult(true, true);
|
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
|
void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(!text_.paragraphs().begin()->rows.empty());
|
||||||
// update our idea of where we are
|
// update our idea of where we are
|
||||||
setPosCache(pi, x, y);
|
setPosCache(pi, x, y);
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
|||||||
text_.draw(pi, x, y);
|
text_.draw(pi, x, y);
|
||||||
|
|
||||||
if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
|
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 ttoD2 = TEXT_TO_INSET_OFFSET / 2;
|
||||||
int const frame_x = x + ttoD2;
|
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_w = dim_.wid - TEXT_TO_INSET_OFFSET;
|
||||||
int const frame_h = dim_.asc + dim_.des - 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());
|
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)
|
void InsetText::edit(LCursor & cur, bool left)
|
||||||
{
|
{
|
||||||
//lyxerr << "InsetText: edit left/right" << endl;
|
//lyxerr << "InsetText: edit left/right" << endl;
|
||||||
|
@ -170,7 +170,7 @@ private:
|
|||||||
///
|
///
|
||||||
void removeNewlines();
|
void removeNewlines();
|
||||||
///
|
///
|
||||||
void drawFrame(Painter &, int x) const;
|
void drawFrame(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
void clearInset(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
|
RowList::iterator
|
||||||
LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
|
LyXText::getRowNearY(int y, ParagraphList::iterator & pit) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(!paragraphs().empty());
|
||||||
|
BOOST_ASSERT(!paragraphs().begin()->rows.empty());
|
||||||
#if 1
|
#if 1
|
||||||
ParagraphList::iterator const
|
ParagraphList::iterator const
|
||||||
pend = boost::prior(paragraphs().end());
|
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
|
// returns the column near the specified x-coordinate of the row
|
||||||
// x is set to the real beginning of this column
|
// x is set to the real beginning of this column
|
||||||
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
|
||||||
@ -1327,7 +1327,8 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
|||||||
ParagraphList::iterator pit;
|
ParagraphList::iterator pit;
|
||||||
Row const & row = *getRowNearY(y, pit);
|
Row const & row = *getRowNearY(y, pit);
|
||||||
bool bound = false;
|
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.par() = parOffset(pit);
|
||||||
cur.pos() = pos;
|
cur.pos() = pos;
|
||||||
cur.boundary() = bound;
|
cur.boundary() = bound;
|
||||||
@ -1337,10 +1338,11 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
|
|||||||
// x,y are absolute screen coordinates
|
// x,y are absolute screen coordinates
|
||||||
void LyXText::edit(LCursor & cur, int x, int y)
|
void LyXText::edit(LCursor & cur, int x, int y)
|
||||||
{
|
{
|
||||||
int xx = x; // is modified by getColumnNearX
|
|
||||||
ParagraphList::iterator pit;
|
ParagraphList::iterator pit;
|
||||||
Row const & row = *getRowNearY(y, pit);
|
Row const & row = *getRowNearY(y - yo_, pit);
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
|
|
||||||
|
int xx = x; // is modified by getColumnNearX
|
||||||
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
|
pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
|
||||||
cur.par() = parOffset(pit);
|
cur.par() = parOffset(pit);
|
||||||
cur.pos() = pos;
|
cur.pos() = pos;
|
||||||
@ -1349,11 +1351,12 @@ void LyXText::edit(LCursor & cur, int x, int y)
|
|||||||
// try to descend into nested insets
|
// try to descend into nested insets
|
||||||
InsetBase * inset = checkInsetHit(x, y);
|
InsetBase * inset = checkInsetHit(x, y);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
// This should be just before or just behind the cursor position
|
// This should be just before or just behind the
|
||||||
// set above.
|
// cursor position set above.
|
||||||
BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1))
|
BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1))
|
||||||
|| inset == pit->getInset(pos));
|
|| 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))
|
if (inset == pit->getInset(pos - 1))
|
||||||
--cur.pos();
|
--cur.pos();
|
||||||
inset->edit(cur, x, y);
|
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)
|
InsetBase * LyXText::checkInsetHit(int x, int y)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit;
|
ParagraphList::iterator pit;
|
||||||
ParagraphList::iterator end;
|
ParagraphList::iterator end;
|
||||||
|
|
||||||
getParsInRange(paragraphs(),
|
getParsInRange(paragraphs(),
|
||||||
bv()->top_y(),
|
bv()->top_y() - yo_,
|
||||||
bv()->top_y() + bv()->workHeight(),
|
bv()->top_y() - yo_ + bv()->workHeight(),
|
||||||
pit, end);
|
pit, end);
|
||||||
|
|
||||||
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
|
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
|
||||||
@ -269,7 +270,7 @@ InsetBase * LyXText::checkInsetHit(int x, int y)
|
|||||||
<< " yo: " << inset->yo() - inset->ascent() << "..."
|
<< " yo: " << inset->yo() - inset->ascent() << "..."
|
||||||
<< inset->yo() + inset->descent() << endl;
|
<< inset->yo() + inset->descent() << endl;
|
||||||
#endif
|
#endif
|
||||||
if (inset->covers(x, y - bv()->top_y())) {
|
if (inset->covers(x, y)) {
|
||||||
lyxerr << "Hit inset: " << inset << endl;
|
lyxerr << "Hit inset: " << inset << endl;
|
||||||
return inset;
|
return inset;
|
||||||
}
|
}
|
||||||
@ -1228,7 +1229,8 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
|
setCursorFromCoordinates(cur.current(), cmd.x - xo_,
|
||||||
|
cmd.y - yo_);
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
finishUndo();
|
finishUndo();
|
||||||
cur.x_target() = cursorX(cur.current());
|
cur.x_target() = cursorX(cur.current());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user