Jump to content

XylemFlow

Members
  • Content Count

    66
  • Joined

  • Last visited

Everything posted by XylemFlow

  1. XylemFlow

    Issue with TMenuBar and Alt key

    Here's a demo project. Mouse down, move and up events are recorded with counters and shown in labels. Steps: - Hold down left mouse button on the canvas - Press and release the Alt key - Release the left mouse button - Mouse down and mouse up counters no longer match TMenuBar Alt Issue.zip
  2. XylemFlow

    User Drawing of Lines and Curves

    Here's a basic demo using TPath and TSelectionPoint (Tested for Windows 32-bit). Click and drag to draw the line. Then you can drag the control points to create a curve. Of course you can then add the path to a list of paths if you want to keep multiple drawn paths. PathDemo.zip
  3. XylemFlow

    Styling message boxes

    I use TDialogServiceSync.MessageDialog and TDialogServiceSync.ShowMessage in my Windows / mac OS application. However, I've added a dark mode to my application from a downloaded style and it doesn't seem possible to set the style of these message boxes. The only solution seems to be to create my own message dialog forms and call them using ShowModal. Firstly, will that give exactly the same behaviour? Secondly, does anyone have or know of any free code for message dialog forms? I'd like it to support the various button combination options (TMsgDlgButtons) and an icon depending on TMsgDlgType. If not I'll of course make them myself.
  4. Thanks everyone, but I don't think the line endings are the cause of the issue. Like I said, Notepad++ couldn't find any incorrect line endings. I also tried converting to Unix EOL and back to Windows EOL and the resulting file was identical to the original.
  5. XylemFlow

    Styling message boxes

    I guess that one issue will be that currently I think the message boxes show the text on the buttons in the user's own language according to their Windows regional settings.
  6. Thanks. I tried searching the file in Notepad++ using Regular expression \r(?!\n)|(?<!\r)\n, which is supposed to find these. None were found though.
  7. I've had the same problem for months. Close and re-open, even restart Windows, doesn't fix them. Remove and re-add from customize toolbars doesn't fix them either. Ctrl+F12 does work, but I prefer to use the buttons. What else can I try? I also have several other issues with the Delphi 11.2 IDE. For example, in one of my longer units it seems always confused what lines things are on. If I search the file and click to go to a result it always goes to the wrong place (offset by a constant amount). Find Declaration (Ctrl+click) also never works in that file. Is this a bug with long units (almost 8000 lines) or does something need resetting? Again, restart doesn't help.
  8. I'm trying to create a 'Dark Mode' for my Windows application, but I want to keep the basic style of the controls and just change the colours. I have downloaded a VCL style (Windows 10 Charcoal) and converted it to an FMX style using the Bitmap Style Designer. It looks mostly ok. However, there are some annoying differences. The main one being that there's a thicker border around the forms. There are a few other issues with some controls. I can open the Style Designer to edit the parameters, but it's difficult to know what to change. I'd like to compare the parameters with the default style to see what's different, but how do I do that? The default style seems to be hardcoded and not visible in the Style Designer.
  9. XylemFlow

    How to see the parameters of the default style?

    Thanks for sharing that. But your stylebookDefault shows nothing as I expected. That's my issue. I can see all the parameters of the dark style but not the parameters of the default style to compare against.
  10. XylemFlow

    How to see the parameters of the default style?

    I'm not sure what you mean. The style object for my normal mode doesn't contain anything because only hard coded styles are used. Attached is a basic example of the issues I'm having. I build it in Delphi 11.2 for Windows 32-bit. When run you can click the checkbox to switch between styles. I have 2 issues when in Dark Mode. The borders of the form change. All the components on the form shift because of this. I'd like only the colours to change. I assume that I need to change some parameters in windowborderstyle in the Style Designer, but playing around with those parameters hasn't helped much. The main menu behaves differently. In normal light mode I can click File for example and then move the cursor over Edit and Edit will automatically open and File will close. However, that doesn't happen in Dark Mode. File just stays open. I don't know what to change in the style to fix it. If I had all the parameters of the default style (light) then I could compare with the parameters of the dark style to try to work out what the differences are and maybe fix these issues. But I don't know how to do that? Dark Mode Demo.zip
  11. That could be very useful. I've often considered if I could use the 3D capabilities of FMX for my 2D graphics. I may give textures a go in my circle demo. Implementing the interpolation for downsampling with higher quality should just be a matter of writing it into the pixel shader. One down side is that different shaders need to be written to support all platforms, but that's not a big issue. The main issue is combining this with other drawing primitives such as lines, circles, text and others that I use from TCanvas. The shader requires a 3D component, so mixing the two to draw to a single canvas seems difficult.
  12. The circles is just an example. My users could load any image and then want to animate it at various scale and angles. I've tried Skia4Delphi. One issue for me is that it doesn't use the GPU when drawing to an off screen TBitmap, whereas TCanvasD2D does. I've already benchmarked TCanvasD2D (using GPU) against TCanvasGDIPlus (without GPU) on Windows and TCanvasD2D is significantly faster. That tells me that the GPU is making a big difference even with a fast library. I'm not running on a potato either, but my users might be (I use a potato for testing to make sure that it will work for all user setups). A previous version of my software was developed in VCL and rendered the images with scale and rotation in software, so I have those libraries already. There was a significant performance boost moving to FMX, so there's no going back. I'm doing full screen animation at up to 30fps so I need to make use of any hardware boost available. You said that you think the code is AND-ing rather than OR-ing. What makes you think that rather than it just using nearest neighbour sub-sampling? Surely the Delphi code is just sending instructions to the GPU and the GPU is unlikely to be making an error like that.
  13. XylemFlow

    write text on image with specific position fmx

    I think the issue is with BitmapScale. With the code below I get the text in the right position. procedure TForm1.Button1Click(Sender: TObject); var ARect: TRectF; s: string; begin with Image1.Bitmap do begin Canvas.Font.Family := 'Arial'; Canvas.Fill.Color := TAlphaColorRec.Black; ARect.Top := 200; ARect.Left := 100; ARect.Width := 105; ARect.Height := 50; s := 'hellow Fmx'; Canvas.BeginScene; Canvas.Clear(TAlphaColorRec.White); // canvas.textout(20,20,'hellow Fmx'); Canvas.FillText(ARect, s, false, 1, [], TTextAlign.Leading, TTextAlign.Leading); Canvas.EndScene; SaveToFile('testBmp.png'); end; end; procedure TForm1.FormCreate(Sender: TObject); begin Image1.Bitmap.SetSize(Round(Image1.Width), Round(Image1.Height)); Image1.Bitmap.BitmapScale := 1; end;
  14. Thanks everyone for those suggestions. However, I don't think anyone has suggested a way to get the GPU to handle this. My hand written code is about as fast as the CPU can go (I also have code for downscaling by exactly a factor of 2 which is faster still). But my original question was about doing this on the GPU, because I'm dealing with animated real time graphics. I also need to draw these images onto a canvas at an angle, which I do by setting TCanvas.Matrix with TCanvas.DrawBitmap. I could write code to do shrink and rotate but that would be super slow compared to the GPU. // shrink a bitmap by a factor of 2. ABitmapOut size needs to be pre set procedure ShrinkFast(const ABitmap : TBitmap ; out ABitmapOut : TBitmap); Var Lx, Ly, R : integer; P1, P2, P3, P4, POut, PRowStart, PRowStartOut : pByte; W, HM, WL : integer; LRowSizeOut, LRowSize : integer; bdata, bdatao : TBitmapData; begin if (ABitmapOut.Width = 0) or (ABitmapOut.Height = 0) then Exit; ABitmap.Map(TMapAccess.Read, bdata); ABitmapOut.Map(TMapAccess.Write, bdatao); try W := ABitmapOut.Width; R := ABitmap.Width div W; // shrink ratio if R <> 2 then Exit; HM := ABitmapOut.Height - 1; WL := W - 3; PRowStart := pByte(bdata.GetScanline(0)); LRowSize := bdata.Pitch; PRowStartOut := pByte(bdatao.GetScanline(0)); LRowSizeOut := bdatao.Pitch; if R = 2 then begin for Ly := 0 to HM do begin P1 := PRowStart; P2 := P1 + LRowSize; P3 := P1 + 4; P4 := P2 + 4; POut := PRowStartOut; Lx := 0; // set output pixel to the average of the 2X2 box of input pixels while Lx < WL do begin // loop unrolled by 4 POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // blue Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // green Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // red Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // alpha Inc(P1,5); Inc(P2,5); Inc(P3,5); Inc(P4,5); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // blue Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // green Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // red Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // alpha Inc(P1,5); Inc(P2,5); Inc(P3,5); Inc(P4,5); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // blue Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // green Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // red Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // alpha Inc(P1,5); Inc(P2,5); Inc(P3,5); Inc(P4,5); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // blue Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // green Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // red Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // alpha Inc(P1,5); Inc(P2,5); Inc(P3,5); Inc(P4,5); Inc(POut); Inc(Lx, 4); end; while Lx < W do begin POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // blue Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // green Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // red Inc(P1); Inc(P2); Inc(P3); Inc(P4); Inc(POut); POut^ := (P1^ + P2^ + P3^ + P4^) shr 2; // alpha Inc(P1,5); Inc(P2,5); Inc(P3,5); Inc(P4,5); Inc(POut); Inc(Lx); end; Inc(PRowStartOut, LRowSizeOut); Inc(PRowStart, LRowSize shl 1); end; end; finally ABitmap.Unmap(bdata); ABitmapOut.Unmap(bdatao); end; end;
  15. That doesn't do a great job either. Looking into the code, it appears to use DrawBitmap as well. However it wouldn't help me anyway. I need to be able to render the images to a TCanvas. I'm updating the canvas for dragging the objects around in real time, which is why I need high performance.
  16. XylemFlow

    Windows App hosting options?

    This isn't specifically a Delphi question. More of a general Windows development and deployment question. I'm looking into the best options for hosting my application. My application is free and should be available publicly to everyone who wants to download it. My revenue model is based on advertising on my website, so I want to drive all the download traffic through my website. Of course the best option is most likely to host it on my website, but the application is fairly large and the number of downloads it high. My current web host is unlikely to provide enough bandwidth without me upgrading it. I'd also like to prevent people sharing the download link and thus avoiding visiting my website. If it was hosted on my site I would simply change the download file name every few days. What other options are there with 3rd party hosting? I have looked into using the Windows Store, but even if I make the listing undiscoverable I can't avoid people sharing the link and avoid going through my website. It doesn't look like Windows store provides a feature for changing the URL on a regular basis, and if they did how would I synch my website to the new link each time?
  17. XylemFlow

    Windows App hosting options?

    Thanks, but I've used this funding model for some time and it's already proved to be easily profitable enough and I've had no complaints about the ads. The whole internet seems to be based on advertising so I think people are used to it. On the other hand, very few people are willing to pay for software in my experience. I've found that a lot more income can be made from free software with advertising compared to the same paid software without advertising, simply because it is much more likely to become popular. Of course it depends on the type of software and the target users
  18. I use .ini for language files. This makes it easy for users to create their own language files. Is there any specific advantage of the .lng format over .ini?
  19. XylemFlow

    Creating Gradient by code

    What platform are you running it on and which implementation of TCanvas? There are many issues with GPU canvas. Have you read this? https://stackoverflow.com/questions/53561919/fmx-multi-point-gradients
  20. XylemFlow

    Draw a path with winding fill mode?

    TCanvas doesn't appear to provide a way to switch between 'alternate' and 'winding' fill modes. The default is alternate. This is important when paths intersect themselves and prevents me rendering certain objects how I would like. I created a new feature request for this on the quality page a while ago. It got the following comment. I'd like to try to do that as my application is currently Windows only. However, how do I actually go about calling implementation specific functions like Path.SetFillMode(D2D1_FILL_MODE_WINDING) in my code? I know how to find out the current implementation of a TCanvas with ACanvas.ClassName.
  21. XylemFlow

    Draw a path with winding fill mode?

    I made some progress on this by copying FMX.Canvas.D2D.pas locally and adding Path.SetFillMode(D2D1_FILL_MODE_WINDING); in TCanvasD2D.CreatePathGeometry just after Geometry.Open(Path). It works but modifying Delphi code is a horrible solution and to be able to switch fill mode at run time I would also need to add a property for it in TCanvas in FMX.Graphics.pas. Then I would need to modify FMX.Canvas.GDI.pas and FMX.Canvas.GPU.pas to make the same change. It's not a huge amount of work though. The interface for fill mode is already there. I wonder why they didn't implement such a basic feature?
  22. XylemFlow

    Newbee: FMX: Can't find DirectoryListBox or FileListBox

    TListBox is there in FMX. I'm not sure why you think it's not. Regarding rotating images. You may know this already but the best way to do it is by setting the Matrix property of the TCanvas you're drawing to. Use TMatrix.CreateRotation to create the matrix from a rotation angle. The advantage of this method is that the GPU takes care of all the transformations. It's also easy to combine with other transformations such as scaling or translation. TBitmap.Rotate is essentially doing that for you, but gives you less control.
  23. XylemFlow

    is there a complete guide to converting VCL to FMX?

    I have done this myself. I don't know of a guide to doing it. I'd just recommend to familiarise yourself with FMX first. You will have to rebuild your forms from scratch. You can then copy and paste most of the code and link the events, but some changes will be needed. The drawing commands are different and you need to get used to wrapping drawing commands with BeginScene and EndScene. Code using strings may need to be modified because of unicode. Finally, some visual components are just different and have differently named properties (the most common is that you will have to change .Caption to .Text). Other than that it's not too bad and you get quicker once you get into it.
  24. XylemFlow

    Converting simple VCL form to FMX

    When I ported my application from VCL to FMX I remade each form by hand. There are 17 forms so it took a while, but this was not the most time consuming part of the porting process by far. The RAD interface makes it quick and easy.
  25. XylemFlow

    Can you mix VCL and FMX?

    Yes you can, but of course it will only compile under Windows. I have used several VCL features in my FMX application. I just place them inside {$IFDEF MSWINDOWS} so they don't compile under other platforms.
×