# HG changeset patch # User insilmaril # Date 1136281481 0 # Node ID aa48c7b52549d494661258d62c21b7c8e0bfa429 # Parent 8814a667241ae2063ed7575403ca241a9f6f3b01 1.7.6 New features for floatimages and fixes diff -r 8814a667241a -r aa48c7b52549 branchobj.cpp --- a/branchobj.cpp Tue Jan 03 09:44:41 2006 +0000 +++ b/branchobj.cpp Tue Jan 03 09:44:41 2006 +0000 @@ -102,6 +102,9 @@ scrolled=false; tmpUnscrolled=false; + includeImagesVer=false; + includeImagesHor=false; + url=""; vymLink=""; } @@ -544,6 +547,9 @@ void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); + FloatImageObj *fio; + for (fio=floatimage.first(); fio; fio=floatimage.next() ) + fio->reposition(); positionBBox(); } @@ -577,17 +583,13 @@ cout << "BO::positionBBox (noHeading)\n"; */ - // Position contents by moving OO - OrnamentedObj::move (absPos.x(),absPos.y()); - - // It seems that setting x,y also affects width,height - int w_old=bbox.width(); - int h_old=bbox.height(); - bbox.setX (absPos.x() ); - bbox.setY (absPos.y() ); - bbox.setWidth(w_old); - bbox.setHeight(h_old); + positionContents(); + + int d=frame->getBorder()/2; + bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad)); + clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d )); + setSelBox(); // set the frame @@ -619,8 +621,38 @@ h=max (sysflags_h,stanflags_h); h=max (h,heading_h); + clickBox.setSize (QSize (w,h)); + + // Floatimages + QPoint rp; + FloatImageObj *foi; + + topPad=botPad=leftPad=rightPad=0; + if (includeImagesVer || includeImagesHor) + { + if (countFloatImages()>0) + { + for (foi=floatimage.first(); foi; foi=floatimage.next() ) + { + rp=foi->getRelPos(); + if (includeImagesVer) + { + if (rp.y() < 0) + topPad=max (topPad,-rp.y()); + if (rp.y()+foi->height() > h) + botPad=max (botPad,rp.y()+foi->height()-h); + } + } + } + + h+=topPad+botPad; + } + + // Frame thickness w+=frame->getBorder(); h+=frame->getBorder(); + + // Finally set size bbox.setSize (QSize (w,h)); } @@ -636,13 +668,13 @@ } // Search myself - if (inBBox (p) && (this != excludeLMO) && isVisibleObj() ) + if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) return this; // Search float images FloatImageObj *foi; for (foi=floatimage.first(); foi; foi=floatimage.next() ) - if (foi->inBBox(p) && + if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO && foi->isVisibleObj() @@ -653,11 +685,6 @@ void BranchObj::setHeading(QString s) { -/* FIXME testing only - cout << "BO::setHeading ("<0) + idAttr=attribut ("id",getSelectString()); + else + idAttr=""; + + s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr); incIndent(); // save heading @@ -837,6 +872,48 @@ return NULL; } +void BranchObj::setIncludeImagesVer(bool b) +{ + includeImagesVer=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); + // FIMXE undo needed +} + +bool BranchObj::getIncludeImagesVer() +{ + return includeImagesVer; +} + +void BranchObj::setIncludeImagesHor(bool b) +{ + includeImagesHor=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); + // FIMXE undo needed +} + +bool BranchObj::getIncludeImagesHor() +{ + return includeImagesHor; +} + +QString BranchObj::getIncludeImageAttr() +{ + QString a; + if (includeImagesVer) + a=attribut ("incImgV","true"); + else + a=attribut ("incImgV","false"); + if (includeImagesHor) + a+=" "+attribut ("incImgH","true"); + else + a+=" "+attribut ("incImgH","false"); + return a; +} + LinkableMapObj* BranchObj::addFloatImage () { FloatImageObj *newfi=new FloatImageObj (canvas,this); @@ -845,8 +922,11 @@ newfi->setVisibility (false); else newfi->setVisibility(visible); + calcBBoxSize(); + positionBBox(); requestReposition(); return newfi; + // FIMXE undo needed } LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio) @@ -858,8 +938,11 @@ newfi->setVisibility (false); else newfi->setVisibility(visible); + calcBBoxSize(); + positionBBox(); requestReposition(); return newfi; + // FIMXE undo needed } FloatImageObj* BranchObj::getFirstFloatImage () @@ -880,7 +963,10 @@ void BranchObj::removeFloatImage (FloatImageObj *fio) { floatimage.remove (fio); + calcBBoxSize(); + positionBBox(); requestReposition(); + // FIMXE undo needed } void BranchObj::savePosInAngle () @@ -1129,14 +1215,19 @@ void BranchObj::alignRelativeTo (QPoint ref) { + int th = bboxTotal.height(); /* TODO testing if (!getHeading().isEmpty()) cout << "BO::alignRelTo "<reposition(); - if (scrolled) return; // Set reference point for alignment of childs @@ -1214,6 +1301,10 @@ alignRelativeTo ( QPoint (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); branch.sort(); + + // After load, the floats might be at wrong position, force + // them to move, too + move (absPos); } else { // This is only important for moving branches: @@ -1247,14 +1338,14 @@ } void BranchObj::calcBBoxSizeWithChilds() -{ - // This is called only from reposition and +{ + // This is initially called only from reposition and // and only for mapcenter. So it won't be // called more than once for a single user // action + // Calculate size of LMO including all childs (to align them later) - bboxTotal.setX(bbox.x() ); bboxTotal.setY(bbox.y() ); @@ -1287,8 +1378,10 @@ bboxTotal.setWidth (bbox.width() + r.width() ); else bboxTotal.setWidth (bbox.width() + r.width() + linkwidth); - bboxTotal.setHeight(max (r.height(), bbox.height() ) ); + + bboxTotal.setHeight(max (r.height(), bbox.height())); // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + } void BranchObj::select() diff -r 8814a667241a -r aa48c7b52549 branchobj.h --- a/branchobj.h Tue Jan 03 09:44:41 2006 +0000 +++ b/branchobj.h Tue Jan 03 09:44:41 2006 +0000 @@ -73,6 +73,11 @@ virtual XLinkObj* XLinkAt (int); // return reference of XLinkObj virtual int countXLink (); virtual BranchObj* XLinkTargetAt (int); + void setIncludeImagesVer(bool); + bool getIncludeImagesVer(); + void setIncludeImagesHor(bool); + bool getIncludeImagesHor(); + QString getIncludeImageAttr(); virtual LinkableMapObj* addFloatImage(); virtual LinkableMapObj* addFloatImage(FloatImageObj*); virtual void removeFloatImage(FloatImageObj*); @@ -125,6 +130,9 @@ bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree QString url; // url to external doc QString vymLink; // path to another map + bool includeImagesVer; // include floatimages in bbox vertically + bool includeImagesHor; // include floatimages in bbox horizontally + }; diff -r 8814a667241a -r aa48c7b52549 demos/math.vym Binary file demos/math.vym has changed diff -r 8814a667241a -r aa48c7b52549 demos/todo.vym Binary file demos/todo.vym has changed diff -r 8814a667241a -r aa48c7b52549 mapcenterobj.cpp --- a/mapcenterobj.cpp Tue Jan 03 09:44:41 2006 +0000 +++ b/mapcenterobj.cpp Tue Jan 03 09:44:41 2006 +0000 @@ -46,13 +46,11 @@ void MapCenterObj::move (double x, double y) { BranchObj::move(x,y); - positionBBox(); } void MapCenterObj::moveBy (double x, double y) { - //BranchObj::moveBy(x,y); - move (x+absPos.x(),y+absPos.y() ); + BranchObj::moveBy(x,y); positionBBox(); } @@ -77,9 +75,8 @@ void MapCenterObj::updateLink() { // set childPos to middle of MapCenterObj - childPos=QPoint( - absPos.x() + QSize(getSize() ).width()/2, - absPos.y() + QSize(getSize() ).height()/2); + childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 ); + childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 ); parPos=childPos; BranchObj *b; for (b=branch.first(); b; b=branch.next() ) @@ -95,19 +92,15 @@ for (bo=branch.first(); bo; bo=branch.next() ) { lmo = bo->findMapObj(p, excludeLMO); - - if (lmo!= NULL) - { - return lmo; - } + if (lmo!= NULL) return lmo; } // is p in MapCenter? - if (inBBox (p) && (this != excludeLMO) ) return this; + if (inBox (p) && (this != excludeLMO) ) return this; // Search float images FloatImageObj *foi; for (foi=floatimage.first(); foi; foi=floatimage.next() ) - if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi; + if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi; // nothing found return NULL; @@ -124,9 +117,29 @@ attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) + attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10)); + // Providing an ID for a branch makes export to XHTML easier + QString idAttr; + if (countXLinks()>0) + idAttr=attribut ("id",getSelectString()); + else + idAttr=""; + + QString linkAttr=getLinkAttr(); + + QString urlAttr; + if (!url.isEmpty()) + urlAttr=attribut ("url",url); + QString vymLinkAttr; + if (!vymLink.isEmpty()) + vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) ); + s=beginElement ("mapcenter" +attribut("absPosX",QString().setNum(absPos.x(),10)) +attribut("absPosY",QString().setNum(absPos.y(),10)) + +vymLinkAttr + +urlAttr + +linkAttr + +idAttr +attribut("frameType",frame->getFrameTypeName()) +areaAttr ); diff -r 8814a667241a -r aa48c7b52549 xml.cpp --- a/xml.cpp Tue Jan 03 09:44:41 2006 +0000 +++ b/xml.cpp Tue Jan 03 09:44:41 2006 +0000 @@ -420,7 +420,7 @@ { x=a.value("absPosX").toInt (&okx, 10); y=a.value("absPosY").toInt (&oky, 10); - if (okx && oky) + if (okx && oky ) lastBranch->move(x,y); else return false; // Couldn't read absPos @@ -434,16 +434,26 @@ lastBranch->setVymLink (a.value ("vymLink")); if (!a.value( "frameType").isEmpty() ) lastBranch->setFrameType (a.value("frameType")); + + if (!a.value( "incImgV").isEmpty() ) + lastBranch->setIncludeImagesVer(a.value("incImgV")); + if (!a.value( "incImgH").isEmpty() ) + lastBranch->setIncludeImagesHor(a.value("incImgH")); return true; } bool mapBuilderHandler::readLinkAttr (const QXmlAttributes& a) { - if (!a.value( "hideLinkUnselected").isEmpty()) + if (lastLMO) { - if (a.value ("hideLinkUnselected") =="true") - if (lastLMO) lastLMO->setHideLinkUnselected(true); - } + if (!a.value( "hideLink").isEmpty()) + { + if (a.value ("hideLink") =="true") + lastLMO->setHideLinkUnselected(true); + else + lastLMO->setHideLinkUnselected(false); + } + } return true; } @@ -496,7 +506,6 @@ bool mapBuilderHandler::readFloatImageAttr (const QXmlAttributes& a) { lastLMO=lastFloat; - if (!readLinkAttr(a)) return false; if (!a.value( "useOrientation").isEmpty() ) { @@ -520,7 +529,7 @@ } if (!a.value( "floatExport").isEmpty() ) { - if (a.value ("floatExpofrt") =="true") + if (a.value ("floatExport") =="true") lastFloat->setFloatExport (true); else lastFloat->setFloatExport (false); @@ -543,6 +552,9 @@ return false; } } + + if (!readLinkAttr(a)) return false; + return true; } diff -r 8814a667241a -r aa48c7b52549 xml.h --- a/xml.h Tue Jan 03 09:44:41 2006 +0000 +++ b/xml.h Tue Jan 03 09:44:41 2006 +0000 @@ -5,6 +5,7 @@ #include #include +#include "file.h" #include "mapcenterobj.h" #include "mapeditor.h"