fpGUI icon indicating copy to clipboard operation
fpGUI copied to clipboard

fpGUI minor code improvement suggestions

Open deanm73 opened this issue 2 years ago • 8 comments

These are small code improvements that might make the framework slightly more robust:

src/corelib/fpg_msgqueue.inc procedure fpgInitMsgQueue; after line "uMsgQueueList := TList.Create;" add "uMsgQueueList.Capacity := cMessageQueueSize;"

procedure fpgDeliverMessage replace "msg.Dest.Free" with "FreeAndNil(msg.Dest)"

src/corelib/fpg_main.pas procedure TfpgApplication.RunMessageLoop; reduce timeout from "WaitWindowMessage(2000);" to "WaitWindowMessage(100);"

src/corelib/fpg_widget.pas procedure procedure TfpgWidget.MsgPaint put code between "Canvas.BeginDraw;" and "Canvas.EndDraw" into try...finally

deanm73 avatar Jun 08 '23 07:06 deanm73

@graemeg - I would like to make some suggestions too. (I am in the process of migrating my whole software team to using fpGUI instead of Lazarus). In doing this, I have made 8 new styles (Luna, Charcoal, Olive, Silver, LightBlue, Chocolate, SlightPurple (Luna with matching RED to BLUE RGB values), OldMac).

I found, since 99% of the styles I am implementing, offer a "Gradient" for buttons, bars, etc. That TfpgStyle should have two additional properties (and wanted your feedback before I just dig in and start making changes):

.HasGradient:Boolean default False; .DefaultDirection: default gdVertical;

  • This will allow my styles to be called, like: (** Using fpg_button as example **) if fpgStyle.HasGradient then fogStyle.DrawButtonFace(Canvas, r, gdHorizontal, lBtnFlags); // etc.

  • I am also porting over roughly 100 components:

  • Things like fpg_shortcutBar - a 32px height panel, for buttons that link to MENU choices. ( fpg_toolBar - a 64px .. 94px height panel - for BIG FLAT buttons - like UWP style apps).

  • Accordion, Dropdown Button, MultiColumn Combobox (like a lookup combobox), etc.

  • I am also takng a stab at porting over most of RxLIB components (where license allows).

Ozz Nixon

ozznixon avatar Jan 21 '25 20:01 ozznixon

@graemeg -- Sorry, do not know how to use git to push these to you...

corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[1] := rsShortSun; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[2] := rsShortMon; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[3] := rsShortTue; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[4] := rsShortWed; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[5] := rsShortThu; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[6] := rsShortFri; corelib/fpg_main.pas:DefaultFormatSettings.ShortDayNames[7] := rsShortSat; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[1] := rsLongSun; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[2] := rsLongMon; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[3] := rsLongTue; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[4] := rsLongWed; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[5] := rsLongThu; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[6] := rsLongFri; corelib/fpg_main.pas:DefaultFormatSettings.LongDayNames[7] := rsLongSat; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[1] := rsShortJan; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[2] := rsShortFeb; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[3] := rsShortMar; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[4] := rsShortApr; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[5] := rsShortMay; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[6] := rsShortJun; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[7] := rsShortJul; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[8] := rsShortAug; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[9] := rsShortSep; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[10] := rsShortOct; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[11] := rsShortNov; corelib/fpg_main.pas:DefaultFormatSettings.ShortMonthNames[12] := rsShortDec; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[1] := rsLongJan; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[2] := rsLongFeb; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[3] := rsLongMar; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[4] := rsLongApr; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[5] := rsLongMay; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[6] := rsLongJun; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[7] := rsLongJul; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[8] := rsLongAug; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[9] := rsLongSep; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[10] := rsLongOct; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[11] := rsLongNov; corelib/fpg_main.pas:DefaultFormatSettings.LongMonthNames[12] := rsLongDec;

ozznixon avatar Jan 23 '25 05:01 ozznixon

  • Also added: Property Image to BaseButton and Button.

So Form code can do LoadImage_png('...');

  • Making Buttons much more "usable"... {IMHO}

Q1. Now, how do I make the loaded Image transparent???

Ozz

ozznixon avatar Jan 25 '25 04:01 ozznixon

Thanks @ozznixon - I've applied your localisation changes to resolve the FPC deprecation warnings

As for transparent images. fpGUI (without AggPas) relies as colour masking (eg: everything Magenta is considered transparent). When fpGUI is compiled with AggPas canvas support), it handles true transparency from the alpha channel of each colour.

graemeg avatar Jun 09 '25 12:06 graemeg

Thank you @deanm73 for your suggestions. I've applied them to the develop branch and back-ported it to the maint branch.

graemeg avatar Jun 09 '25 20:06 graemeg

@graemeg - porting over my DOS CRT (uses TPanel)... I am getting:

Got "TBitmap", expected "TfpgImageBase"

Is there a method to convert TBitmap to TfpgImageBase?

Actual Code: Self.Canvas.StretchDraw(Canvas.ClipRect,TextBuf.Picture.Bitmap);

? So, it is fair to say - TPicture to TfpgImageBase also?

Ozz

osscommunitypcb avatar Jun 11 '25 21:06 osscommunitypcb

@graemeg just to clarify more:

textbuf := Timage.create(self);

I draw onto textbuf's bitmap - DOS ROM images (from int10h.org) - so the rendering is 100% what DOS looked like (based upon the 113 ROM images I have). (Yeah, I code 99% of my "DOS" applications using this - was in D7, but, now that I have heard back from you - I am porting everything to FPC & fpGUI).

osscommunitypcb avatar Jun 11 '25 21:06 osscommunitypcb

@graemeg - porting over my DOS CRT (uses TPanel)... I am getting:

Got "TBitmap", expected "TfpgImageBase"

Is there a method to convert TBitmap to TfpgImageBase?

Not in fpGUI, because TBitmap is a Delphi (and Windows) thing. But looking at the VCL TBitmap documentation of Delphi, I believe you should be able to use the TBitmap.Scanline[] to retrieve colour data pixel-by-pixel, and then copy that colour data into a fpGUI's TfpgImage instance. It essentially boils down to copying VCL's internal pixel data to fpGUI Image class's internal image data.

The "examples/gui/imgtest/" code might be of use as a reference.

I hope that helps.

Regards, Graeme

graemeg avatar Jun 11 '25 23:06 graemeg