highlighting fix

This commit is contained in:
zueuk 2009-04-21 07:58:23 +00:00
parent d93f2e37b9
commit 58572f000c

View File

@ -259,8 +259,6 @@ type
procedure scrlXFormColorScroll(Sender: TObject; procedure scrlXFormColorScroll(Sender: TObject;
ScrollCode: TScrollCode; var ScrollPos: Integer); ScrollCode: TScrollCode; var ScrollPos: Integer);
procedure scrlXFormColorChange(Sender: TObject); procedure scrlXFormColorChange(Sender: TObject);
// procedure chkUseXFormColorClick(Sender: TObject);
// procedure chkHelpersClick(Sender: TObject);
procedure txtXFormColorExit(Sender: TObject); procedure txtXFormColorExit(Sender: TObject);
procedure txtXFormColorKeyPress(Sender: TObject; var Key: Char); procedure txtXFormColorKeyPress(Sender: TObject; var Key: Char);
procedure txtSymmetrySet(Sender: TObject); procedure txtSymmetrySet(Sender: TObject);
@ -422,11 +420,12 @@ type
Pivot: TSPoint; Pivot: TSPoint;
VarsCache: array of double; // hack: to prevent slow valuelist redraw VarsCache: array of double; // hack: to prevent slow valuelist redraw
// -JF- 64 wasn't big enough... buffer overrun // -JF- 64 wasn't big enough... buffer overrun
// VariablesOddness: array of integer; VariationListColors, VariationListTextColors: array of TColor;
VariableUsed: array of bool; VariableUsed: array of bool;
// VariableFavsHighlight: array of bool; //hmm
VariableListColors, VariableListTextColors: array of TColor; VariableListColors, VariableListTextColors: array of TColor;
VariableListStrings: TStrings; VariableListStrings: TStrings;
variableListCount: integer; variableListCount: integer;
@ -692,8 +691,6 @@ begin
end; end;
procedure TEditForm.UpdateDisplay(PreviewOnly: boolean = false); procedure TEditForm.UpdateDisplay(PreviewOnly: boolean = false);
var
i, j, n: integer;
begin begin
// currently EditForm does not really know if we select another // currently EditForm does not really know if we select another
// flame in the Main Window - which is not good... // flame in the Main Window - which is not good...
@ -734,12 +731,6 @@ begin
if MainForm.UndoIndex = 0 then AutoZoom // auto-zoom only on 'new' flame if MainForm.UndoIndex = 0 then AutoZoom // auto-zoom only on 'new' flame
else TriangleView.Invalidate; else TriangleView.Invalidate;
for i := 0 to GetNrRegisteredVariations-1 do begin
n := GetRegisteredVariation(i).firstVariableIndex;
// for j := 0 to GetRegisteredVariation(i).GetNrVariables-1 do
// VariableFavsHighlight[n + j] := FavouriteVariations[NRLOCVAR + i];
end;
end; end;
procedure TEditForm.DrawPreview; procedure TEditForm.DrawPreview;
@ -770,7 +761,7 @@ end;
procedure TEditForm.ShowSelectedInfo; procedure TEditForm.ShowSelectedInfo;
var var
i, j, n: integer; i, j, k, n: integer;
v: double; v: double;
strval: string; strval: string;
@ -897,25 +888,39 @@ begin
if v <> VarsCache[i] then if v <> VarsCache[i] then
begin begin
VarsCache[i]:=v; VarsCache[i] := v;
VEVars.Values[VarNames(i)] := FloatToStr(v); //Format('%.6g', [v]); VEVars.Values[VarNames(i)] := FloatToStr(v); //Format('%.6g', [v]);
//if (v = 0) and (FavouriteVariations[i] = false) then VEVars.RowHeights[i+1] := -1 //if (v = 0) and (FavouriteVariations[i] = false) then VEVars.RowHeights[i+1] := -1
//else VEVars.RowHeights[i+1] := VEVars.DefaultRowHeight; //else VEVars.RowHeights[i+1] := VEVars.DefaultRowHeight;
nonzero := (v <> 0);
if nonzero then
VariationListTextColors[i] := IfThen(FavouriteVariations[i], clFavVariation, vleVariables.Font.Color)
else
VariationListTextColors[i] := IfThen(FavouriteVariations[i], clFavVarGreyed, clGrayText);
if i >= NRLOCVAR then begin if i >= NRLOCVAR then begin
n := GetRegisteredVariation(i - NRLOCVAR).GetNrVariables;
if n > 0 then begin
k := GetRegisteredVariation(i - NRLOCVAR).firstVariableIndex;
for j := k to k+n-1 do begin
usedVarsChanged := usedVarsChanged or (VariableUsed[j] <> nonzero);
VariableUsed[j] := nonzero;
end;
end;
{
n := GetRegisteredVariation(i - NRLOCVAR).GetNrVariables; n := GetRegisteredVariation(i - NRLOCVAR).GetNrVariables;
if n > 0 then begin if n > 0 then begin
j := GetRegisteredVariation(i - NRLOCVAR).firstVariableIndex; j := GetRegisteredVariation(i - NRLOCVAR).firstVariableIndex;
repeat repeat
nonzero := (v <> 0);
usedVarsChanged := usedVarsChanged or (VariableUsed[j] <> nonzero); usedVarsChanged := usedVarsChanged or (VariableUsed[j] <> nonzero);
VariableUsed[j] := nonzero; VariableUsed[j] := nonzero;
Inc(j); Inc(j);
Dec(n); Dec(n);
until n = 0; until n = 0;
end; end;
}
end; end;
end; end;
end; end;
@ -932,9 +937,9 @@ begin
GetVariable(varname, v); GetVariable(varname, v);
VariableListStrings.Add(varname + '=' + FloatToStr(v)); VariableListStrings.Add(varname + '=' + FloatToStr(v));
if i <= NumBuiltinVariations then if i <= NumBuiltinVariations then
VariableListColors[n] := ParametricVarColors[n and 1 xor 1] VariableListColors[n] := ParametricVarColors[n and 1]
else else
VariableListColors[n] := PluginVarColors[n and 1 xor 1]; VariableListColors[n] := PluginVarColors[n and 1];
VariableListTextColors[n] := IfThen(FavouriteVariations[i], clFavVariation, vleVariables.Font.Color); VariableListTextColors[n] := IfThen(FavouriteVariations[i], clFavVariation, vleVariables.Font.Color);
Inc(n); Inc(n);
end; end;
@ -1781,7 +1786,6 @@ end;
procedure TEditForm.FormCreate(Sender: TObject); procedure TEditForm.FormCreate(Sender: TObject);
var var
i: integer; i: integer;
j, n: integer;
listBkgColor: TColor; listBkgColor: TColor;
begin begin
// Custom control setup // Custom control setup
@ -1806,8 +1810,12 @@ begin
TriangleView.OnExit := TriangleViewExit; TriangleView.OnExit := TriangleViewExit;
TriangleView.OnMouseLeave := TriangleViewmouseLeave; TriangleView.OnMouseLeave := TriangleViewmouseLeave;
SetLength(VarsCache, NRVAR);
SetLength(VariationListColors, NRVAR);
SetLength(VariationListTextColors, NRVAR);
for i := 0 to NRVAR-1 do begin for i := 0 to NRVAR-1 do begin
VEVars.InsertRow(Varnames(i), '0', True); VEVars.InsertRow(Varnames(i), '0', True);
VarsCache[i] := MinDouble;
end; end;
SetLength(VariableUsed, GetNrVariableNames); SetLength(VariableUsed, GetNrVariableNames);
@ -1866,18 +1874,21 @@ begin
MemTriangle.x[2] := 0; MemTriangle.x[2] := 0;
MemTriangle.y[2] := 1; MemTriangle.y[2] := 1;
SetLength(VarsCache, NRVAR);
for i := 0 to NRVAR-1 do
VarsCache[i] := MinDouble;
listBkgColor := VEVars.Canvas.Brush.Color; listBkgColor := VEVars.Canvas.Brush.Color;
NormalVarColors[0] := MixColor(listBkgColor, clNormalHilite); NormalVarColors[1] := MixColor(listBkgColor, clNormalHilite);
NormalVarColors[1] := listBkgColor; NormalVarColors[0] := listBkgColor;
ParametricVarColors[0] := MixColor(listBkgColor, clParametricHilite); ParametricVarColors[1] := MixColor(listBkgColor, clParametricHilite);
ParametricVarColors[1] := MixColor(listBkgColor, ParametricVarColors[0]); ParametricVarColors[0] := MixColor(listBkgColor, ParametricVarColors[1]);
PluginVarColors[0] := MixColor(listBkgColor, clPluginsHilite); PluginVarColors[1] := MixColor(listBkgColor, clPluginsHilite);
PluginVarColors[1] := MixColor(listBkgColor, PluginVarColors[0]); PluginVarColors[0] := MixColor(listBkgColor, PluginVarColors[1]);
for i := 0 to NrLocVar-1 do
VariationListColors[i] := NormalVarColors[i and 1];
for i := NrLocVar to NumBuiltinVariations-1 do
VariationListColors[i] := ParametricVarColors[i and 1];
for i := NumBuiltinVariations to NrVAR-1 do
VariationListColors[i] := PluginVarColors[i and 1];
ChaosColors[0] := MixColor(listBkgColor, clChaosHilite); ChaosColors[0] := MixColor(listBkgColor, clChaosHilite);
ChaosColors[1] := MixColor(listBkgColor, ChaosColors[0]); ChaosColors[1] := MixColor(listBkgColor, ChaosColors[0]);
@ -3203,9 +3214,6 @@ begin
end; end;
procedure TEditForm.txtSymmetrKeyPress(Sender: TObject; var Key: Char); procedure TEditForm.txtSymmetrKeyPress(Sender: TObject; var Key: Char);
var
Allow: boolean;
NewVal, OldVal: double;
begin begin
if key = #13 then if key = #13 then
begin begin
@ -3296,7 +3304,6 @@ procedure TEditForm.VEVarsMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
var var
cell: TGridCoord; cell: TGridCoord;
i, n: integer;
begin begin
if Button = mbLeft then begin if Button = mbLeft then begin
varDragOld:=x; varDragOld:=x;
@ -4479,6 +4486,7 @@ procedure TEditForm.VEVarsDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); Rect: TRect; State: TGridDrawState);
begin begin
if (ARow = 0) or (gdSelected in State) then exit; if (ARow = 0) or (gdSelected in State) then exit;
{
if (ARow <= NRLOCVAR) then if (ARow <= NRLOCVAR) then
VEVars.canvas.brush.Color := NormalVarColors[ARow and 1] VEVars.canvas.brush.Color := NormalVarColors[ARow and 1]
else else
@ -4500,6 +4508,13 @@ begin
VEVars.canvas.Font.Color := clFavVariation; VEVars.canvas.Font.Color := clFavVariation;
VEVars.canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, VEVars.Cells[ACol,ARow]); VEVars.canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, VEVars.Cells[ACol,ARow]);
}
with VEVars.Canvas do begin
Brush.Color := VariationListColors[ARow-1];
FillRect(Rect);
Font.Color := VariationListTextColors[ARow-1];
TextRect(Rect, Rect.Left+2, Rect.Top+2, VEVars.Cells[ACol,ARow]);
end;
end; end;
procedure TEditForm.tbEnableFinalXformClick(Sender: TObject); procedure TEditForm.tbEnableFinalXformClick(Sender: TObject);
@ -5239,23 +5254,16 @@ var
begin begin
editor := TEditorHacker(TGridHacker(sender).InplaceEditor); editor := TEditorHacker(TGridHacker(sender).InplaceEditor);
if Assigned(editor) then begin if Assigned(editor) then begin
if (ARow <= NRLOCVAR) then editor.Color := VariationListColors[ARow-1];
editor.Color := NormalVarColors[ARow and 1] //editor.Font.Color := VariationListTextColors[ARow-1];
else
begin if (VEVars.Cells[1, ARow] <> '0') or (value <> '0') then begin
if ARow <= NumBuiltinVariations then editor.Font.Color := IfThen(FavouriteVariations[ARow-1], clFavVariation, VEVars.Font.Color);
editor.Color := ParametricVarColors[ARow and 1]
else
editor.Color := PluginVarColors[ARow and 1];
end;
if VEVars.Cells[1,Arow] = '0' then begin
if FavouriteVariations[ARow-1] = true then
editor.Font.Color := clFavVarGreyed
else
editor.Font.Color := clGrayText;
end end
else if FavouriteVariations[ARow-1] = true then else begin
editor.Font.Color := clFavVariation; editor.Font.Color := IfThen(FavouriteVariations[ARow-1], clFavVarGreyed, clGrayText);
end;
end; end;
end; end;