It is currently Sat Nov 28, 2020 9:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 265 posts ]  Go to page Previous  1 ... 12, 13, 14, 15, 16, 17, 18  Next
Author Message
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 01, 2017 3:52 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
A request to the resident artists : a transparent or translucent icon would be a useful addition, I think.
An invisible icon really ! :shock:
Sounds crazy, i know, but it could be used as a space-holder or spacer, on a toolbar, for instance.

To all of you behind this project : thank you for your excellent work and for a great contribution to the PureBasic world. Obviously, you've answered a need, and in a brilliant way.

Off topic : Of course, all of this has been made possible by the recent addition of vector graphics to PB. So, in passing, i also want to thank Fred, Freak, and the other developers who keep pushing PureBasic forward.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 01, 2017 6:04 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Hi Blue,

thanks for your very kind words! You are welcome.

Blue wrote:
A request to the resident artists : a transparent or translucent icon would be a useful addition, I think.
An invisible icon really ! :shock:
Sounds crazy, i know, but it could be used as a space-holder or spacer, on a toolbar, for instance.

Cool idea! 8)
I just added such an icon to the code for the next release.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 01, 2017 6:27 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3346
Location: Boston, MA
Blue wrote:
Sounds crazy, i know, but it could be used as a space-holder or spacer, on a toolbar, for instance.
Call me crazy, but I use transparent images as toolbar separators since the thin black bar is not wide enough to prevent operator miss clicks.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 01, 2017 9:18 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Well, since you insist, skywalk, we'll gladly call you crazy.
But your kind of crazy is what sane people ought to aim for. :wink:

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Thu Mar 02, 2017 5:26 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3346
Location: Boston, MA
Cool, v56 final fixes my toolbar code. Windows only. Note, an empty image is not required to create a same size separator.
EDIT: removed link to bug url per Fred's note below.
Code:
EnableExplicit
Global.i evWW, evM, tbn
Global.l tb_maxSize = 16

Macro Min(x, y)
  (Bool((x) <= (y)) * (x) + Bool((y) < (x)) * (y))
EndMacro
Macro Max(x, y)
  (Bool((x) >= (y)) * (x) + Bool((y) > (x)) * (y))
EndMacro
Macro MAKELONG(wLo, wHi)
  ((wLo) & $FFFF) | (wHi) << 16
EndMacro

Procedure tb_images(tb_maxSize)
  CreateImage(0, tb_maxSize, tb_maxSize)
  StartDrawing(ImageOutput(0))
  Box(0, 0, tb_maxSize, tb_maxSize, #Red)
  DrawText(2,0,"-")
  StopDrawing()
  CreateImage(2, tb_maxSize, tb_maxSize)
  StartDrawing(ImageOutput(2))
  Box(0, 0, tb_maxSize, tb_maxSize, #Blue)
  DrawText(2,0,"+")
  StopDrawing()
EndProcedure

Procedure tb_scale(tb_maxSize)
  If tb_maxSize > 16
    tbn = CreateToolBar(#PB_Any, WindowID(0), #PB_ToolBar_Large)
    Protected.i tbh = ToolBarID(tbn)
    If tbh
      ResizeImage(0,tb_maxSize,tb_maxSize,#PB_Image_Smooth)
      ResizeImage(2,tb_maxSize,tb_maxSize,#PB_Image_Smooth)
      If 0
        Protected.i hTBimgList, hTBimgList2
        hTBimgList = SendMessage_(tbh, #TB_GETIMAGELIST, 0, 0)
        hTBimgList2 = ImageList_Duplicate_(hTBimgList)
        ImageList_Destroy_(hTBimgList)
        Swap hTBimgList, hTBimgList2
        ImageList_SetIconSize_(hTBimgList, tb_maxSize, tb_maxSize)
        SendMessage_(tbh, #TB_SETIMAGELIST, 0, hTBimgList)
        SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
        SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
        SendMessage_(tbh, #TB_SETBUTTONSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
        SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
        SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
      Else
        hTBimgList = SendMessage_(tbh, #TB_GETIMAGELIST, 0, 0)
        ImageList_SetIconSize_(hTBimgList, tb_maxSize, tb_maxSize)
        SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
        SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
      EndIf
      ToolBarImageButton(0, ImageID(0))
      ToolBarSeparator()
      ToolBarImageButton(1, 0)  ; same size separator using empty image.
      ToolBarImageButton(2, ImageID(2))
    EndIf
  Else
    tbn = CreateToolBar(#PB_Any, WindowID(0), #PB_ToolBar_Small)
    tbh = ToolBarID(tbn)
    If tbh
      ToolBarImageButton(0, ImageID(0))
      ToolBarSeparator()
      ToolBarImageButton(1, 0)  ; same size separator using empty image.
      ToolBarImageButton(2, ImageID(2))
    EndIf
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 500, 500, "v56 - Scaled Toolbar & Wide Separator(Windows only)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  tb_images(16)
  tb_scale(16)
  StartDrawing(WindowOutput(0))
  Box(0,0,500,500,#White)
  DrawText(5,280,"Click the '+' image tool bar.")
  StopDrawing()
  SmartWindowRefresh(0,1)
  Repeat
    evWW = WaitWindowEvent()
    If evWW = #PB_Event_Menu
      evM = EventMenu()
      FreeToolBar(#PB_All)
      If evM = 0
        tb_maxSize = max(tb_maxSize - 16, 16)
        Debug "tb#" + evM + ", " + Str(tb_maxSize)
      ElseIf  evM = 2
        tb_maxSize = max(tb_maxSize + 16, 16)
        Debug "tb#" + evM + ", " + Str(tb_maxSize)
      EndIf
      tb_scale(tb_maxSize)
      StartDrawing(WindowOutput(0))
      Box(0,0,500,500,#White)
      If tb_maxSize > 16
        DrawText(5,280,"Click image tool bars.")
        DrawText(5,310,"Toolbar resized to " + Str(tb_maxSize) + " pixels.")
      Else
        DrawText(5,280,"Click image '+' tool bar.")
      EndIf
      DrawImage(ImageID(0), 100, 350)
      DrawImage(ImageID(2), 300, 350)
      StopDrawing()
    ElseIf evWW = #PB_Event_CloseWindow
      Break
    EndIf
  ForEver
EndIf

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Last edited by skywalk on Thu Mar 02, 2017 5:39 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Thu Mar 02, 2017 5:33 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14179
Location: France
You should not link to a bug report, as it will be moved to an hidden forum and the link will be broken


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Thu Mar 02, 2017 6:09 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
@Little John
Question 1:
Little John wrote:
Cool idea! 8)
I just added such an icon to the code for the next release.
How do we know which is the latest release ? Have you introduced some kind of versioning scheme ?

Question 2: when you implement the transparent icon, is it possible to provide an adjustable width parameter ? I'm thinking that it would be convenient to specify, for example, an icon as Wide as 5 regular ones rather than having to code and display 5 separate invisible icons in order to insert a 5-icons wide space. Or is that kind of thing not doable ?

@skywalk: thank you for the smart algorithm, but that kind of code is above my pay grade. :oops:

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Sun Mar 05, 2017 7:34 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
@Little John

Would it be too much to ask that the macros and procedures within each grouping in vectoricons.pbi be sorted alphabetically? (with some exceptions, such as those macros defined by previously defined macros, as well as logical groupings such as the sort and chess pieces procedures)

I've done it in the copy I downloaded. It makes visually locating specific procedures a lot easier.

If it's a matter of too much work, just let me know. I'll gladly do it for you. Once done, it would be simple to maintain, since further additions would simply be inserted in their proper alphabetical position.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Mon Mar 06, 2017 8:05 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Hello Blue.

Blue wrote:
@Little John
Question 1:
How do we know which is the latest release ? Have you introduced some kind of versioning scheme ?

In the first post of this thread, there is always the date of the most recent release. Currently you have to compare it with the time stamp of the downloaded ZIP archive. That's not very comfortable, I am sorry.
Beginning with the next release, I'll write the release date in the file 'vectoricons.pbi'.

Blue wrote:
Question 2: when you implement the transparent icon, is it possible to provide an adjustable width parameter ? I'm thinking that it would be convenient to specify, for example, an icon as Wide as 5 regular ones rather than having to code and display 5 separate invisible icons in order to insert a 5-icons wide space. Or is that kind of thing not doable ?

This is the current code for the transparent icon in my private copy of 'vectoricons.pbi':

Code:
   Procedure.i Transparent (file$, img.i, size.i)
      ; in : file$: name of SVG file which is to be created (only supported on Linux),
      ;             or "" for creating an image in memory
      ;      img  : number of the image which is to be created, or #PB_Any
      ;      size : width and height (number of pixels)
      ; out: return value: if img = #Pb_Any --> number of the created image,
      ;                    on error --> 0
      ; [by Little John, after an idea by Blue]
      Protected ret.i
     
      ret = StartVectorIconOutput(file$, img, size)
     
      If ret
         StopVectorDrawing()
      EndIf
     
      ProcedureReturn ret
   EndProcedure

All icon procedures currently contain the line

Code:
ret = StartVectorIconOutput(file$, img, size)

So there are no separate 'width' and 'height' parameters, but only one 'size' parameter, since all icons are square.
When the icons are used together with PB's built-in toolbar functions, then icons that are not square probably will not work, I think. According to the docs, only square icons are supported. And when we create icons on custom controls by using the canvas gadget, something like this IMO is not required, since in that case we have complete control over the locations were the icons are placed.

Blue wrote:
@Little John

Would it be too much to ask that the macros and procedures within each grouping in vectoricons.pbi be sorted alphabetically? (with some exceptions, such as those macros defined by previously defined macros, as well as logical groupings such as the sort and chess pieces procedures)

I've done it in the copy I downloaded. It makes visually locating specific procedures a lot easier.

If it's a matter of too much work, just let me know. I'll gladly do it for you. Once done, it would be simple to maintain, since further additions would simply be inserted in their proper alphabetical position.

Hmm ... Frankly, I don't know whether I like that idea. :-/
For instance, I want the icons 'ToClipboard' and 'FromClipboard' to be next to each other, and also e.g. the icons 'Redo' and 'Undo'. After sorting the macros and procedures alphabetically, this order would be destroyed.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Mon Mar 06, 2017 4:09 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Hi Little John
I see that you've thought of everything.
Thank you.
Quote:
Hmm ... Frankly, I don't know whether I like that idea. :-/
Frankly, I agree with you. I think it was a good idea... at first glance only :(

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 08, 2017 10:40 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Current changes (2017-03-08)
  • Added icon "Transparent" (suggested by Blue, thank you!).
  • Removed unnecessary code from some icon procedures.
  • Some minor cosmetic changes in 'vectoricons.pbi'.
  • Moved example code files to a subfolder and added 2 new examples.
  • Entered the release date in files 'vectoricons.pbi' and 'vectoriconbrowser.pbi'.
  • Added release date to the name of the ZIP archive.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Wed Mar 08, 2017 12:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Little John wrote:
Current changes (2017-03-08)
Brilliant work, Little John. What a positive change it brings to the way i program my little apps. I love it !
Thank you.

If it's not too late in the game, I'd like to suggest a few changes to the collection of icons.
(1) I think that the 'Add' icon should be renamed 'Plus'; 'add' is a math operation, while 'plus' is the actual name of the symbol.
(2) same reasoning for 'Sub' (math operation) to be renamed 'Minus' (actual name of the sign)
(3) 'Stop' should be renamed 'StopSign'', for better accuracy.
There may be a few others in that vein, but they escape me right now.

I also think that, for logical grouping within the file, all chess pieces should be prefixed by 'Chess_'

If at all possible, I'd appreciate those modifications. But I wouldn't want to raise a wave of protests from people saying that such changes would break their code. Suggestions are only that, and they can always find a welcoming home in the circular file.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Thu Mar 09, 2017 7:18 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Blue wrote:
Little John wrote:
Current changes (2017-03-08)
Brilliant work, Little John. What a positive change it brings to the way i program my little apps. I love it !
Thank you.

Blue, you are most welcome! I'm glad that you like this contribution.

Blue wrote:
If it's not too late in the game, I'd like to suggest a few changes to the collection of icons.
(1) I think that the 'Add' icon should be renamed 'Plus'; 'add' is a math operation, while 'plus' is the actual name of the symbol.
(2) same reasoning for 'Sub' (math operation) to be renamed 'Minus' (actual name of the sign)
(3) 'Stop' should be renamed 'StopSign'', for better accuracy.
There may be a few others in that vein, but they escape me right now.

There is no unique naming scheme for the icons, and their names have been chosen more or less spontaneously by their respective creators. However, as far as I can see, the current names are mainly according to two general principles:
  1. The name is a description of what the icon actually shows, such as "UpArrow", "DownArrow", "SnowFlake", etc.
  2. The name is a suggestion which action the icon should/could represent, i.e. which action will take place when the button with that icon on it will be clicked. It's a word which the programmer might also choose for the caption or the tooltip of the respective button. So for instance there is "FindNext" (instead of "Magnifying glass with arrow"), "Cut" (instead of "Scissors"), "Undo" (instead of "Curved clockwise arrow"). Isn't it the same with "Add" vs. "Plus", "Sub(tract)" vs. "Minus", and "Stop" vs. "StopSign"?

Blue wrote:
I also think that, for logical grouping within the file, all chess pieces should be prefixed by 'Chess_'

I want to leave that decision to the creator of those fine chess icons (davido).

BTW: Since we now have these icons, who is going to write a chess program in PB? 8)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Thu Mar 09, 2017 9:39 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1791
Location: Uttoxeter, UK
Hi Little John,
I have no issue with any changes you wish to make to any of the Icons that I have contributed.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Create your own icons for toolbars etc. with PureBasic
PostPosted: Fri Mar 10, 2017 11:10 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Hi davido,

that is very generous, thank you!

So if there will be no objections by other people, then in the next release I'll add the prefix "Chess_" to the names of all chess icons, as suggested by Blue.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 265 posts ]  Go to page Previous  1 ... 12, 13, 14, 15, 16, 17, 18  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye