⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeanimateeditor.pas

📁 第三方控件:PaintGrid.pas 网格型仪表控件源文件 Mymeter.pas 圆型仪表控件源文件 Project1是这两个控件的使用范例。 该
💻 PAS
📖 第 1 页 / 共 2 页
字号:

    TeeInspector1.Enabled:=tmp;

    SpeedButton6.Enabled:=tmp;

    if tmp then
    with TAnimation(Sender.Data) do
    begin
      TeeInspector1.Items[1].Value:=Enabled;
      TeeInspector1.Items[2].Value:=StartFrame;
      TeeInspector1.Items[3].Value:=Duration;
      TeeInspector1.Items[4].Value:=Loop;

      tmpIsOk:=TAnimation(Sender.Data) is TIntegerAnimation;
      TeeInspector1.Items[7].Visible:=tmpIsOk;
      TeeInspector1.Items[8].Visible:=tmpIsOk;

      if tmpIsOk then
      with TIntegerAnimation(Sender.Data) do
      begin
        TeeInspector1.Items[7].Value:=StartValue;
        TeeInspector1.Items[8].Value:=EndValue;
      end;

      tmpIsOk:=TAnimation(Sender.Data) is TColorAnimation;
      TeeInspector1.Items[5].Visible:=tmpIsOk;
      TeeInspector1.Items[6].Visible:=TeeInspector1.Items[5].Visible;

      if tmpIsOk then
      begin
        TeeInspector1.Items[5].Value:=TColorAnimation(Sender.Data).StartColor;
        TeeInspector1.Items[6].Value:=TColorAnimation(Sender.Data).EndColor;
      end;

      if TAnimation(Sender.Data) is TNodeAnimation then
      begin
        TeeInspector1.Items[0].Visible:=True;
        with TNodeAnimation(Sender.Data) do
        begin
          TeeInspector1.Items[0].Value:=NodeText(Node);
          TeeInspector1.Items[0].Data:=Node;
        end;
      end
      else
      begin
        TeeInspector1.Items[0].Visible:=False;
      end;

      { Direction Animation }
      if TAnimation(Sender.Data) is TMovementAnimation then begin //tom:13/09/2002: Direction
        with TMovementAnimation(Sender.Data) do begin
          TeeInspector1.Items[10].Visible := True;
          TeeInspector1.Items[9].Visible := True;
          TeeInspector1.Items[9].Value := MoveSizeDirection[Direction];
          TeeInspector1.Items[9].Data:= TObject(Direction);
        end;
      end
      else
        TeeInspector1.Items[9].Visible := False;

      {NodeColor}
      if TAnimation(Sender.Data) is TNodeColorAnimation then begin //tom:13/09/2002: NodeColor
        with TNodeColorAnimation(Sender.Data) do begin
          TeeInspector1.Items[10].Visible := True;
          TeeInspector1.Items[10].Value := TreeAnimate.NodeColor[NodeColor];
          TeeInspector1.Items[10].Data:= TObject(NodeColor);
        end;
      end
      else
        TeeInspector1.Items[10].Visible := False;

      {TreeColor}
      if TAnimation(Sender.Data) is TTreeColorAnimation then begin //tom:13/09/2002: TreeColor
        with TTreeColorAnimation(Sender.Data) do begin
          TeeInspector1.Items[0].Visible := False;  //tom:18/10/2002
          TeeInspector1.Items[11].Visible := True;
          TeeInspector1.Items[11].Value := TreeAnimate.TreeColor[TreeColor];
          TeeInspector1.Items[11].Data:= TObject(TreeColor);
        end;
      end
      else
        TeeInspector1.Items[11].Visible := False;

      {ZoomPercent}
      if TAnimation(Sender.Data) is TNodeZoomAnimation then begin //tom:18/10/2002: ZoomPercent
        with TNodeZoomAnimation(Sender.Data) do begin
          TeeInspector1.Items[12].Visible := True;
          TeeInspector1.Items[12].Value := ZoomPercent;
        end;
      end
      else
        TeeInspector1.Items[12].Visible := False;

      {SizePercent}
      if TAnimation(Sender.Data) is TTextFlashAnimation then begin //tom:18/10/2002: SizePercent
        with TTextFlashAnimation(Sender.Data) do begin
          TeeInspector1.Items[13].Visible := True;
          TeeInspector1.Items[13].Value := SizePercent;
        end;
      end
      else
        TeeInspector1.Items[13].Visible := False;

    end
    else
    begin
      TeeInspector1.Items[0].Visible:=False;
      TeeInspector1.Items[5].Visible:=False;
      TeeInspector1.Items[6].Visible:=False;
      TeeInspector1.Items[7].Visible:=False;
      TeeInspector1.Items[8].Visible:=False;
      TeeInspector1.Items[9].Visible:=False; //tom:13/09/2002: Direction
      TeeInspector1.Items[10].Visible:=False; //tom:13/09/2002: NodeColor
      TeeInspector1.Items[11].Visible:=False; //tom:13/09/2002: TreeColor
      TeeInspector1.Items[12].Visible:=False; //tom:18/10/2002: ZoomPercent
      TeeInspector1.Items[13].Visible:=False; //tom:18/10/2002: SizePercent
    end;
  end;

begin
  Changing:=True;
  try
    DoSelection;
  finally
    Changing:=False;
  end;
end;

procedure TTreeAnimateEditor.AnimateDeletedShapes(Sender: TObject);
begin
  if Assigned(Tree1) then Tree1SelectShape(Tree1.Selected.First);
end;

procedure TTreeAnimateEditor.AnimateClear(Sender: TObject);
begin
  FillNodes;
end;

procedure TTreeAnimateEditor.TreeMapDeletedShapes(Sender: TObject);
begin
  SpeedButton6Click(Sender);
end;

procedure TTreeAnimateEditor.TreeMapDeletingShapes(
  Sender: TSelectedShapeList; var AllowDelete: Boolean);
begin
  TAnimation(Sender.First.Data).Free;
  Tree1.Roots[TreeMap.Roots.IndexOf(Sender.First)].Free;
end;

Function TTreeAnimateEditor.TheActionBar:TTreeNodeShape;
begin
  result:=TreeMap.Roots[Tree1.Roots.IndexOf(Tree1.Selected.First)];
end;

Function TTreeAnimateEditor.TheAction:TAnimation;
begin
  if Tree1.Selected.First<>nil then
     result:=TAnimation(Tree1.Selected.First.Data)
  else
     result:=nil;
end;

procedure TTreeAnimateEditor.TreeMapMovingShape(Sender: TTreeNodeShape;
  var DeltaX, DeltaY: Integer);
var tmp : Integer;
begin
  DeltaY:=0; // prevent moving vertically

  tmp:=(DeltaX div IHorizScale);

  with TAnimation(Sender.Data) do
  begin
    if (StartFrame+tmp)>0 then StartFrame:=StartFrame+tmp
                          else StartFrame:=0;
    Sender.X0:=StartFrame*IHorizScale;
    DeltaX:=0;

    TeeInspector1.Items[2].Value:=StartFrame;
  end;
end;

procedure TTreeAnimateEditor.TreeMapResizingShape(Sender: TTreeNodeShape;
  ACorner: TTreeShapeHandle; var DeltaX, DeltaY: Integer);
var tmp : Integer;
begin
  DeltaY:=0; // prevent resizing vertically

  tmp:=(DeltaX div IHorizScale);

  with TAnimation(Sender.Data) do
  begin
    if ACorner=rcLeft then
    begin
      if (Duration-tmp)>0 then
      begin
        Duration:=Duration-tmp;
        StartFrame:=StartFrame+tmp;
        Sender.Left:=StartFrame*IHorizScale;
        TeeInspector1.Items[2].Value:=StartFrame;
      end;
    end
    else
    begin
      if (Duration+tmp)>1 then Duration:=Duration+tmp
                          else Duration:=1;
    end;

    Sender.Width:=Duration*IHorizScale;
    TeeInspector1.Items[3].Value:=Duration;
    DeltaX:=0;
  end;
end;

procedure TTreeAnimateEditor.SpeedButton6Click(Sender: TObject);
begin
  TheAction.Free;
  FillNodes;
  SpeedButton6.Enabled:=Animate.Animations.Count>0;
  Tree1SelectShape(Tree1.Selected.First);
  TeeModified;
end;

procedure TTreeAnimateEditor.SpeedButton5Click(Sender: TObject);
var tmp      : TAnimation;
    tmpClass : TAnimationClass;
    tmpSt    : String;
begin
  tmpClass:=TAnimationGallery.Select;
  if Assigned(tmpClass) then
  begin
    tmp:=tmpClass.Create(Animate.Owner);
    tmpSt:=tmp.ClassName+IntToStr(Animate.Animations.Count+1);
    if Copy(tmpSt,1,1)='T' then Delete(tmpSt,1,1);
    tmp.Name:=tmpSt;
    Animate.Animations.Add(tmp);
    FillNodes;
    TreeMap.Roots.Last.Selected:=True;
    TeeModified;
  end;
end;

procedure TTreeAnimateEditor.TeeModified;
begin
  if Assigned(FOnModified) then FOnModified(Self);
end;

type TAnimationAccess=class(TAnimation);

procedure TTreeAnimateEditor.AnimateContinue(Sender: TObject);
begin
  SBPause.Down:=False;
  SBFrame.Enabled:=False;
end;

procedure TTreeAnimateEditor.Tree1DeletedShapes(Sender: TObject);
begin
  SpeedButton6Click(Sender);
end;

procedure TTreeAnimateEditor.SetAnimate(const Value: TTreeAnimate);
begin
  FAnimate:=Value;
  FormShow(Self);
end;

procedure TTreeAnimateEditor.UpScaleClick(Sender: TObject;
  Button: TUDBtnType);
begin
  if UpScale.Position<3 then IHorizScale:=12*(4-UpScale.Position)
                        else IHorizScale:=12 div (UpScale.Position-2);
  TreeMap.Grid.HorizStep:=IHorizScale;
  FillNodes;
end;

procedure TTreeAnimateEditor.TeeInspector1Items2Change(Sender: TObject);
begin
  TheAction.StartFrame:=TInspectorItem(Sender).Value;
  TheActionBar.Left:=TheAction.StartFrame*IHorizScale;
  TeeModified;
end;

procedure TTreeAnimateEditor.TeeInspector1Items3Change(Sender: TObject);
var tmp : Integer;
begin
  tmp:=TInspectorItem(Sender).Value;
  if TheAction.Duration<>tmp then
  begin
    TheAction.Duration:=tmp;
    TheActionBar.Width:=IHorizScale*tmp;
    TeeModified;
  end;
end;

procedure TTreeAnimateEditor.TeeInspector1Items1Change(Sender: TObject);
begin
  if TheAction.Enabled<>TInspectorItem(Sender).Value then
  begin
    TheAction.Enabled:=TInspectorItem(Sender).Value;
    TeeModified;
  end;
  SetActionBarColor;
end;

procedure TTreeAnimateEditor.TeeInspector1Items0Change(Sender: TObject);
var tmp : TTreeNodeShape;
begin
  if TheAction is TNodeAnimation then
  begin
    tmp:=TNodeAnimation(TheAction).Node;
    TNodeAnimation(TheAction).Node:=TTreeNodeShape(TInspectorItem(Sender).Data);

    if not Assigned(tmp) then
    begin
      TAnimationAccess(TheAction).NewNode;
      Tree1SelectShape(Tree1.Selected.First);
    end;

    TeeInspector1Items1Change(TeeInspector1.Items[1]);

    TeeModified;
  end;
end;

procedure TTreeAnimateEditor.TeeInspector1Items4Change(Sender: TObject);
begin
  if TheAction.Loop<>TInspectorItem(Sender).Value then
  begin
    TheAction.Loop:=TInspectorItem(Sender).Value;
    TeeModified;
  end;
  SetActionBarColor;
end;

Procedure TTreeAnimateEditor.SetActionBarColor;
begin
  if TheAction.IsEnabled then
     if TheAction.Loop then TheActionBar.Color:=clBlue
                       else TheActionBar.Color:=clBlack
  else
     TheActionBar.Color:=clDkGray;
end;

Function TTreeAnimateEditor.NodeText(ANode:TTreeNodeShape):String;
begin
  if Assigned(ANode) then
  begin
    result:=ANode.SimpleText;
    if result='' then
    begin
      result:=ANode.Name;
      if result='' then result:='Node '+IntToStr(ANode.Tree.Shapes.IndexOf(ANode));
    end;
  end
  else result:='';
end;

procedure TTreeAnimateEditor.TeeInspector1Items0GetItems(
  Sender: TInspectorItem; Proc: TGetItemProc);
var t : Integer;
begin
  if Assigned(Animate.Tree) then
  for t:=0 to Animate.Tree.Shapes.Count-1 do
      Proc(NodeText(Animate.Tree[t]),Animate.Tree[t]);
end;

procedure TTreeAnimateEditor.TeeInspector1Items6Change(Sender: TObject);
begin
  TColorAnimation(TheAction).EndColor:={$IFDEF CLR}TColor{$ENDIF}(TInspectorItem(Sender).Value);
  TeeModified;
end;

procedure TTreeAnimateEditor.TeeInspector1Items5Change(Sender: TObject);
begin
  TColorAnimation(TheAction).StartColor:={$IFDEF CLR}TColor{$ENDIF}(TInspectorItem(Sender).Value);
  TeeModified;
end;

procedure TTreeAnimateEditor.TeeInspector1Items7Change(Sender: TObject);
begin
  if TheAction is TIntegerAnimation then
  with TIntegerAnimation(TheAction) do
  begin
    StartValue:=TInspectorItem(Sender).Value;
    TeeModified;
  end;
end;

procedure TTreeAnimateEditor.TeeInspector1Items8Change(Sender: TObject);
begin
  if TheAction is TIntegerAnimation then
  with TIntegerAnimation(TheAction) do
  begin
    EndValue:=TInspectorItem(Sender).Value;
    TeeModified;
  end;
end;

procedure TTreeAnimateEditor.SBCloseClick(Sender: TObject);
begin
  PanelAnim.Hide;
  Splitter2.Hide;
end;

procedure TTreeAnimateEditor.PanelAnimResize(Sender: TObject);
begin
  SBClose.Left:=PanelAnim.Width-20;
end;

procedure TTreeAnimateEditor.TeeInspector1Items9GetItems(
  Sender: TInspectorItem; Proc: TGetItemProc);                             //tom:13/09/2002: Direction
var t: Integer;
begin
  for t:=0 to Length(MoveSizeDirection)-1 do
      Proc(MoveSizeDirection[TMoveSizeDirection(t)],TObject(t));
end;

procedure TTreeAnimateEditor.TeeInspector1Items9Change(Sender: TObject);  //tom:13/09/2002: Direction
var tmp : TMoveSizeDirection;
begin
  if TheAction is TMovementAnimation then begin
    tmp := TMoveSizeDirection(TInspectorItem(Sender).Data);
    with TMovementAnimation(TheAction) do begin
      if Direction <> tmp then begin
        Direction:= tmp;
        TeeModified;
      end;
    end;
  end;
end;

procedure TTreeAnimateEditor.TeeInspector1Items10GetItems(
  Sender: TInspectorItem; Proc: TGetItemProc);                              //tom:13/09/2002: NodeColor
var t: Integer;
begin
  for t:=0 to Length(NodeColor)-1 do
      Proc(NodeColor[TNodeColor(t)],TObject(t));
end;

procedure TTreeAnimateEditor.TeeInspector1Items10Change(Sender: TObject);  //tom:13/09/2002: NodeColor
var tmp : TNodeColor;
begin
  if TheAction is TNodeColorAnimation then begin
    tmp := TNodeColor(TInspectorItem(Sender).Data);
    with TNodeColorAnimation(TheAction) do begin
      if NodeColor <> tmp then begin
        NodeColor:= tmp;
        TeeModified;
      end;
    end;
  end;
end;

procedure TTreeAnimateEditor.TeeInspector1Items11GetItems(                 //tom:13/09/2002: TreeColor
  Sender: TInspectorItem; Proc: TGetItemProc);
var t: Integer;
begin
  for t:=0 to Length(TreeColor)-1 do
      Proc(TreeColor[TTreeColor(t)],TObject(t));
end;

procedure TTreeAnimateEditor.TeeInspector1Items11Change(Sender: TObject);  //tom:13/09/2002: TreeColor
var tmp : TTreeColor;
begin
  if TheAction is TTreeColorAnimation then begin
    tmp := TTreeColor(TInspectorItem(Sender).Data);
    with TTreeColorAnimation(TheAction) do begin
      if TreeColor <> tmp then begin
        TreeColor:= tmp;
        TeeModified;
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -