mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 01:02:17 -05:00
Fixed a memory leak.
BrigthnessAdjust -> BrightnessAdjust git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@345 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
ffcb20146b
commit
fed81fb976
@ -11,22 +11,23 @@ object FunctionListFrame: TFunctionListFrame
|
||||
DesignTop = 219
|
||||
object FunctionList: TTreeView
|
||||
Left = 0
|
||||
Height = 300
|
||||
Height = 306
|
||||
Top = 0
|
||||
Width = 115
|
||||
Align = alClient
|
||||
DefaultItemHeight = 19
|
||||
DefaultItemHeight = 15
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
OnDeletion = FunctionListDeletion
|
||||
OnMouseDown = FunctionListMouseDown
|
||||
OnMouseUp = FunctionListMouseUp
|
||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
|
||||
end
|
||||
object editSearchList: TEdit
|
||||
Left = 0
|
||||
Height = 27
|
||||
Top = 300
|
||||
Height = 21
|
||||
Top = 306
|
||||
Width = 115
|
||||
Align = alBottom
|
||||
OnChange = editSearchListChange
|
||||
|
@ -4,13 +4,13 @@ LazarusResources.Add('TFunctionListFrame','FORMDATA',[
|
||||
'TPF0'#18'TFunctionListFrame'#17'FunctionListFrame'#4'Left'#2#0#6'Height'#3'G'
|
||||
+#1#3'Top'#2#0#5'Width'#2's'#5'Align'#7#6'alLeft'#12'ClientHeight'#3'G'#1#11
|
||||
+'ClientWidth'#2's'#8'TabOrder'#2#0#10'DesignLeft'#3#145#1#9'DesignTop'#3#219
|
||||
+#0#0#9'TTreeView'#12'FunctionList'#4'Left'#2#0#6'Height'#3','#1#3'Top'#2#0#5
|
||||
+'Width'#2's'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#19#8'ReadOnly'#9
|
||||
+#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#11'OnMouseDown'#7#21'Functi'
|
||||
+'onListMouseDown'#9'OnMouseUp'#7#19'FunctionListMouseUp'#7'Options'#11#17'tv'
|
||||
+'oAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvoReadO'
|
||||
+'nly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0
|
||||
+#0#5'TEdit'#14'editSearchList'#4'Left'#2#0#6'Height'#2#27#3'Top'#3','#1#5'Wi'
|
||||
+'dth'#2's'#5'Align'#7#8'alBottom'#8'OnChange'#7#20'editSearchListChange'#8'T'
|
||||
+'abOrder'#2#1#0#0#0
|
||||
+#0#0#9'TTreeView'#12'FunctionList'#4'Left'#2#0#6'Height'#3'2'#1#3'Top'#2#0#5
|
||||
+'Width'#2's'#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#15#8'ReadOnly'#9
|
||||
+#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#10'OnDeletion'#7#20'Functio'
|
||||
+'nListDeletion'#11'OnMouseDown'#7#21'FunctionListMouseDown'#9'OnMouseUp'#7#19
|
||||
+'FunctionListMouseUp'#7'Options'#11#17'tvoAutoItemHeight'#16'tvoHideSelectio'
|
||||
+'n'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'#14'tvoShowButtons'#12'tvoShowL'
|
||||
+'ines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#5'TEdit'#14'editSearchList'#4'L'
|
||||
+'eft'#2#0#6'Height'#2#21#3'Top'#3'2'#1#5'Width'#2's'#5'Align'#7#8'alBottom'#8
|
||||
+'OnChange'#7#20'editSearchListChange'#8'TabOrder'#2#1#0#0#0
|
||||
]);
|
||||
|
@ -15,14 +15,16 @@ type
|
||||
editSearchList: TEdit;
|
||||
FunctionList: TTreeView;
|
||||
procedure editSearchListChange(Sender: TObject);
|
||||
procedure FunctionListDeletion(Sender: TObject; Node: TTreeNode);
|
||||
procedure FunctionListMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure FunctionListMouseUp(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
private
|
||||
procedure CreateFilterTree;
|
||||
FFilterTree : TTreeView;
|
||||
procedure FilterTreeVis(Vis : boolean);
|
||||
function GetFilterTree: TTreeView;
|
||||
{ private declarations }
|
||||
public
|
||||
DraggingNode : TTreeNode;
|
||||
@ -32,7 +34,8 @@ type
|
||||
StartWordCompletion : TPoint;
|
||||
CompletionLine : string;
|
||||
CompletionStart : string;
|
||||
FilterTree : TTreeView;
|
||||
property FilterTree : TTreeView read GetFilterTree;
|
||||
procedure LoadScriptTree( Script : String);
|
||||
function Find(Next : boolean) : boolean;
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -49,35 +52,67 @@ begin
|
||||
Find(false);
|
||||
end;
|
||||
|
||||
procedure TFunctionListFrame.FunctionListDeletion(Sender: TObject;
|
||||
Node: TTreeNode);
|
||||
begin
|
||||
if node.data <> nil then
|
||||
StrDispose(PChar(Node.Data));
|
||||
end;
|
||||
|
||||
procedure TFunctionListFrame.DockFormOnClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
CloseAction := caHide;
|
||||
Form1.MenuItemFunctionList.Checked := False;
|
||||
end;
|
||||
|
||||
procedure TFunctionListFrame.CreateFilterTree;
|
||||
begin
|
||||
if Assigned(FilterTree) then
|
||||
exit;
|
||||
FilterTree := TTreeView.Create(Self);
|
||||
FilterTree.Parent := Self;
|
||||
FilterTree.Visible := false;
|
||||
FilterTree.SetBounds(FunctionList.Left,FunctionList.Top,FunctionList.Width,FunctionList.Height);
|
||||
FilterTree.Align := alClient;
|
||||
FilterTree.ReadOnly:= True;
|
||||
FilterTree.ScrollBars:= ssAutoBoth;
|
||||
FilterTree.OnMouseDown:= @FunctionListMouseDown;
|
||||
FilterTree.OnMouseUp:= @FunctionListMouseUp;
|
||||
|
||||
end;
|
||||
|
||||
procedure TFunctionListFrame.FilterTreeVis(Vis: boolean);
|
||||
begin
|
||||
CreateFilterTree;
|
||||
FunctionList.Visible:= not Vis;
|
||||
FilterTree.Visible := Vis;
|
||||
end;
|
||||
|
||||
function TFunctionListFrame.GetFilterTree: TTreeView;
|
||||
begin
|
||||
Result := FFilterTree;
|
||||
if Assigned(Result) then
|
||||
exit;
|
||||
FFilterTree := TTreeView.Create(Self);
|
||||
FFilterTree.Parent := Self;
|
||||
FFilterTree.Visible := false;
|
||||
FFilterTree.SetBounds(FunctionList.Left,FunctionList.Top,FunctionList.Width,FunctionList.Height);
|
||||
FFilterTree.Align := alClient;
|
||||
FFilterTree.ReadOnly:= True;
|
||||
FFilterTree.ScrollBars:= ssAutoBoth;
|
||||
FFilterTree.OnMouseDown:= FunctionList.OnMouseDown;
|
||||
FFilterTree.OnMouseUp:= FunctionList.OnMouseUp;
|
||||
FFilterTree.OnChange:= FunctionList.OnChange;
|
||||
FFilterTree.OnExit := FunctionList.OnExit;
|
||||
Result := FFilterTree;
|
||||
//We do not want to delete the data from the FilterTree
|
||||
// FilterTree.OnDeletion:= FunctionList.OnDeletion;
|
||||
end;
|
||||
|
||||
procedure TFunctionListFrame.LoadScriptTree(Script: String);
|
||||
var
|
||||
I : integer;
|
||||
Analyzer : TScriptAnalyzer;
|
||||
tmpNode : TTreeNode;
|
||||
begin
|
||||
if FilterTree.Visible then
|
||||
Writeln('Might get some acces violations now..');
|
||||
ScriptNode.DeleteChildren;
|
||||
Analyzer := TScriptAnalyzer.create;
|
||||
Analyzer.ScriptToAnalyze:= Script;
|
||||
Analyzer.analyze;
|
||||
for i := 0 to Analyzer.MethodLen - 1 do
|
||||
begin
|
||||
tmpNode := FunctionList.Items.AddChild(ScriptNode,Analyzer.Methods[i].Name);
|
||||
tmpNode.Data:= strnew(PChar(Analyzer.Methods[i].CreateMethodStr));
|
||||
end;
|
||||
ScriptNode.Expand(true);
|
||||
end;
|
||||
|
||||
function TFunctionListFrame.Find(Next : boolean) : boolean;
|
||||
var
|
||||
Start,Len,i,index,posi: Integer;
|
||||
@ -89,7 +124,6 @@ var
|
||||
Node : TTreeNode;
|
||||
InsertStr : string;
|
||||
begin
|
||||
CreateFilterTree;
|
||||
if(editSearchList.Text = '')then
|
||||
begin
|
||||
editSearchList.Color := clWhite;
|
||||
@ -101,6 +135,7 @@ begin
|
||||
Form1.CurrScript.SynEdit.SelEnd:= Form1.CurrScript.SynEdit.SelStart;
|
||||
end;
|
||||
FilterTreeVis(False);
|
||||
ScriptNode.Expand(true);
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
@ -326,40 +326,47 @@ begin
|
||||
end;
|
||||
tkProcedure,
|
||||
tkFunction : begin;
|
||||
if not InMethod then
|
||||
InVarSection := False;
|
||||
if (not InTypes) and (not InVarSection) then
|
||||
if (InVarSection or (InMethod and InParams)) and ExpectingType then
|
||||
begin;
|
||||
WaitingForResult := LastTK = tkFunction;
|
||||
if Lex.TokenID <> tkIdentifier then
|
||||
//Do nothing since the this procedure/function is a var ;-)
|
||||
end else
|
||||
begin;
|
||||
if not InMethod then
|
||||
InVarSection := False;
|
||||
if (not InTypes) and (not InVarSection) then
|
||||
begin;
|
||||
ShowMessage('No method name -> exiting');
|
||||
exit;
|
||||
end;
|
||||
TempName := Lex.Token;
|
||||
Lex.NextNoJunk;
|
||||
if Lex.TokenID = tkRoundOpen then
|
||||
InParams := True
|
||||
else if Lex.TokenID = tkPoint then
|
||||
begin;
|
||||
// FormAnalyzer.SynEdit2.Lines.add('In class definition *cough*');
|
||||
Lex.NextNoJunk;
|
||||
WaitingForResult := LastTK = tkFunction;
|
||||
if Lex.TokenID <> tkIdentifier then
|
||||
begin;
|
||||
Writeln('Analyzer: No method name -> exiting');
|
||||
exit;
|
||||
end;
|
||||
TempName := Lex.Token;
|
||||
end else if ((Lex.TokenID = tkSemicolon) xor WaitingForResult) or ((Lex.TokenID = tkColon) xor WaitingForResult) then
|
||||
begin;
|
||||
InParams := False;
|
||||
end else
|
||||
begin;
|
||||
ShowMessage('Your missing some stuff in the procedure declaration');
|
||||
Exit;
|
||||
end;
|
||||
if InMethod then
|
||||
Method := Method.AddMethod(WaitingForResult,TempName)
|
||||
else
|
||||
Method := Self.AddMethod(WaitingForResult,TempName);
|
||||
InMethod := true;
|
||||
Method.BeginPos := LastPos - 5;
|
||||
Lex.NextNoJunk;
|
||||
if Lex.TokenID = tkRoundOpen then
|
||||
InParams := True
|
||||
else if Lex.TokenID = tkPoint then
|
||||
begin;
|
||||
Writeln('Analyzer: In class definition?');
|
||||
// FormAnalyzer.SynEdit2.Lines.add('In class definition *cough*');
|
||||
Lex.NextNoJunk;
|
||||
TempName := Lex.Token;
|
||||
end else if ((Lex.TokenID = tkSemicolon) xor WaitingForResult) or ((Lex.TokenID = tkColon) xor WaitingForResult) then
|
||||
begin;
|
||||
InParams := False;
|
||||
end else
|
||||
begin;
|
||||
Writeln('Analyzer: You''re missing some stuff in the procedure declaration');
|
||||
Exit;
|
||||
end;
|
||||
if InMethod then
|
||||
Method := Method.AddMethod(WaitingForResult,TempName)
|
||||
else
|
||||
Method := Self.AddMethod(WaitingForResult,TempName);
|
||||
InMethod := true;
|
||||
Method.BeginPos := LastPos - 5;
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
object Form1: TForm1
|
||||
Left = 243
|
||||
Left = 273
|
||||
Height = 557
|
||||
Top = 302
|
||||
Top = 233
|
||||
Width = 734
|
||||
ActiveControl = ScriptPanel
|
||||
Caption = 'THA FUKING MUFASA'
|
||||
@ -391,6 +391,8 @@ object Form1: TForm1
|
||||
Height = 275
|
||||
Width = 145
|
||||
OnChange = FunctionListChange
|
||||
OnDeletion = nil
|
||||
OnEnter = FunctionListEnter
|
||||
OnExit = FunctionListExit
|
||||
end
|
||||
inherited editSearchList: TEdit
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -214,6 +214,7 @@ type
|
||||
procedure editSearchListExit(Sender: TObject);
|
||||
procedure editSearchListKeyPress(Sender: TObject; var Key: char);
|
||||
procedure FunctionListChange(Sender: TObject; Node: TTreeNode);
|
||||
procedure FunctionListEnter(Sender: TObject);
|
||||
procedure FunctionListExit(Sender: TObject);
|
||||
procedure MenuItemColourHistoryClick(Sender: TObject);
|
||||
procedure dlgReplaceFind(Sender: TObject);
|
||||
@ -1008,8 +1009,17 @@ end;
|
||||
|
||||
procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode);
|
||||
begin
|
||||
if node = nil then
|
||||
exit;
|
||||
if Node.Level > 0 then
|
||||
StatusBar.Panels[2].Text := PChar(Node.Data);
|
||||
if Node.level = 0 then
|
||||
StatusBar.Panels[2].Text := 'Section: ' + Node.Text;
|
||||
end;
|
||||
|
||||
procedure TForm1.FunctionListEnter(Sender: TObject);
|
||||
begin
|
||||
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
||||
end;
|
||||
|
||||
procedure TForm1.FunctionListExit(Sender: TObject);
|
||||
@ -1245,6 +1255,7 @@ begin
|
||||
Tree.Items.Clear;
|
||||
Sections := TStringList.Create;
|
||||
LastSection := '';
|
||||
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
|
||||
for i := 0 to high(Methods) do
|
||||
begin;
|
||||
if Methods[i].Section <> LastSection then
|
||||
@ -1262,7 +1273,7 @@ begin
|
||||
Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false));
|
||||
Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl));
|
||||
end;
|
||||
frmFunctionList.ScriptNode := Tree.Items.Add(nil,'Script');
|
||||
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.Text);
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItemHideClick(Sender: TObject);
|
||||
@ -1462,17 +1473,7 @@ begin
|
||||
if editSearchList.CanFocus then
|
||||
editSearchList.SetFocus;
|
||||
//Lets load up this Script tree!
|
||||
Tree := frmFunctionList.FunctionList;
|
||||
Node := frmFunctionList.ScriptNode;
|
||||
Node.DeleteChildren;
|
||||
Analyzer := TScriptAnalyzer.create;
|
||||
Analyzer.ScriptToAnalyze:= CurrScript.SynEdit.Lines.Text;
|
||||
Analyzer.analyze;
|
||||
for i := 0 to Analyzer.MethodLen - 1 do
|
||||
begin
|
||||
tmpNode := Tree.Items.AddChild(Node,Analyzer.Methods[i].Name);
|
||||
tmpNode.Data:= PChar(Analyzer.Methods[i].CreateMethodStr);
|
||||
end;
|
||||
frmFunctionList.LoadScriptTree(CurrScript.SynEdit.text);
|
||||
end else begin
|
||||
if(frmFunctionList.Parent is TPanel)then
|
||||
frmFunctionList.Hide
|
||||
|
@ -805,7 +805,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function BrigthnessAdjust(Col: byte; br : integer): byte;inline;
|
||||
function BrightnessAdjust(Col: byte; br : integer): byte;inline;
|
||||
var
|
||||
temp : integer;
|
||||
begin;
|
||||
@ -824,9 +824,9 @@ begin
|
||||
Ptr := Self.FData;
|
||||
for i := (h*w-1) downto 0 do
|
||||
begin;
|
||||
Ptr^.r := BrigthnessAdjust(Ptr^.r,br);
|
||||
Ptr^.g := BrigthnessAdjust(Ptr^.g,br);
|
||||
Ptr^.b := BrigthnessAdjust(Ptr^.b,br);
|
||||
Ptr^.r := BrightnessAdjust(Ptr^.r,br);
|
||||
Ptr^.g := BrightnessAdjust(Ptr^.g,br);
|
||||
Ptr^.b := BrightnessAdjust(Ptr^.b,br);
|
||||
inc(ptr);
|
||||
end;
|
||||
end;
|
||||
@ -841,9 +841,9 @@ begin
|
||||
PtrNew := TargetBitmap.FData;
|
||||
for i := (h*w-1) downto 0 do
|
||||
begin;
|
||||
PtrNew^.r := BrigthnessAdjust(PtrOld^.r,br);
|
||||
PtrNew^.g := BrigthnessAdjust(PtrOld^.g,br);
|
||||
PtrNew^.b := BrigthnessAdjust(PtrOld^.b,br);
|
||||
PtrNew^.r := BrightnessAdjust(PtrOld^.r,br);
|
||||
PtrNew^.g := BrightnessAdjust(PtrOld^.g,br);
|
||||
PtrNew^.b := BrightnessAdjust(PtrOld^.b,br);
|
||||
inc(ptrOld);
|
||||
inc(PtrNew);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user