ecere/gui/DropBox; ide/Property Sheet: (#818) Fixed counter-intuitive selection colors
authorJerome St-Louis <jerome@ecere.com>
Thu, 8 Aug 2013 04:11:16 +0000 (00:11 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 8 Aug 2013 04:11:16 +0000 (00:11 -0400)
- Also tweaked EditBox, ListBox to handle black vs unset through ColorAlpha

ecere/src/gui/controls/DropBox.ec
ecere/src/gui/controls/EditBox.ec
ecere/src/gui/controls/ListBox.ec
ide/src/designer/Sheet.ec

index 2550242..3e23913 100644 (file)
@@ -32,6 +32,14 @@ public class DropBox : CommonControl
    {
       listBox.background = background;
    };
+   watch(selectionColor)
+   {
+      listBox.selectionColor = selectionColor;
+   };
+   watch(selectionText)
+   {
+      listBox.selectionText = selectionText;
+   };
 
 public:
    property bool activeStipple
@@ -201,6 +209,7 @@ public:
       get { return style.showNone; }
    }
    property Color selectionColor { set { selectionColor = value; } get { return selectionColor; } isset { return selectionColor ? true : false; } };
+   property Color selectionText  { set { selectionText = value; } get { return selectionText; } isset { return selectionText ? true : false; } };
    property bool changeContents
    {
       set { style.changeContents = value; }
@@ -635,7 +644,7 @@ private:
          if(!isEnabled)
             surface.SetForeground(Color { 85,85,85 } );
          else
-            surface.SetForeground((active && style.activeColor && !pulledWindow /*listBox.visible*/) ? SELECTION_TEXT : foreground);
+            surface.SetForeground((active && style.activeColor && !pulledWindow /*listBox.visible*/) ? selectionText : foreground);
          surface.TextOpacity(true);
 
          if(currentRow)
@@ -915,5 +924,8 @@ private:
    EditBox editBox;
    Alignment alignment;
    DataRow noneRow;
-   Color selectionColor;
+   ColorAlpha selectionColor, selectionText;
+
+   selectionColor = SELECTION_COLOR;
+   selectionText = SELECTION_TEXT;
 };
index 5bca7ee..498a3cd 100644 (file)
@@ -945,7 +945,7 @@ private:
    int caretX, caretY;
    UndoBuffer undoBuffer { data = this };
    int savedAction;
-   Color selectionColor, selectionText;
+   ColorAlpha selectionColor, selectionText;
    SyntaxColorScheme colorScheme { };
 
    menu = Menu { };
index 7bffe24..32037d5 100644 (file)
@@ -4581,6 +4581,6 @@ private:
 
    // Only used for OnMouseMove so far, for avoiding problems with consequential mouse moves
    bool insideNotifySelect;
-   Color selectionColor, selectionText, stippleColor;
+   ColorAlpha selectionColor, selectionText, stippleColor;
    stippleColor = 0xFFFFFF80;
 };
index 1074438..45e86c6 100644 (file)
@@ -268,6 +268,9 @@ void SetProperty(Property prop, Instance object, DataValue value)
    }
 }
 
+static define sheetSelectionColor = Color { 170, 220, 255 };
+static define sheetSelectionText = black;
+
 class Sheet : Window
 {
    text = $"Sheet";
@@ -453,6 +456,8 @@ class Sheet : Window
       hasVertScroll = true, alwaysEdit = true, collapseControl = true, resizable = true;
       background = viewsBackground;
       foreground = viewsText;
+      selectionText = sheetSelectionText;
+      selectionColor = sheetSelectionColor;
 
       bool NotifySelect(ListBox control, DataRow row, Modifiers keyFlags)
       {
@@ -1623,6 +1628,18 @@ public:
             delete subData;
 
             editData.font = { font.faceName, font.size, font.bold };
+            if(eClass_IsDerived(editData._class, class(DropBox)))
+            {
+               DropBox db = (DropBox)editData;
+               db.selectionColor = sheetSelectionColor;
+               db.selectionText = sheetSelectionText;
+            }
+            else if(eClass_IsDerived(editData._class, class(EditBox)))
+            {
+               EditBox eb = (EditBox)editData;
+               eb.selectionColor = sheetSelectionColor;
+               eb.selectionText = sheetSelectionText;
+            }
          }
       }
       return editData;