Browse Source

add center alignment option to uiml layouter

Kolja Strohm 2 years ago
parent
commit
97f5e9f1b1
3 changed files with 13 additions and 5 deletions
  1. 8 0
      UIMLView.cpp
  2. 4 4
      UIMLView.h
  3. 1 1
      Zeichnung.cpp

+ 8 - 0
UIMLView.cpp

@@ -48,6 +48,8 @@ void UIMLElement::layout(XML::Element& element, Zeichnung& z, int pWidth, int pH
 			x = 0;
 		else if (la.istGleich("end"))
 			x = pWidth;
+		else if (la.istGleich("center"))
+			x = pWidth / 2 - width / 2;
 		else
 		{
 			XML::Editor ed = element.zParent()->selectChildsByAttribute("id", la);
@@ -74,6 +76,8 @@ void UIMLElement::layout(XML::Element& element, Zeichnung& z, int pWidth, int pH
 			x = -z.getBreite();
 		else if (ra.istGleich("end"))
 			x = pWidth - z.getBreite();
+		else if (ra.istGleich("center"))
+			x = pWidth / 2 - width / 2;
 		else
 		{
 			XML::Editor ed = element.zParent()->selectChildsByAttribute("id", ra);
@@ -100,6 +104,8 @@ void UIMLElement::layout(XML::Element& element, Zeichnung& z, int pWidth, int pH
 			y = 0;
 		else if (ta.istGleich("end"))
 			y = pHeight;
+		else if (ta.istGleich("center"))
+			y = pHeight / 2 - height / 2;
 		else
 		{
 			XML::Editor ed = element.zParent()->selectChildsByAttribute("id", ta);
@@ -126,6 +132,8 @@ void UIMLElement::layout(XML::Element& element, Zeichnung& z, int pWidth, int pH
 			y = -z.getHeight();
 		else if (ba.istGleich("end"))
 			y = pHeight - z.getHeight();
+		else if (ba.istGleich("center"))
+			y = pHeight / 2 - height / 2;
 		else
 		{
 			XML::Editor ed = element.zParent()->selectChildsByAttribute("id", ba);

+ 4 - 4
UIMLView.h

@@ -129,10 +129,10 @@ namespace Framework
 		- margin-top (integer, optional % char at end),
 		- margin-right (integer, optional % char at end),
 		- margin-bottom (integer, optional % char at end),
-		- align-left (string (id values of other elements or keywords: start, end)),
-		- align-top (string (id values of other elements or keywords: start, end)),
-		- align-bottom ((string (id values of other elements or keywords: start, end)),
-		- align-right (string (id values of other elements or keywords: start, end)),
+		- align-left (string (id values of other elements or keywords: start, end, center)),
+		- align-top (string (id values of other elements or keywords: start, end, center)),
+		- align-bottom ((string (id values of other elements or keywords: start, end, center)),
+		- align-right (string (id values of other elements or keywords: start, end, center)),
 		- tooltip (string),
 		- style (hex __int64),
 		- class (string (id of class element))

+ 1 - 1
Zeichnung.cpp

@@ -213,7 +213,7 @@ void Zeichnung::doPublicMausEreignis( MausEreignis &me ) // ruft Mak auf
     me.mx -= pos.x, me.my -= pos.y;
     if( me.insideParent || hatStyle( Style::MEIgnoreParentInside ) )
     {
-        bool userRet = me.verarbeitet || !me.insideParent || hatStyleNicht( Style::Erlaubt ) || ( inside && mak && mak( makParam, this, me ) );
+        bool userRet = hatStyle(Style::Erlaubt) && (me.verarbeitet || !me.insideParent || ( inside && mak && mak( makParam, this, me ) ));
         bool vera = me.verarbeitet;
         doMausEreignis( me, userRet );
         if( nMak && me.verarbeitet && !vera && hatStyle( Style::Erlaubt ) && me.insideParent && inside )