r14979 by jghali - scripter : modify setImageOffset() to use values similar to those shown in PP for consistency with setImageScale()

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 17 01:10:32 CEST 2010


Revision: 14979
Author: jghali
Date: 2010-04-16T23:07:17.777349Z
Commit message: scripter : modify setImageOffset() to use values similar to those shown in PP for consistency with setImageScale()

Changeset: 
M  /branches/Version135/Scribus/scribus/doc/fr/scripterapi-setobjprop.html
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdmani.h
M  /branches/Version135/Scribus/scribus/doc/en/scripterapi-setobjprop.html

Diffs:
Index: scribus/doc/en/scripterapi-setobjprop.html
===================================================================
--- scribus/doc/en/scripterapi-setobjprop.html	(revision 14978)
+++ scribus/doc/en/scripterapi-setobjprop.html	(revision 14979)
@@ -99,7 +99,7 @@
 
 <dt><a name="-setImageOffset"><strong>setImageOffset</strong></a>(...)</dt>
 <dd><code>setImageOffset(x, y [, "name"])</code>
-<p>Sets the internal offset of the picture in the image frame "name". If "name" is not given the currently selected item is used. Internal offsets are different from the values shown on properties palette.</p>
+<p>Sets the position of the picture in the image frame "name". If "name" is not given the currently selected item is used. The specified offset values are equal to the values shown on properties palette when point unit is used.</p>
 <p>May raise <a href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the target frame is not an image frame</p></dd>
 
 <dt><a name="-traceText"><strong>traceText</strong></a>(...)</dt>
Index: scribus/doc/fr/scripterapi-setobjprop.html
===================================================================
--- scribus/doc/fr/scripterapi-setobjprop.html	(revision 14978)
+++ scribus/doc/fr/scripterapi-setobjprop.html	(revision 14979)
@@ -30,7 +30,7 @@
 
 <dt><a name="-setImageOffset"><strong>setImageOffset</strong></a>(...)</dt>
 <dd><code><a href="#-setImageOffset">setImageOffset</a>(x, y [, "nom"])</code>
-<p>D&eacute;finit les coordonn&eacute;es de position internes de l'image dans le cadre d'image "nom". Si le "nom" n'est pas fourni, l'&eacute;l&eacute;ment s&eacute;lectionn&eacute; est utilis&eacute;.  Les coordonn&eacute;es de position internes sont diff&eacute;rentes des valeurs indiqu&eacute;es dans la palette des propri&eacute;t&eacute;s.</p>
+<p>D&eacute;finit la position de l'image dans le cadre d'image "nom". Si le "nom" n'est pas fourni, l'&eacute;l&eacute;ment s&eacute;lectionn&eacute; est utilis&eacute;.  Les coordonn&eacute;es sp&eacute;cifi&eacute;es sont &eacute;gales aux valeurs indiqu&eacute;es dans la palette des propri&eacute;t&eacute;s lorsque l'unit&eacute; utilis&eacute;e est le point.</p>
 <p>Peut g&eacute;n&eacute;rer <a href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> si le cadre cible n'est pas un cadre d'image</p></dd>
 
 <dt><a name="-setCornerRadius"><strong>setCornerRadius</strong></a>(...)</dt>
Index: scribus/plugins/scriptplugin/cmdmani.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14978)
+++ scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14979)
@@ -83,44 +83,46 @@
 
 PyObject *scribus_setimageoffset(PyObject* /* self */, PyObject* args)
 {
-        char *Name = const_cast<char*>("");
-        double x, y;
-        if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
-                return NULL;
-        if(!checkHaveDocument())
-                return NULL;
-        PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
-        if (item == NULL)
-                return NULL;
-        if (! item->asImageFrame())
-        {
-                PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
-                return NULL;
-        }
+	char *Name = const_cast<char*>("");
+	double x, y;
+	if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+	if (item == NULL)
+		return NULL;
+	if (! item->asImageFrame())
+	{
+		PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
+		return NULL;
+	}
 
-        // Grab the old selection - but use it only where is there any
-        Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
-        bool hadOrigSelection = (tempSelection.count() != 0);
+	// Grab the old selection - but use it only where is there any
+	Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
+	bool hadOrigSelection = (tempSelection.count() != 0);
 
-        ScCore->primaryMainWindow()->doc->m_Selection->clear();
-        // Clear the selection
-        ScCore->primaryMainWindow()->view->Deselect();
-        // Select the item, which will also select its group if
-        // there is one.
-        ScCore->primaryMainWindow()->view->SelectItemNr(item->ItemNr);
+	ScCore->primaryMainWindow()->doc->m_Selection->clear();
+	// Clear the selection
+	ScCore->primaryMainWindow()->view->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	ScCore->primaryMainWindow()->view->SelectItemNr(item->ItemNr);
 
-        // offset
-        ScCore->primaryMainWindow()->doc->itemSelection_SetImageOffset(x, y); //CB why when this is done above?
-        ScCore->primaryMainWindow()->doc->updatePic();
-        
-        // Now restore the selection.
-        ScCore->primaryMainWindow()->view->Deselect();
-        if (hadOrigSelection)
-                *ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
-                
-//      Py_INCREF(Py_None);
-//      return Py_None;
-        Py_RETURN_NONE;
+	// offset
+	double newOffsetX = x / ((item->imageXScale() != 0.0) ? item->imageXScale() : 1);
+	double newOffsetY = y / ((item->imageYScale() != 0.0) ? item->imageYScale() : 1);
+	ScCore->primaryMainWindow()->doc->itemSelection_SetImageOffset(newOffsetX, newOffsetY); //CB why when this is done above?
+	ScCore->primaryMainWindow()->doc->updatePic();
+
+	// Now restore the selection.
+	ScCore->primaryMainWindow()->view->Deselect();
+	if (hadOrigSelection)
+		*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
+
+	//      Py_INCREF(Py_None);
+	//      return Py_None;
+	Py_RETURN_NONE;
 }
 
 
Index: scribus/plugins/scriptplugin/cmdmani.h
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.h	(revision 14978)
+++ scribus/plugins/scriptplugin/cmdmani.h	(revision 14979)
@@ -185,8 +185,10 @@
 PyDoc_STRVAR(scribus_setimageoffset__doc__,
 QT_TR_NOOP("setImageOffset(x, y [, \"name\"])\n\
 \n\
-Sets the internal offset of the picture in the image frame \"name\".\n\
+Sets the position of the picture in the image frame \"name\".\n\
 If \"name\" is not given the currently selected item is used.\n\
+The specified offset values are equal to the values shown on \n\
+properties palette when point unit is used.\n\
 \n\
 May raise WrongFrameTypeError if the target frame is not an image frame\n\
 "));




More information about the scribus-commit mailing list