فهرست منبع

edit texture opacity

Johann 6 سال پیش
والد
کامیت
a89ae7fc1a
3فایلهای تغییر یافته به همراه25 افزوده شده و 11 حذف شده
  1. 1 0
      lazpaint/lazpaintmainform.pas
  2. 15 4
      lazpaint/tools/utool.pas
  3. 9 7
      lazpaint/tools/utoolvectorial.pas

+ 1 - 0
lazpaint/lazpaintmainform.pas

@@ -3512,6 +3512,7 @@ end;
 procedure TFMain.OnTextureChanged(Sender: TObject);
 procedure TFMain.OnTextureChanged(Sender: TObject);
 begin
 begin
   UpdateTextureIcon;
   UpdateTextureIcon;
+  SpinEdit_TextureOpacity.Value := ToolManager.ToolTextureOpacity;
 end;
 end;
 
 
 procedure TFMain.UpdateStatusText;
 procedure TFMain.UpdateStatusText;

+ 15 - 4
lazpaint/tools/utool.pas

@@ -264,7 +264,8 @@ type
 
 
     function SetToolDeformationGridSize(NbX,NbY: integer): boolean;
     function SetToolDeformationGridSize(NbX,NbY: integer): boolean;
     procedure SwapToolColors;
     procedure SwapToolColors;
-    procedure SetToolTexture(ATexture: TBGRABitmap);
+    procedure SetToolTexture(ATexture: TBGRABitmap); overload;
+    procedure SetToolTexture(ATexture: TBGRABitmap; AOpacity: byte); overload;
     function GetToolTextureAfterAlpha: TBGRABitmap;
     function GetToolTextureAfterAlpha: TBGRABitmap;
     function GetToolTexture: TBGRABitmap;
     function GetToolTexture: TBGRABitmap;
     function BorrowToolTexture: TBGRABitmap;
     function BorrowToolTexture: TBGRABitmap;
@@ -801,6 +802,7 @@ begin
   if AValue = FToolTextureOpactiy then exit;
   if AValue = FToolTextureOpactiy then exit;
   FreeAndNil(FToolTextureAfterAlpha);
   FreeAndNil(FToolTextureAfterAlpha);
   FToolTextureOpactiy := AValue;
   FToolTextureOpactiy := AValue;
+  if Assigned(FOnTextureChanged) then FOnTextureChanged(self);
 end;
 end;
 
 
 function TToolManager.CheckExitTool: boolean;
 function TToolManager.CheckExitTool: boolean;
@@ -1281,9 +1283,18 @@ end;
 
 
 procedure TToolManager.SetToolTexture(ATexture: TBGRABitmap);
 procedure TToolManager.SetToolTexture(ATexture: TBGRABitmap);
 begin
 begin
-  if ATexture = FToolTexture then exit;
-  FToolTexture.FreeReference;
-  FToolTexture := ATexture.NewReference as TBGRABitmap;
+  SetToolTexture(ATexture, ToolTextureOpacity);
+end;
+
+procedure TToolManager.SetToolTexture(ATexture: TBGRABitmap; AOpacity: byte);
+begin
+  if (ATexture = FToolTexture) and (AOpacity = FToolTextureOpactiy) then exit;
+  if ATexture<>FToolTexture then
+  begin
+    FToolTexture.FreeReference;
+    FToolTexture := ATexture.NewReference as TBGRABitmap;
+  end;
+  FToolTextureOpactiy:= AOpacity;
   FreeAndNil(FToolTextureAfterAlpha);
   FreeAndNil(FToolTextureAfterAlpha);
   if Assigned(FOnTextureChanged) then FOnTextureChanged(self);
   if Assigned(FOnTextureChanged) then FOnTextureChanged(self);
 end;
 end;

+ 9 - 7
lazpaint/tools/utoolvectorial.pas

@@ -164,9 +164,9 @@ begin
       if (vsfBackFill in AShape.Fields) and (AShape.BackFill.FillType = vftSolid) then
       if (vsfBackFill in AShape.Fields) and (AShape.BackFill.FillType = vftSolid) then
         Manager.ToolBackColor := AShape.BackFill.SolidColor;
         Manager.ToolBackColor := AShape.BackFill.SolidColor;
       if (vsfBackFill in AShape.Fields) and (AShape.BackFill.FillType = vftTexture) then
       if (vsfBackFill in AShape.Fields) and (AShape.BackFill.FillType = vftTexture) then
-        Manager.SetToolTexture(AShape.BackFill.Texture)
+        Manager.SetToolTexture(AShape.BackFill.Texture,AShape.BackFill.TextureOpacity)
       else if (vsfPenFill in AShape.Fields) and (AShape.PenFill.FillType = vftTexture) then
       else if (vsfPenFill in AShape.Fields) and (AShape.PenFill.FillType = vftTexture) then
-        Manager.SetToolTexture(AShape.PenFill.Texture)
+        Manager.SetToolTexture(AShape.PenFill.Texture,AShape.PenFill.TextureOpacity)
       else
       else
         Manager.SetToolTexture(nil);
         Manager.SetToolTexture(nil);
     end;
     end;
@@ -307,7 +307,7 @@ begin
       if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftGradient) then
       if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftGradient) then
       begin
       begin
         if Assigned(Manager.GetToolTexture) then
         if Assigned(Manager.GetToolTexture) then
-          SelectedShape.BackFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity)
+          SelectedShape.BackFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity, Manager.ToolTextureOpacity)
         else
         else
         begin
         begin
           SelectedShape.BackFill.Gradient.StartColor := Manager.ToolForeColor;
           SelectedShape.BackFill.Gradient.StartColor := Manager.ToolForeColor;
@@ -321,14 +321,15 @@ begin
           vftTexture:
           vftTexture:
             begin
             begin
               SelectedShape.BackFill.SetTexture(Manager.GetToolTexture,
               SelectedShape.BackFill.SetTexture(Manager.GetToolTexture,
-                SelectedShape.BackFill.TextureMatrix,SelectedShape.BackFill.TextureOpacity,
+                SelectedShape.BackFill.TextureMatrix,Manager.ToolTextureOpacity,
                 SelectedShape.BackFill.TextureRepetition);
                 SelectedShape.BackFill.TextureRepetition);
               if (vsfPenFill in SelectedShape.Fields) and (SelectedShape.PenFill.FillType = vftSolid) then
               if (vsfPenFill in SelectedShape.Fields) and (SelectedShape.PenFill.FillType = vftSolid) then
                 SelectedShape.PenFill.SolidColor := Manager.ToolForeColor;
                 SelectedShape.PenFill.SolidColor := Manager.ToolForeColor;
             end;
             end;
           vftGradient,vftSolid:
           vftGradient,vftSolid:
             begin
             begin
-              SelectedShape.BackFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity);
+              SelectedShape.BackFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity,
+                Manager.ToolTextureOpacity);
               if (vsfPenFill in SelectedShape.Fields) and (SelectedShape.PenFill.FillType = vftSolid) then
               if (vsfPenFill in SelectedShape.Fields) and (SelectedShape.PenFill.FillType = vftSolid) then
                 SelectedShape.PenFill.SolidColor := Manager.ToolForeColor;
                 SelectedShape.PenFill.SolidColor := Manager.ToolForeColor;
             end;
             end;
@@ -337,14 +338,15 @@ begin
               vftTexture:
               vftTexture:
                 begin
                 begin
                   SelectedShape.PenFill.SetTexture(Manager.GetToolTexture,
                   SelectedShape.PenFill.SetTexture(Manager.GetToolTexture,
-                    SelectedShape.PenFill.TextureMatrix,SelectedShape.PenFill.TextureOpacity,
+                    SelectedShape.PenFill.TextureMatrix,Manager.ToolTextureOpacity,
                     SelectedShape.PenFill.TextureRepetition);
                     SelectedShape.PenFill.TextureRepetition);
                   if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftSolid) then
                   if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftSolid) then
                     SelectedShape.BackFill.SolidColor := Manager.ToolBackColor;
                     SelectedShape.BackFill.SolidColor := Manager.ToolBackColor;
                 end;
                 end;
               vftGradient,vftSolid:
               vftGradient,vftSolid:
                 begin
                 begin
-                  SelectedShape.PenFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity);
+                  SelectedShape.PenFill.SetTexture(Manager.GetToolTexture, AffineMatrixIdentity,
+                    Manager.ToolTextureOpacity);
                   if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftSolid) then
                   if (vsfBackFill in SelectedShape.Fields) and (SelectedShape.BackFill.FillType = vftSolid) then
                     SelectedShape.BackFill.SolidColor := Manager.ToolBackColor;
                     SelectedShape.BackFill.SolidColor := Manager.ToolBackColor;
                 end;
                 end;