Lazarus

Programming => Packages and Libraries => Topic started by: husker on September 23, 2020, 07:34:31 pm

Title: spkToolbar evolution
Post by: husker on September 23, 2020, 07:34:31 pm
Hello to all forum members,

I've added separators items to spkToolbar component. 2 sizes of separators are now available (large and small), as you can see on attached screenshots of the modified "actions" demo.

The changes are mainly a new ButtonKind (bkSeparator) added on TspkLargeButton and TspkSmallButton, and modifications to handle it on the necessary procedures (those that deal with drawing and size calculations).

You'll find attached the modified "spkt_Button.pas" unit (the only one I change beside demo), and if someone could "upload" it (or merge the changes) in the repository, that would be great :). All changes are commented out, starting with "// Husker". if needed, I can upload also the modified demos, or the whole package, if someone tell me how to do (the attachments size and number limitation, you know :-[...)

To be honest, I'm a hobbyist developer that only play with Lazarus, reminding me the old days when I did the same thing with Delphi Personal Edition, almost 10 years ago, and I don't know how to use SVN and all this sort of thing. As I don't want and have time to learn how to use them, I think it's better spending time trying to improve components than fighting with SVN stuff...

Last precision : I work on Windows 10 1903, and haven't tested the changes on other platforms as I don't have access to them.

Feel free to give me feedback or comments.

Regards,

Husker

Title: Re: spkToolbar evolution
Post by: Alextp on September 23, 2020, 08:03:48 pm
You can
-create account on GitHub
-create new repo there "spkToolbar"
-don't install git! Go to your repo, and use web site to Make new file (button "Add file" above file list), to Edit it later, etc. All via browser!
Title: Re: spkToolbar evolution
Post by: husker on September 23, 2020, 08:47:07 pm
Wouldn't this create a sort of alternate version of spkToolbar ? Moreover, it won't be accessible via the Online Package Manager ? I see that the current package is hosted on Sourceforge, not on GitHub...
Title: Re: spkToolbar evolution
Post by: wp on September 23, 2020, 09:18:22 pm
Thanks for this nice contribution. Good to see that people are taking the time to dig into lots of code.

I applied your changes to the current trunk version on CCR; I modified a few places to activate high-dpi scaling of the new lateral dimensions.
Title: Re: spkToolbar evolution
Post by: husker on September 23, 2020, 09:42:45 pm
Thanks for the uploading of the changes, wp :).

When I used Delphi PE 10 years ago, I enjoyed time spend to understand how the components worked, and creating new ones as exercises for me. I think I have the same kind of great time to do the same thing using Lazarus :).

spkToolbar interests me a lot: it's a good attempt to mimic the Windows ribbon, without using anything from the original library. I'm pretty sure that some things are not possible to mimic (quick access toolbar in window title, contextual tab with "titlebar overlay tab") at least for my programming skill, but maybe it's possible to add some more stuff.

I'll know dig in the drawing and position of the tabs, just to see if it's possible to push them a little bit on the right side, to leave space to add a sort of "menu button".
Title: Re: spkToolbar evolution
Post by: husker on September 23, 2020, 09:56:06 pm
wp,

Just found how to see the changes you commited to the repo. I haven't thought to put the new constants in the correct unit, this is better like this :). Also, I've seen the changes you have made to support hi-dpi scaling. I don't know the purpose of this, something more to dig in :) !

Always happy to learn, thanks a lot.
Title: Re: spkToolbar evolution
Post by: wp on September 23, 2020, 10:28:22 pm
I've seen the changes you have made to support hi-dpi scaling. I don't know the purpose of this, something more to dig in :) !
Since v1.8 Lazarus is supporting automatic scaling of sizes to the current screen resolution. While everything is done automatically for the built-in controls, third-party components must take care of scaling their inner dimensions themselves. For this purpose, the method DoAutoAdjustLayout must be overridden to apply the scaling factor (https://wiki.lazarus.freepascal.org/High_DPI#High_DPI_in_Lazarus_1.8_and_above). There is another method ScaleFontsForPPI() which takes care of scaling the font sizes. For older Laz versions, spkToolbars contains his own, simpler, scaling method which is executed in procedure SpkInitLayoutConsts() of unit spkt_Const.
Title: Re: spkToolbar evolution
Post by: husker on September 24, 2020, 10:16:12 pm
Thanks for the input, wp. I've read the wiki page, it's clear for me now. I'll try to manage this in my next evolution(s) of SpkToolbar.
Title: Re: spkToolbar evolution
Post by: husker on September 25, 2020, 08:31:53 pm
Hello all,

Here is a small correction for the spkToolbar editor (design mode) : the bitmap of the action used to insert new SpkRadioButton was not the right one, due to a mistake in the ImageIndex.

Wp (or somebody who know how to do), could you please merge the modified files attached ? I've installed TortoiseSVN, succeeded to do a checkout of spkToolbar from Lazarus-CCR, but I'm not sure what to do to achieve a correct commit... Should I have to create an account on SourceForge to be able to do commit from my Windows Explorer using Tortoise ? How can I tell that it's me the author of the commit ? This is not clear at all for me %)...

Thanks in advance, regards,

Husker.
Title: Re: spkToolbar evolution
Post by: wp on September 25, 2020, 11:42:29 pm
At the moment you cannot commit. But when you have submitted several changes I can ask that you get commit rights.

Since you have svn now I'd like to ask you to create a proper patch instead of submitting the entire units. A patch contains only differences between your local version and the repository version - this way I can see more easily what you changed.

In order to create a patch with Tortoise you must right-click on your local spktoolbar folder and select "Create patch..." from the "TortoiseSVN" submenu. Tortoise will create a list of changed files, you can double-click any of them to see the changes yourself. Save the patch and upload it here. (This is the same procedure basically how you can create a patch for Lazarus itself).

The ideal place to submit patches is the bug tracker (link in the left forum bar) because changes can be documented in a more formal way than here. But for me, it's ok too if you submit your CCR patches to the forum because CCR is a rather informal activity.

Could you try to practice this with your current modification?
Title: Re: spkToolbar evolution
Post by: husker on September 26, 2020, 12:36:27 pm
At the moment you cannot commit. But when you have submitted several changes I can ask that you get commit rights.

It's OK for me, I don't really want to have direct access to commit. I tested this because I was wondering that maybe it could bother you to merge my changes in the repository for me.

As I said previously, I'm just an hobbyist developer, not a professionnal one, and I prefer that somebody check my changes first before eventually merge then in the repository. I don't want to break things in the repository :). And I have no problem to have comments on my work, as I do this to learn something ;).

Quote from: wp
Since you have svn now I'd like to ask you to create a proper patch instead of submitting the entire units. A patch contains only differences between your local version and the repository version - this way I can see more easily what you changed.

In order to create a patch with Tortoise you must right-click on your local spktoolbar folder and select "Create patch..." from the "TortoiseSVN" submenu. Tortoise will create a list of changed files, you can double-click any of them to see the changes yourself. Save the patch and upload it here. (This is the same procedure basically how you can create a patch for Lazarus itself).

That's OK for me.

Quote from: wp
The ideal place to submit patches is the bug tracker (link in the left forum bar) because changes can be documented in a more formal way than here. But for me, it's ok too if you submit your CCR patches to the forum because CCR is a rather informal activity.

I took a look at bug tracker, maybe I'll use it later, if you think it's necessary. You'll probably have to explain me how it works, however... But for now, I'll create patches and post them here in the forum, for review and merge if all is OK.

Quote from: wp
Could you try to practice this with your current modification?

Attached is the patch for the change in the design editor. Please, check it and tell me if it's OK :).

Thanks for your time and your explanations, they are highly appreciated.

Regards,

Husker.
Title: Re: spkToolbar evolution
Post by: wp on September 26, 2020, 01:30:43 pm
Applied your patch, thank you.
Title: Re: spkToolbar evolution
Post by: husker on September 26, 2020, 09:41:18 pm
Hello all,

Here is another contribution to spkToolbar.

I've added 'More options' button to Pane. You can now hide/show a button on the right-bottom corner of the pane. When clicked, an event is launched. This way it's possible to show another form, for example.

See screenshots below to see how it looks. Tested with all the built-in styles, but only on Windows 10 1903.

Patch is attached too. Wp, I'm not sure to have handled correctly Hi-Dpi, maybe a double check on this point is necessary.

Enjoy :).

Regards,

Husker
Title: Re: spkToolbar evolution
Post by: Zoran on September 26, 2020, 10:32:22 pm
I took a look at bug tracker, maybe I'll use it later, if you think it's necessary. You'll probably have to explain me how it works, however... But for now, I'll create patches and post them here in the forum, for review and merge if all is OK.

When you want to learn more about how to use bug tracker, you can read this wiki page (https://wiki.freepascal.org/How_do_I_create_a_bug_report).

As Werner says, it is ok for now to post your patches for spkToolBar here.
However, as FPC/Lazarus user, one day you will encounter bugs in LCL, or even in the compiler. Then it is nice to report it properly. :)

Understandably, developers will often miss bugs reported in forum. Bugs reported in bugtracker have much bigger chance to be taken and solved. It is also so when asking for improvements.
And further, the chance that the reported bug (or improvement you ask for) gets applied raises a lot when a patch is provided (as you did in this case). But of course, it is not expected that you can solve any bug, then you should just report it.
Title: Re: spkToolbar evolution
Post by: husker on September 26, 2020, 11:04:48 pm
Thanks for the link Zoran.

I'll study it and try to post my improvements patches of SpkToolbar directly in Bug Tracker, and put a note on the forum when done.

But what happen if I create a patch if the previous one is not yet applied on the repo ? Wouldn't the second patch also hold the changes of the first patch ? If yes, I guess this will get things confusing in the Bug Tracker %)...
Title: Re: spkToolbar evolution
Post by: wp on September 27, 2020, 12:41:37 am
Thanks for the nice patch. I applied it with minor modifications:

- Allow for an "arrow-corner" symbol similar to MS Office, in addition to your "plus" (in case that the font on non-Windows systems does not have the corresponding UTF8 code point).
- Fixed a bug firing mouse click events on a hidden "more options" button.
Title: Re: spkToolbar evolution
Post by: husker on September 27, 2020, 02:29:43 pm
Thanks wp for corrections and applying the patch :).

I just investigate your changes, and I wonder what is the '#$E2#$87#$B2' code that stands for the arrow char ? When I wrote the code, I wonder how I could draw the arrow but as I don't know how to do it, I wrote instead the '+' sign ::). I didn't know that the arrow could exists as a character or something else. I thought it was drawn like a sort of bitmap.

Good catch on the fire event bug. I neglected to check if the 'more options' button was visible before firing it  :-[...

I've some other ideas for spkToolbar, I'll try to program them.
Title: Re: spkToolbar evolution
Post by: wp on September 27, 2020, 02:41:15 pm
I wonder what is the '#$E2#$87#$B2' code that stands for the arrow char ?
Lazarus and thus spktoolbar work with utf8-encoded strings. In order to see all utf8-"characters", open the "Character map" under the "Edit" menu. The "corner arrow" can be found in the "Arrows" range. Note that any arbitrary code point is not necessarily contained in the font currently used. When you click on a cell in the character map the related character is copied into your source code window. The #$E2#$87#$B2 is the binary representation of the "corner arrow" - I hope you know that utf8 consists of up to 4 bytes per "character" (or better: code point - see any other discussion about utf8 here in the forum).
Title: Re: spkToolbar evolution
Post by: husker on September 27, 2020, 03:23:49 pm
Thanks for the explanation, wp.

Now, I know what is UTF-8 :D. To be honest, I haven't got theorical programming background. I've learnt by myself, and I've probably missed many important things... "The one who is his own teacher is more likely the student of a dumb", someone told me this one day. OK, I can live with this, as I learn new things every day !

My only programming background is not very useful here: I'm a former G-Code for CNC-driven machines...

But indeed, the built-in character map in Lazarus could be really useful.

I just made a try with a blank project, and tried to assign at runtime this binary representation to a TLabel. But instead of the arrow, I get a "?W" as caption label... And the font label is Segoe UI, so is the TSpkPane font. Do I miss something here %) ?
Title: Re: spkToolbar evolution
Post by: wp on September 27, 2020, 03:38:21 pm
No need to excuse for your missing background. I don't have formal IT training either. You submit good patches, and that's all what counts.

I don't know what you are doing exactly. Here is the screenshot for a form with a label, font blown up to 24 pt, and with this OnCreate handler, on Win 10, font Segoe UI:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Label1.Caption := #$E2#$87#$B2;
  4. end;  
I'm not very happy with this glyph because the arrow head is very tiny at "real" font size -- but maybe you find a better one in the UTF8 table.
Title: Re: spkToolbar evolution
Post by: husker on September 27, 2020, 03:52:33 pm
I think I've done something wrong... Testing again using  your code is OK, and I get exactly your screenshot. Duuhhh... OK, it works now.
Title: Re: spkToolbar evolution
Post by: wp on September 27, 2020, 05:04:08 pm
But what happen if I create a patch if the previous one is not yet applied on the repo ? Wouldn't the second patch also hold the changes of the first patch ?
I am not very strong in these version control systems. But my feeling is that with SVN you must wait until the first patch has been applied before you can submit a follow-up patch. With GIT you can create a merge request after each patch separately. Standard access to Lazarus version control, however, is SVN, but I know that some developers maintain a git mirror.

In any case try to keep the patches as "atomic" as possible, i.e. address only a single feature. Do not change formatting or so, because this will crowd the diff file with many unrelated details and make it very difficult to see how the bug is fixed by your changes.

As far as spktoolbar is concerned, I see myself as the current maintainer after the original author disappeared. So, you can assign your spktoolbar bug tracker reports to me, and I will see the report in bugtracker in my personal filtered list. But as i said earlier I do not insist on bug tracker reports, at least for spktoolbar; there is only some chance that I could miss a report when the "Recent" list overflows (in this case - if nothing happens after a few days - send me a PM reminder).
Title: Re: spkToolbar evolution
Post by: husker on September 27, 2020, 05:38:56 pm
I had some troubles to update my SpkToolbar after you committed my last patch : updated using SVN cause conflicts on all the changed files. It made my rebuild of Lazarus crashing due to weird texts on the unit (seems that it was the "patch commands" that were put directly in the source :o !). I had to revert back using SVN, and then I got the correct, updated, units... I don't know what happen, but finally all is working now.

If you are OK, I'll continue posting the next patch here for now. And some day, I'll try to use bug tracker...

Next evolution might take a much longer time, I guess theses changes will need to dig deeper ;).
Title: Re: spkToolbar evolution
Post by: wp on September 27, 2020, 07:15:38 pm
I had some troubles to update my SpkToolbar after you committed my last patch : updated using SVN cause conflicts on all the changed files. It made my rebuild of Lazarus crashing due to weird texts on the unit (seems that it was the "patch commands" that were put directly in the source :o !). I had to revert back using SVN, and then I got the correct, updated, units... I don't know what happen, but finally all is working now.
The reason probably is that I did not apply your patch byte-by-byte: I renamend some identifiers, and also added the MoreButtonStyle property. Therefore, your version was no longer the same as that from the ccr repository. In such cases, I always revert my version and update to the official revision; in case of a conflict I always accept "their" version.
Title: Re: spkToolbar evolution
Post by: husker on September 27, 2020, 07:19:05 pm
OK, I understand. I'll do this next time. Thanks for the tip, wp.
Title: Re: spkToolbar evolution
Post by: husker on September 28, 2020, 10:17:24 pm
Hello all,

Something is cooking... This is the first step, more to come (soon, I hope !)
Title: Re: spkToolbar evolution
Post by: husker on October 02, 2020, 11:21:49 am
Hello all,

Here is my new contribution to TSpkToolbar: I've added a Menu Button that can drop a dropdown menu. This Menu Button can be shown or hidden, as well as a dropdown arrow on it. I tried to choose colors that match the ones already existing on each theme.

Added properties:

Added event:

TSpkAppearance was updated accordingly to manage colors and style of MenuButton: there is now a new "Menu Button" appearance object, exposing colors and style. The design time appearance editor was updated too.

Last, I've modified some demo projects to show the new capacities.

Enjoy :) !

Title: Re: spkToolbar evolution
Post by: husker on October 02, 2020, 11:23:20 am
Here is the corresponding patch.

Wp or anyone who can do: please review, and if OK merge it in the repository.

Thanks in advance.
Title: Re: spkToolbar evolution
Post by: wp on October 02, 2020, 01:09:47 pm
To make sure that I understand correctly: Is this the first button of the ribbon which has some special function (I never understood why)? The one that brings up the full-page menu in MS Office and the 2-level drop-down menu of the Win10 Explorer?
Title: Re: spkToolbar evolution
Post by: husker on October 02, 2020, 01:29:51 pm
Yes Wp, this is the equivalent of the first blue button of Win10 Explorer or Wordpad.

As I still don't know how to mimic the full page menu of MS Office or the 2-level dropdown menu of some Win10 apps, I've made a simpler one, which mimic the look of the original MS button but dropdown a simple TPopupMenu.

Maybe one day I'll add something closer to the original Ribbon insted of the TPopupMenu...

Please note that it's not mandatory to use this new feature: Menu Button and all related stuff is optional, it's still possible to use TSpkToolbar like previously.

As I was digging deeply in drawing codes, I've also corrected a few drawing glitches that existed on the Tabs, especially visible with Metro Light and Metro Dark themes. The upper right corner of tabs in Active mode had an extra pixel outside the frame, and the left frame line was not drawn at all (the tab rect had its left border outside of the component on the first tab).
Title: Re: spkToolbar evolution
Post by: wp on October 02, 2020, 11:43:48 pm
Thanks.

I tried to apply the patch, but was not successful ("The patch does not apply cleanly ... Patching is not possible"). I split it into the individual file parts, and managed to patch spkt_Const, spkToolbar and spkt_Appearance as well as the demo. As for the AppearanceEditor, however, the patch file contains a note for the lfm file saying "Cannot display: file marked as a binary type.".

Could you please try to create the patch again for the appearance editor again? As an exception add also the full files, if there is such an issue again.
Title: Re: spkToolbar evolution
Post by: husker on October 03, 2020, 09:32:32 am
Weird... I've created a new patch with only Appearance Editor unit and form, and I also got the "Cannot display: file marked as a binary type" when I check the patch in TortoiseUDiff. But seeing diffs with TortoiseMerge, the .lfm file is seen as a text file ?! I should do something wrong, but I don't know what  %)...

I attach the patch but also the original files (I had to change .lfm file extension to attach it).

Thanks for your time :).
Title: Re: spkToolbar evolution
Post by: wp on October 03, 2020, 04:59:21 pm
Still the same problem, no idea why TortoiseSVN considers a file with mime-type text/plain as binary... But with the full files I could complete the patch. Thanks. I fixed anchoring and TabOrder and reworked the autosizing for the AppearanceEditor.
Title: Re: spkToolbar evolution
Post by: husker on October 03, 2020, 08:13:18 pm
OK.

Thanks wp for the corrections, and merging my changes. I must confess that I completely forgot to check tab order on the appearance editor  :-[...

I'll update my package to match the repository, and start working on the next step. I've 3 or 4 differents things that I still want to add, but I don't know yet which one I'll pick and work on :). I need to think about this for a while now.

Stay tuned  ;).
TinyPortal © 2005-2018