[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1752
Date       : Fri Sep 15 10:13:05 BST 2006

Changed paths:
   M /Trunk/XaraLX/tools/bevinfo.cpp
   M /Trunk/XaraLX/tools/opbevel.cpp
   M /Trunk/XaraLX/tools/opbevel.h

Make changes to bevel joint type via an op to fix BZ #1234


Diff:
Index: Trunk/XaraLX/tools/bevinfo.cpp
===================================================================
--- Trunk/XaraLX/tools/bevinfo.cpp	(revision 1751)
+++ Trunk/XaraLX/tools/bevinfo.cpp	(revision 1752)
@@ -2156,17 +2156,40 @@
 ********************************************************************************************/
 void BevelInfoBarOp::ChangeJoinType(JointType jt)
 {
-	// Create the appropriate join type attribute.
-	AttrJoinType* pJoinAttr = new AttrJoinType;
-	if (pJoinAttr == NULL)
+		// update my variables first
+	BevelInfo BI;
+	
+	SetUpBevelInfo(&BI);
+
+	BI.m_bJointTypeChanged = TRUE;
+	BI.m_JointType = jt;
+
+	// check for zero selection
+	Range				Sel(*(GetApplication()->FindSelection()));	
+	RangeControl		rg = Sel.GetRangeControlFlags();
+	rg.PromoteToParent = TRUE;
+	Sel.SetRangeControl(rg);
+
+	AttrJoinType*		pJoinType = NULL;
+	if (Sel.IsEmpty())
 	{
-		InformWarning(_R(IDS_UNDO_MEMORY_FAILURE), _R(IDS_OK));
+		// do the default attribute
+		pJoinType = new AttrJoinType;
+
+		if (!pJoinType)
+		{
+			ERROR3("Can't create bevel indent");
+			return;
+		}
+
+		pJoinType->Value.JoinType = BI.m_JointType;
+
+		AttributeManager::AttributeSelected( pJoinType );
 		return;
 	}
-	pJoinAttr->Value.JoinType = jt;
 
-	// Let the attribute manager apply it to the selection.
-	AttributeManager::AttributeSelected(pJoinAttr);
+	// get the operation descriptor for the bevel change
+	DoBevelAttrChange(&BI);
 }
 
 
Index: Trunk/XaraLX/tools/opbevel.cpp
===================================================================
--- Trunk/XaraLX/tools/opbevel.cpp	(revision 1751)
+++ Trunk/XaraLX/tools/opbevel.cpp	(revision 1752)
@@ -488,11 +488,12 @@
 
 	NodeListItem *pNodeListItem = (NodeListItem *)BevelNodeList.GetHead();
 
-	AttrBevelIndent * pAttrIndent = NULL;
-	AttrBevelType   * pAttrType	  = NULL;
-	AttrBevelContrast * pAttrContrast = NULL;
-	AttrBevelLightAngle * pAttrLightAngle = NULL;
-	AttrBevelLightTilt * pAttrLightTilt = NULL;
+	AttrBevelIndent*	pAttrIndent = NULL;
+	AttrBevelType*		pAttrType	  = NULL;
+	AttrBevelContrast*	pAttrContrast = NULL;
+	AttrBevelLightAngle* pAttrLightAngle = NULL;
+	AttrBevelLightTilt* pAttrLightTilt = NULL;
+	AttrJoinType*		pAttrJointType = NULL;
 
 	HideNodeAction *pAction = NULL;
 
@@ -525,6 +526,7 @@
 		}
 
 		// insert nodes if they are defaults exist !
+		// JointType is not handled here, since it has a very different meaning for non-bevels
 		if (pBevelInfo->m_bBevelIndentChanged || pBevelInfo->m_bBevelDirectionChanged)
 		{
 			if (pBevelControl->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrBevelIndent), 
@@ -660,6 +662,7 @@
 				}
 			}
 		}
+
 		
 		// localise out all the attributes
 		if (!DoLocaliseCommonAttributes(pBevelControl, TRUE, TRUE))
@@ -918,7 +921,40 @@
 
 				m_NameID = _R(IDS_CHANGEBEVELLIGHTTILTOPNAME);
 			}
+			else
+			if (pCurrentNode->IS_KIND_OF(AttrJoinType) && pBevelInfo->m_bJointTypeChanged)
+			{
+				bGenerateNode = TRUE;
+				ALLOC_WITH_FAIL(pAttrJointType, (new AttrJoinType()), this);
 
+				pAttrJointType->Value.JoinType = pBevelInfo->m_JointType;
+
+				// hide the original node
+				if (!DoHideNode(pCurrentNode, TRUE, &pNodeHidden))
+				{
+					FailAndExecute();
+					End();
+					BevelNodeList.DeleteAll();
+					return;
+				}
+
+				// insert the new attribute node
+				pAttrJointType->AttachNode(pNodeHidden, NEXT);
+
+				// add an hide node action so that undo works ok
+				if (HideNodeAction::Init(this, GetUndoActionList(), (Node *)pAttrJointType,
+								FALSE, (Action **)&pAction, FALSE) != AC_OK)
+				{
+					FailAndExecute();
+					End();
+					BevelNodeList.DeleteAll();
+					return;
+				}
+
+				m_NameID = _R(IDS_CHANGEJOINTYPEOPNAME);
+			}
+
+
 //			else if (pCurrentNode->IS_KIND_OF(NodeBevel))
 //			{
 //				((NodeBevel*)pCurrentNode)->InvalidateBoundingRect();
Index: Trunk/XaraLX/tools/opbevel.h
===================================================================
--- Trunk/XaraLX/tools/opbevel.h	(revision 1751)
+++ Trunk/XaraLX/tools/opbevel.h	(revision 1752)
@@ -253,6 +253,7 @@
 		m_bBevelDirectionChanged	= FALSE;
 		m_bBevelLightTiltChanged    = FALSE;
 		m_bCreateNewBevels			= FALSE;
+		m_bJointTypeChanged			= FALSE;
 	}
 	
 	INT32			m_BevelType;				// the kind of bevel
@@ -267,6 +268,8 @@
 	BOOL		m_bBevelContrastChanged;	// has the contrast changed ?
 	double		m_Tilt;
 	BOOL		m_bBevelLightTiltChanged;
+	JointType	m_JointType;
+	BOOL		m_bJointTypeChanged;
 
 	BOOL		m_bCreateNewBevels;			// whether to create new bevels or not
 };


Xara