Browse Source

GuiEditorCtrl Themed

Tied the themes into GuiEditorCtrl so that the colors used by the control are based on the profile.
Peter Robinson 2 years ago
parent
commit
54ddb6aad7

+ 23 - 1
editor/EditorCore/Themes/BaseTheme/BaseTheme.cs

@@ -67,6 +67,7 @@ function BaseTheme::onAdd(%this)
 	%this.makeGraphProfile();
 	%this.makeTextDisplayProfile();
 	%this.makeSubListProfile();
+	%this.makeGuiEditorProfile();
 }
 
 function BaseTheme::init(%this)
@@ -1900,7 +1901,7 @@ function BaseTheme::makeGraphProfile(%this)
 	{
 		padding = 4;
 		border = %this.borderSize;
-		borderColor = %this.color3; //Used for the border as normal
+		borderColor = %this.color1; //Used for the border as normal
 	};
 
 	%this.graphProfile = new GuiControlProfile()
@@ -2007,6 +2008,27 @@ function BaseTheme::makeTextDisplayProfile(%this)
 	};
 }
 
+function BaseTheme::makeGuiEditorProfile(%this)
+{
+	%border = new GuiBorderProfile()
+	{
+		border = 1;
+		borderColor = %this.color1; //Used for a single selected nut without key focus
+		borderColorHL = %this.color1; //Used for a multiple selected nuts without key focus
+		borderColorSL = %this.color1; //Used for nuts if the editor has key focus
+	};
+
+	%this.guiEditorProfile = new GuiControlProfile()
+	{
+		fillColor = %this.color4; //Used single selected nuts
+		fillColorHL = %this.color3; //Used for multi selected nuts
+		fillColorSL = %this.color5; //Used for nuts if the editor has key focus
+		fillColorNA = %this.color5; //Used for the add set control and ruler lines
+		
+		borderDefault = %border;
+	};
+}
+
 //Positive values are brighter, negative are darker
 function BaseTheme::adjustValue(%this, %color, %percent)
 {

+ 1 - 1
editor/GuiEditor/GuiEditor.cs

@@ -53,13 +53,13 @@ function GuiEditor::create( %this )
 
     %this.brain = new GuiEditCtrl()
     {
-        Profile = "GuiTextEditProfile";
         Class = "GuiEditorBrain";
 		HorizSizing = "width";
         VertSizing = "height";
         Position = "0 0";
         Extent = %this.guiPage.getExtent();
     };
+    ThemeManager.setProfile(%this.brain, "guiEditorProfile");
     %this.guiPage.add(%this.brain);
 
     %this.ctrlListWindow = new GuiWindowCtrl()

+ 40 - 30
engine/source/gui/editor/guiEditCtrl.cc

@@ -420,31 +420,32 @@ void GuiEditCtrl::drawNuts(RectI &box, ColorI &outlineColor, ColorI &nutColor)
    S32 lx = box.point.x, rx = box.point.x + box.extent.x - 1;
    S32 cx = (lx + rx) >> 1;
    S32 ty = box.point.y, by = box.point.y + box.extent.y - 1;
-   S32 cy = (ty + by) >> 1;
-   ColorF greenLine(0.0f, 1.0f, 0.0f ,0.6f);
-   ColorF lightGreenLine(0.0f, 1.0f, 0.0f, 0.3f);
+   S32 cy = (ty + by) >> 1; 
+   ColorI fillColor = mProfile->getFillColor(DisabledState);
+   ColorI weakColor(fillColor.red, fillColor.green, fillColor.blue, 120);
+   ColorI strongColor(fillColor.red, fillColor.green, fillColor.blue, 200);
    if(lx > 0 && ty > 0)
    {
-      dglDrawLine(0, ty, lx, ty, greenLine);
-      dglDrawLine(lx, 0, lx, ty, greenLine);
+      dglDrawLine(0, ty, lx, ty, weakColor);
+      dglDrawLine(lx, 0, lx, ty, weakColor);
    }
    if(lx > 0 && by > 0)
-      dglDrawLine(0, by, lx, by, greenLine);
+      dglDrawLine(0, by, lx, by, weakColor);
 
    if(rx > 0 && ty > 0)
-      dglDrawLine(rx, 0, rx, ty, greenLine);
+      dglDrawLine(rx, 0, rx, ty, weakColor);
 
    Point2I extent = localToGlobalCoord(mBounds.extent);
 
    if(lx < extent.x && by < extent.y)
-      dglDrawLine(lx, by, lx, extent.y, lightGreenLine);
+      dglDrawLine(lx, by, lx, extent.y, strongColor);
    if(rx < extent.x && by < extent.y)
    {
-      dglDrawLine(rx, by, rx, extent.y, lightGreenLine);
-      dglDrawLine(rx, by, extent.x, by, lightGreenLine);
+      dglDrawLine(rx, by, rx, extent.y, strongColor);
+      dglDrawLine(rx, by, extent.x, by, strongColor);
    }
    if(rx < extent.x && ty < extent.y)
-      dglDrawLine(rx, ty, extent.x, ty, lightGreenLine);
+      dglDrawLine(rx, ty, extent.x, ty, strongColor);
 
    // adjust nuts, so they dont straddle the controls
    lx -= NUT_SIZE;
@@ -489,19 +490,22 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
          cext = mCurrentAddSet->getExtent();
          ctOffset = mCurrentAddSet->localToGlobalCoord(Point2I(0,0));
          RectI box(ctOffset.x, ctOffset.y, cext.x, cext.y);
-
-            box.inset(-5, -5);
-         dglDrawRect(box, ColorI(0, 101, 0,160));
-            box.inset(1,1);
-         dglDrawRect(box, ColorI(0, 101, 0,170));
-            box.inset(1,1);
-         dglDrawRect(box, ColorI(0, 101, 0,180));
-            box.inset(1,1);
-         dglDrawRect(box, ColorI(0, 101, 0,190));
-            box.inset(1,1);
-         dglDrawRect(box, ColorI(0, 101, 0,200));
-			box.inset(1, 1);
-		 dglDrawRect(box, ColorI(0, 101, 0, 220));
+		 ColorI fillColor = mProfile->getFillColor(DisabledState);
+		 bool isRoot = (getCurrentAddSet() == mContentControl);
+		 S32 d = isRoot ? 1 : -1;
+		 if (!isRoot)
+		 {
+			 box.inset(d, d);
+		 }
+         dglDrawRect(box, ColorI(fillColor.red, fillColor.green, fillColor.blue, 200));
+            box.inset(d,d);
+         dglDrawRect(box, ColorI(fillColor.red, fillColor.green, fillColor.blue, 180));
+            box.inset(d,d);
+         dglDrawRect(box, ColorI(fillColor.red, fillColor.green, fillColor.blue, 160));
+            box.inset(d,d);
+         dglDrawRect(box, ColorI(fillColor.red, fillColor.green, fillColor.blue, 140));
+            box.inset(d,d);
+         dglDrawRect(box, ColorI(fillColor.red, fillColor.green, fillColor.blue, 120));
       }
       Vector<GuiControl *>::iterator i;
       bool multisel = mSelectedControls.size() > 1;
@@ -511,10 +515,14 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
          cext = ctrl->getExtent();
          ctOffset = ctrl->localToGlobalCoord(Point2I(0,0));
          RectI box(ctOffset.x,ctOffset.y, cext.x, cext.y);
-         ColorI nutColor = multisel ? ColorI(255,255,255) : ColorI(0,0,0);
-         ColorI outlineColor = multisel ? ColorI(0,0,0) : ColorI(255,255,255);
-         if(!keyFocused)
-            nutColor.set(128,128,128);
+		 auto border = mProfile->getTopBorder();
+         ColorI nutColor = multisel ? mProfile->getFillColor(HighlightState) : mProfile->getFillColor(NormalState);
+         ColorI outlineColor = multisel ? border->getBorderColor(HighlightState) : border->getBorderColor(NormalState);
+         if(keyFocused)
+		 {
+            nutColor = mProfile->getFillColor(SelectedState);
+			outlineColor = border->getBorderColor(SelectedState);
+		 }
 
          drawNuts(box, outlineColor, nutColor);
       }
@@ -523,7 +531,8 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
          RectI b;
          getDragRect(b);
          b.point += offset;
-         dglDrawRect(b, ColorI(255, 255, 255));
+		 ColorI fillColor = mProfile->getFillColor(DisabledState);
+         dglDrawRect(b, fillColor);
       }
    }
 
@@ -555,12 +564,13 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
       AssertFatal(ndot <= maxdot, "dot overflow");
       
       // draw the points.
+	  ColorI fillColor = mProfile->getFillColor(DisabledState);
       glEnableClientState(GL_VERTEX_ARRAY);
       glEnable( GL_BLEND );
       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
 
       glVertexPointer(2, GL_FLOAT, 0, dots);
-      glColor4ub(50, 50, 254, 200);
+      glColor4ub(fillColor.red, fillColor.green, fillColor.blue, 200);
       glDrawArrays( GL_POINTS, 0, ndot);
       glDisableClientState(GL_VERTEX_ARRAY);
       glDisable(GL_BLEND);