Re: riverae - r21703 - in abiword/branches/RiveraESoC/src: text/fmt/xp wp/ap/xp

From: Martin Sevior <msevior_at_physics.unimelb.edu.au>
Date: Fri Aug 10 2007 - 03:49:04 CEST

Hi ernesto,
           You should not store a pointer to ap_Annotation_Preview in
FV_View.

Please rework your commit to remove this. See how I got the pointer for
ap_Annotation_Preview by using dialogfactory framework.

To avoid flickering, don't delete the preview on every call to
getMouseContext.

Cheers

Martin

On Fri, 2007-08-10 at 04:00 +0200, cvs@abisource.com wrote:
> Author: riverae
> Date: 2007-08-10 04:00:38 +0200 (Fri, 10 Aug 2007)
> New Revision: 21703
>
> Modified:
> abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.cpp
> abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.h
> abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View_cmd.cpp
> abiword/branches/RiveraESoC/src/wp/ap/xp/ap_EditMethods.cpp
> abiword/branches/RiveraESoC/src/wp/ap/xp/ap_Preview_Annotation.cpp
> Log:
> Cleaned annotation preview code.
> Fixed annotation preview not correctly redrawing upon when hovering between different annotations.
> Flickering reappeared, checking...
> Eliminated methods no longer useful.
>
> Modified: abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.cpp
> ===================================================================
> --- abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.cpp 2007-08-10 00:03:40 UTC (rev 21702)
> +++ abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.cpp 2007-08-10 02:00:38 UTC (rev 21703)
> @@ -9797,18 +9797,6 @@
> m_iMouseX = xPos;
> m_iMouseY = yPos;
>
> -/*<<<<<<< .mine TODO check
> - // RIVERA kill annotation preview on change of mouse context
> - if ((m_prevMouseContext != EV_EMC_HYPERLINK) &&
> - (m_bAnnotationPreviewActive==true) &&
> - (m_pAnnotationPview != NULL))
> - {
> - UT_DEBUGMSG(("getMouseContext: Deleting annotation preview...\n"));
> - killAnnotationPreview();
> - }
> -
> -=======*/
> -
> if(getPoint() == 0) // We haven't loaded any layouts yet
> {
> return EV_EMC_UNKNOWN;
> @@ -12353,17 +12341,11 @@
> // RIVERA
> void FV_View::killAnnotationPreview()
> {
> -/*<<<<<<< .mine TODO check
> - if(m_bAnnotationPreviewActive)
> - delete m_pAnnotationPview;
> - m_bAnnotationPreviewActive = false;
> -=======*/
> UT_DEBUGMSG(("killAnnotationPreview: Deleting annotation preview...\n"));
> XAP_Frame * pFrame = static_cast<XAP_Frame *>(getParentData());
> XAP_DialogFactory * pDialogFactory
> = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory());
>
> -
> AP_Preview_Annotation * pPview
> = static_cast<AP_Preview_Annotation *>(pDialogFactory->requestDialog( AP_DIALOG_ID_ANNOTATION_PREVIEW));
> UT_ASSERT(pPview);
>
> Modified: abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.h
> ===================================================================
> --- abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.h 2007-08-10 00:03:40 UTC (rev 21702)
> +++ abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View.h 2007-08-10 02:00:38 UTC (rev 21703)
> @@ -48,6 +48,9 @@
> #include "fv_VisualDragText.h"
> #endif
>
> +// RIVERA
> +#include "ap_Preview_Annotation.h"
> +
> #define AUTO_SCROLL_MSECS 100
>
> class FL_DocLayout;
> @@ -565,10 +568,10 @@
> bool getAnnotationRichText(UT_uint32 iAnnotation, UT_UTF8String & sRTF);
> bool setAnnotationRichText(UT_uint32 iAnnotaion, UT_UTF8String &sRTF);
>
> - bool isAnnotationPreviewActive(void)
> - { return m_bAnnotationPreviewActive;}
> - void setAnnotationPreviewActive(bool b)
> - { m_bAnnotationPreviewActive = b;}
> + bool isAnnotationPreviewActive(void) { return m_bAnnotationPreviewActive;}
> + void setAnnotationPreviewActive(bool b) { m_bAnnotationPreviewActive = b;}
> + AP_Preview_Annotation * getActivePreviewAnnotation() { return m_pAnnotationPview;}
> + void setActivePreviewAnnotation(AP_Preview_Annotation * pAnnotationPview) { m_pAnnotationPview = pAnnotationPview;}
> void killAnnotationPreview();
> bool cmdEditAnnotationWithDialog(UT_uint32 aID);
> fl_AnnotationLayout * getAnnotationLayout(UT_uint32 iAnnotation);
> @@ -1067,6 +1070,7 @@
> UT_GenericVector<fv_CaretProps *> m_vecCarets;
> UT_UTF8String m_sDocUUID;
> bool m_bAnnotationPreviewActive;
> + AP_Preview_Annotation * m_pAnnotationPview;
> };
>
> #endif /* FV_VIEW_H */
>
> Modified: abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View_cmd.cpp
> ===================================================================
> --- abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View_cmd.cpp 2007-08-10 00:03:40 UTC (rev 21702)
> +++ abiword/branches/RiveraESoC/src/text/fmt/xp/fv_View_cmd.cpp 2007-08-10 02:00:38 UTC (rev 21703)
> @@ -4621,107 +4621,25 @@
> url.decodeURL();
> pFrame->setStatusMessage(url.utf8_str());
> }
> -/* <<<<<<< .mine TODO check
> - else
> - {
> - fp_AnnotationRun * pAnn = static_cast<fp_AnnotationRun *>(pH1);
> - UT_DEBUGMSG(("cmdHyperlinkStatusBar: HOVERING over an annotation PID %d \n",pAnn->getPID()));
> -
> - // avoid unneeded redrawings
> - if ((m_bAnnotationPreviewActive) &&
> - (m_pAnnotationPview->getAnnotationID()==pAnn->getPID())) // if its not que same annotation, kill it?
> - {
> - UT_DEBUGMSG(("cmdHyperlinkStatusBar: nothing to draw, annotation already previewed\n"));
> - return true; // should be false? think not
> - }
> -
> - fp_Page * pPage = pAnn->getLine()->getPage();
> - if(!pPage)
> - return false;
> - UT_uint32 i =0;
> - bool bFound = false;
> - fp_AnnotationContainer * pACon = NULL;
> - for(i=0; i<pPage->countAnnotationContainers();i++)
> - {
> - pACon = pPage->getNthAnnotationContainer(i);
> - if(pAnn->getPID() == pACon->getPID())
> - {
> - bFound = true;
> - break;
> - }
> - }
> - if(!bFound)
> - return false;
> - fl_AnnotationLayout * pAL = static_cast<fl_AnnotationLayout *>(pACon->getSectionLayout());
> - PL_StruxDocHandle sdhStart = pAL->getStruxDocHandle();
> - PL_StruxDocHandle sdhEnd = NULL;
> - getDocument()->getNextStruxOfType(sdhStart,PTX_EndAnnotation, &sdhEnd);
>
> - UT_return_val_if_fail(sdhEnd != NULL, false);
> - PT_DocPosition posStart = getDocument()->getStruxPosition(sdhStart)+1; // Pos of Block o Text
> - PT_DocPosition posEnd = getDocument()->getStruxPosition(sdhEnd) -1; // Just before end strux
> -
> - // preview annotation
> -
> - UT_GrowBuf buffer;
> - fl_BlockLayout * block;
> -
> - block = m_pLayout->findBlockAtPosition(posStart+1);
> - if (block)
> - {
> - block->getBlockBuf(&buffer);
> - }
> - UT_UCS4String str(reinterpret_cast<const UT_UCS4Char *>(buffer.getPointer(0)),buffer.getLength());
> - UT_DEBUGMSG(("cmdHyperlinkStatusBar: Description in annotation is \"%s\"\n",str.utf8_str()));
> -
> - XAP_App * pApp = XAP_App::getApp();
> - UT_return_val_if_fail (pApp, false);
> -
> - pFrame->raise();
> -
> - UT_DEBUGMSG(("cmdHyperlinkStatusBar: Previewing annotation...\n"));
> - AP_Preview_Annotation * pPview;
> - pPview = new AP_UnixPreview_Annotation(pFrame, 100, 100); // TODO modify this unix line
> -
> - // kill previous preview if needed (it is not the same annotation as it would be detected above)
> - if (m_bAnnotationPreviewActive==true)
> - {
> - UT_DEBUGMSG(("cmdHyperlinkStatusBar: Deleting previous annotation preview...\n"));
> - killAnnotationPreview();
> - }
> -
> - // flag as active
> - m_pAnnotationPview = pPview;
> - m_bAnnotationPreviewActive = true;
> -
> - pPview->setTitle("n/a");
> - pPview->setAuthor("n/a");
> - pPview->setDescription(str.utf8_str());
> - pPview->setAnnotationID(pAnn->getPID());
> - pPview->draw();
> -
> - }
> -=======*/
> return true;
> }
>
> bool FV_View::cmdEditAnnotationWithDialog(UT_uint32 aID)
> {
> - if( m_bAnnotationPreviewActive)
> - {
> - // kill the annotation preview popup
> - killAnnotationPreview();
> - m_bAnnotationPreviewActive = false;
> -
> - }
> - //
> - // Get the text fromt he annotation
> - //
> + // kill the annotation preview popup is needed
> + if(isAnnotationPreviewActive())
> + killAnnotationPreview();
>
> + //
> + // Get the text fromt he annotation
> + //
> +
> + // TODO maybe we should not exit if annotation is not present (ex. auto-generated annotations may become not be editable!)
> UT_UTF8String sText;
> bool b = getAnnotationText(aID,sText);
> if(!b)
> - return false;
> + return false;
> // edit annotation
>
> XAP_Frame * pFrame = static_cast<XAP_Frame *> (getParentData());
> @@ -4753,7 +4671,7 @@
>
> if (bOK)
> {
> - UT_DEBUGMSG(("cmdEditAnnotationWithDialog: Annotation \"%d\" edited \n",aID));
> + UT_DEBUGMSG(("cmdEditAnnotationWithDialog: Annotation id(\"%d\") edited \n",aID));
>
> for(UT_uint32 i = 0;i < pApp->getFrameCount();++i)
> {
> @@ -4765,6 +4683,7 @@
> UT_UTF8String pDescr = pDialog->getDescription();
> bool bReplaceSelection = false;
> b = setAnnotationText(aID,pDescr);
> + // TODO implement other fields as well
> }
>
> // release the dialog
>
> Modified: abiword/branches/RiveraESoC/src/wp/ap/xp/ap_EditMethods.cpp
> ===================================================================
> --- abiword/branches/RiveraESoC/src/wp/ap/xp/ap_EditMethods.cpp 2007-08-10 00:03:40 UTC (rev 21702)
> +++ abiword/branches/RiveraESoC/src/wp/ap/xp/ap_EditMethods.cpp 2007-08-10 02:00:38 UTC (rev 21703)
> @@ -683,7 +683,6 @@
>
> //RIVERA
> static EV_EditMethod_Fn insAnnotation;
> - static EV_EditMethod_Fn pviewAnnotation;
>
> static EV_EditMethod_Fn sortColsAscend;
> static EV_EditMethod_Fn sortColsDescend;
> @@ -1033,7 +1032,6 @@
> EV_EditMethod(NF(printPreview), 0, ""),
> EV_EditMethod(NF(printTB), 0, ""),
> EV_EditMethod(NF(purgeAllRevisions), 0, ""),
> - EV_EditMethod(NF(pviewAnnotation), 0, ""),
>
> // q
> EV_EditMethod(NF(querySaveAndExit), _A_, ""),
> @@ -3391,27 +3389,6 @@
> return true ;
> }
>
> -// TODO to be removed
> -Defun(pviewAnnotation)
> -{
> - CHECK_FRAME;
> - UT_return_val_if_fail (pAV_View, false);
> - FV_View * pView = static_cast<FV_View *>(pAV_View);
> -
> - XAP_Frame * pFrame = static_cast<XAP_Frame *>(pView->getParentData());
> - UT_return_val_if_fail(pFrame, false);
> -
> - XAP_App * pApp = XAP_App::getApp();
> - UT_return_val_if_fail (pApp, false);
> -
> - pFrame->raise();
> -
> - UT_DEBUGMSG(("pviewAnnotation: Previewing annotation...\n"));
> -
> - return true;
> -}
> -
> -
> Defun(fileNewUsingTemplate)
> {
> CHECK_FRAME;
> @@ -10516,8 +10493,8 @@
> // set initial annotation properties
>
> pDialog->setTitle("New annotation");
> - pDialog->setAuthor("Author");
> - pDialog->setDescription("annotation description") ;
> + pDialog->setAuthor("");
> + pDialog->setDescription("") ;
>
> // run the dialog
>
> @@ -13688,10 +13665,25 @@
> pView->cmdHyperlinkStatusBar(xpos, ypos);
> return true;
> }
> - if(pView->isAnnotationPreviewActive())
> - return true;
> -
> +
> fp_AnnotationRun * pAnn = static_cast<fp_AnnotationRun *>(pHRun);
> +
> + // avoid unneeded redrawings
> + // check BOTH if we are already previewing an annotation, and that it is indeed the annotation we want
> + if((pView->isAnnotationPreviewActive()) &&
> + (pView->getActivePreviewAnnotation()->getAnnotationID() == pAnn->getPID()))
> + {
> + UT_DEBUGMSG(("hyperlinkStatusBar: nothing to draw, annotation already previewed\n"));
> + return true; // should be false? think not
> + }
> +
> + // kill previous preview if needed (it is not the same annotation as it would have been detected above)
> + if (pView->isAnnotationPreviewActive())
> + {
> + UT_DEBUGMSG(("hyperlinkStatusBar: Deleting previous annotation preview...\n"));
> + pView->killAnnotationPreview();
> + }
> +
> UT_UTF8String sText;
> bool b = pView->getAnnotationText(pAnn->getPID(),sText);
> if(!b)
> @@ -13707,17 +13699,20 @@
> XAP_DialogFactory * pDialogFactory
> = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory());
>
> - AP_Preview_Annotation * pPview
> - = static_cast<AP_Preview_Annotation *>(pDialogFactory->requestDialog( AP_DIALOG_ID_ANNOTATION_PREVIEW));
> + AP_Preview_Annotation * pAnnPview
> + = static_cast<AP_Preview_Annotation *>(pDialogFactory->requestDialog(AP_DIALOG_ID_ANNOTATION_PREVIEW));
>
> UT_DEBUGMSG(("Previewing annotation text %d \n",sText.utf8_str()));
> - pPview->setXY(pG->tdu(xpos),pG->tdu(ypos));
> - pPview->runModeless(pFrame);
> + pAnnPview->setXY(pG->tdu(xpos),pG->tdu(ypos));
> + pAnnPview->runModeless(pFrame);
> +
> pView->setAnnotationPreviewActive(true);
> - // pPview->setTitle("n/a");
> - // pPview->setAuthor("n/a");
> - pPview->setDescription(sText.utf8_str());
> - pPview->draw();
> + pView->setActivePreviewAnnotation(pAnnPview); // this one is also needed to decide when to redraw the preview
> +
> + pAnnPview->setTitle("n/a"); // if those files ar to be hidden it should be at the GUI level (inside AP_Preview_Annotation)
> + pAnnPview->setAuthor("n/a");
> + pAnnPview->setDescription(sText.utf8_str());
> + pAnnPview->draw();
>
> return true;
> }
>
> Modified: abiword/branches/RiveraESoC/src/wp/ap/xp/ap_Preview_Annotation.cpp
> ===================================================================
> --- abiword/branches/RiveraESoC/src/wp/ap/xp/ap_Preview_Annotation.cpp 2007-08-10 00:03:40 UTC (rev 21702)
> +++ abiword/branches/RiveraESoC/src/wp/ap/xp/ap_Preview_Annotation.cpp 2007-08-10 02:00:38 UTC (rev 21703)
> @@ -105,49 +105,28 @@
> void AP_Preview_Annotation::draw(void)
> {
> UT_UCS4_cloneString_char (&m_drawString,
> - g_strconcat(m_pTitle, " (", m_pAuthor, "):", m_pDescription, NULL)
> + g_strconcat(m_pTitle, " (", m_pAuthor, "): ", m_pDescription, NULL)
> );
>
> //
> - // Get text decorations.
> + // Text decorations.
> //
> bool isUnder,isOver,isStrike;
>
> - /*const gchar * pDecor = getVal("text-decoration");
> - if(pDecor)
> - {
> - isUnder = (NULL != strstr(pDecor,));
> - isOver = (NULL != strstr(pDecor,));
> - isStrike = (NULL != strstr(pDecor,));
> - }
> - else
> - {*/
> isUnder = false; // "underline"
> isOver = false; // "overline"
> isStrike = false; // "line-through"
> - //}
>
> //
> - // Do foreground and background colors.
> + // Foreground and background colors.
> //
> UT_RGBColor FGcolor(0,0,0);
> - /*const char * pszFGColor = getVal("color");
> - if(pszFGColor)
> - UT_parseColor(getVal("color"),FGcolor);*/
> UT_RGBColor BGcolor(m_clrBackground);
> - /*const char * pszBGColor = getVal("bgcolor");
> - if(pszBGColor && strcmp(pszBGColor,"transparent") != 0)
> - UT_parseColor(getVal("bgcolor"),BGcolor);*/
> +
> //
> - // Get the font and bold/italic- ness
> + // Get the font and features
> //
> - //GR_Font * pFont;
> - /*const char* pszFamily = getVal();
> - const char* pszStyle = getVal();
> - const char* pszVariant = getVal();
> - const char* pszWeight = getVal();
> - const char* pszStretch = getVal();
> - const char* pszSize = getVal();*/
> +
> // "font-family"
> const char * pszFamily = "Times New Roman";
>
> @@ -202,8 +181,6 @@
> //
> GR_Painter painter(m_gc);
>
> - //if(pszBGColor)
> - //MAYBEpainter.fillRect(BGcolor,iLeft,iTop,twidth,m_iHeight);
> //
> // Do the draw chars at last!
> //
>
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the word
> unsubscribe in the message body.
Received on Fri Aug 10 04:10:51 2007

This archive was generated by hypermail 2.1.8 : Fri Aug 10 2007 - 04:10:51 CEST