re-enable click on button insets

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8394 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-02-03 16:44:57 +00:00
parent 7ffc9e9175
commit 29ef6251e8
8 changed files with 40 additions and 37 deletions

View File

@ -355,7 +355,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
bool BufferView::Pimpl::fitCursor() bool BufferView::Pimpl::fitCursor()
{ {
lyxerr << "BufferView::Pimpl::fitCursor." << endl;
if (screen().fitCursor(bv_)) { if (screen().fitCursor(bv_)) {
updateScrollbar(); updateScrollbar();
return true; return true;

View File

@ -92,19 +92,15 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
// remove one level of cursor // remove one level of cursor
switch (res.val()) { switch (res.val()) {
case FINISHED: case FINISHED:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_LEFT); cmd = FuncRequest(LFUN_FINISHED_LEFT);
break; break;
case FINISHED_RIGHT: case FINISHED_RIGHT:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_RIGHT); cmd = FuncRequest(LFUN_FINISHED_RIGHT);
break; break;
case FINISHED_UP: case FINISHED_UP:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_UP); cmd = FuncRequest(LFUN_FINISHED_UP);
break; break;
case FINISHED_DOWN: case FINISHED_DOWN:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_DOWN); cmd = FuncRequest(LFUN_FINISHED_DOWN);
break; break;
default: default:
@ -112,7 +108,9 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
break; break;
} }
} }
lyxerr << "trying to dispatch to main text " << bv_->text() << endl; current_ = 0;
lyxerr << "trying to dispatch to main text " << bv_->text()
<< " with cursor: " << *this << endl;
DispatchResult res = bv_->text()->dispatch(*this, cmd); DispatchResult res = bv_->text()->dispatch(*this, cmd);
lyxerr << " result: " << res.val() << endl; lyxerr << " result: " << res.val() << endl;
return res; return res;
@ -131,24 +129,18 @@ void LCursor::push(InsetBase * inset)
void LCursor::pop(int depth) void LCursor::pop(int depth)
{ {
//lyxerr << "LCursor::pop() to depth " << depth << endl; while (int(cursor_.size()) > depth + 1)
while (int(cursor_.size()) > depth)
pop(); pop();
lyxerr << "LCursor::pop() result: " << *this << endl;
} }
void LCursor::pop() void LCursor::pop()
{ {
BOOST_ASSERT(!cursor_.empty()); BOOST_ASSERT(cursor_.size() >= 1);
//lyxerr << "LCursor::pop() a level" << endl; cursor_.pop_back();
if (cursor_.size() <= 1) anchor_.pop_back();
lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl; current_ = cursor_.size() - 1;
else {
cursor_.pop_back();
anchor_.pop_back();
current_ = cursor_.size() - 1;
}
//lyxerr << "LCursor::pop() current now: " << current_ << endl;
} }

View File

@ -82,6 +82,8 @@ public:
CursorSlice const & current() const; CursorSlice const & current() const;
/// how many nested insets do we have? /// how many nested insets do we have?
size_t depth() const { return cursor_.size(); } size_t depth() const { return cursor_.size(); }
/// depth of current slice
int currentDepth() const { return current_; }
// //
// selection // selection

View File

@ -212,9 +212,9 @@ bool LyXScreen::fitCursor(BufferView * bv)
int x, y, asc, desc; int x, y, asc, desc;
bv->cursor().getPos(x, y); bv->cursor().getPos(x, y);
lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
<< " top_y: " << top_y << endl;
bv->cursor().getDim(asc, desc); bv->cursor().getDim(asc, desc);
//lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
// << " top_y: " << top_y << endl;
bool const big_row = h / 4 < asc + desc && asc + desc < h; bool const big_row = h / 4 < asc + desc && asc + desc < h;

View File

@ -89,7 +89,7 @@ int InsetOld::scroll(bool recursive) const
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const void InsetOld::setPosCache(PainterInfo const &, 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;
} }

View File

@ -63,20 +63,19 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
void InsetCollapsable::write(Buffer const & buf, ostream & os) const void InsetCollapsable::write(Buffer const & buf, ostream & os) const
{ {
string st; os << "status ";
switch (status_) { switch (status_) {
case Open: case Open:
st = "open"; os << "open";
break; break;
case Collapsed: case Collapsed:
st = "collapsed"; os << "collapsed";
break; break;
case Inlined: case Inlined:
st = "inlined"; os << "inlined";
break; break;
} }
os << "status " << st << "\n"; os << "\n";
inset.text_.write(buf, os); inset.text_.write(buf, os);
} }
@ -170,12 +169,11 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
} else { } else {
Dimension dimc; Dimension dimc;
dimension_collapsed(dimc); dimension_collapsed(dimc);
int const aa = ascent(); int const aa = ascent();
button_dim.x1 = 0; button_dim.x1 = x + 0;
button_dim.x2 = dimc.width(); button_dim.x2 = x + dimc.width();
button_dim.y1 = -aa; button_dim.y1 = y - aa;
button_dim.y2 = -aa + dimc.height(); button_dim.y2 = y - aa + dimc.height();
draw_collapsed(pi, x, y); draw_collapsed(pi, x, y);
if (status_ == Open) { if (status_ == Open) {
@ -219,6 +217,8 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
if (hitButton(cmd)) { if (hitButton(cmd)) {
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl; lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
setStatus(Collapsed); setStatus(Collapsed);
// drop one level
cur.bv().cursor() = cur;
return DispatchResult(false, FINISHED_RIGHT); return DispatchResult(false, FINISHED_RIGHT);
} }
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl; lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
@ -227,7 +227,8 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
case Inlined: case Inlined:
return inset.dispatch(cur, cmd); return inset.dispatch(cur, cmd);
} }
BOOST_ASSERT(false);
// shut up compiler
return DispatchResult(true, true); return DispatchResult(true, true);
} }

View File

@ -210,6 +210,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd) DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
{ {
lyxerr << "\nInsetERT::priv_dispatch (begin): cmd: " << cmd << endl;
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {

View File

@ -1464,24 +1464,32 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
break; break;
case LFUN_FINISHED_LEFT: case LFUN_FINISHED_LEFT:
lyxerr << "swallow LFUN_FINISHED_LEFT" << endl; lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
if (rtl()) if (rtl())
cursorLeft(true); cursorLeft(true);
break; break;
case LFUN_FINISHED_RIGHT: case LFUN_FINISHED_RIGHT:
lyxerr << "swallow LFUN_FINISHED_RIGHT" << endl; lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
if (!rtl()) if (!rtl())
cursorRight(true); cursorRight(true);
break; break;
case LFUN_FINISHED_UP: case LFUN_FINISHED_UP:
lyxerr << "swallow LFUN_FINISHED_UP" << endl; lyxerr << "handle LFUN_FINISHED_UP" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
cursorUp(true); cursorUp(true);
break; break;
case LFUN_FINISHED_DOWN: case LFUN_FINISHED_DOWN:
lyxerr << "swallow LFUN_FINISHED_DOWN" << endl; lyxerr << "handle LFUN_FINISHED_DOWN" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
cursorDown(true); cursorDown(true);
break; break;