HISE Logo Forum
    • Categories
    • Register
    • Login

    Standard way to make icon buttons?

    Scheduled Pinned Locked Moved General Questions
    13 Posts 6 Posters 370 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dannytaurusD
      dannytaurus
      last edited by

      What's the standard way to make icon buttons for things like open/close preset browser, save preset, show/hide settings menu, etc.

      Is it to use LAF on a regular button and draw a converted SVG path inside it?

      Meat Beats: https://meatbeats.com
      Klippr Video: https://klippr.video

      clevername27C 1 Reply Last reply Reply Quote 0
      • clevername27C
        clevername27 @dannytaurus
        last edited by

        @dannytaurus I use a font, Modern Pictograms. Simpler than an SVG.

        dannytaurusD Matt_SFM 2 Replies Last reply Reply Quote 1
        • dannytaurusD
          dannytaurus @clevername27
          last edited by

          @clevername27 Ah, nice tip - thanks.

          I mean more like what component do I use? Just a button styled with LAF?

          Or is there some other trick of using a panel or a label, for instance?

          Meat Beats: https://meatbeats.com
          Klippr Video: https://klippr.video

          clevername27C orangeO 2 Replies Last reply Reply Quote 0
          • clevername27C
            clevername27 @dannytaurus
            last edited by

            @dannytaurus Zzzzzzz I'll answer tomorrow.

            Christoph HartC 1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @clevername27
              last edited by

              Is it to use LAF on a regular button and draw a converted SVG path inside it?

              Yes it was until the CSS renderer came along, now I would recommended this :)

              1 Reply Last reply Reply Quote 2
              • Matt_SFM
                Matt_SF @clevername27
                last edited by

                @clevername27 said in Standard way to make icon buttons?:

                @dannytaurus I use a font, Modern Pictograms. Simpler than an SVG.

                Why haven't thought of that before ? 🤦 🤦 🤦

                Develop branch
                Win10 & VS17 / Ventura & Xcode 14. 3

                1 Reply Last reply Reply Quote 0
                • orangeO
                  orange @dannytaurus
                  last edited by

                  @dannytaurus

                  My favorite is still svg. Check this snippet:

                  Link Preview Image
                  Useful Snippets

                  Hi everyone I want to share some snippets that might be useful for you. I plan to share some stuff periodically. If you want to share yours, you can share he...

                  favicon

                  Forum (forum.hise.audio)

                  develop Branch / XCode 13.1
                  macOS Monterey / M1 Max

                  dannytaurusD 1 Reply Last reply Reply Quote 1
                  • dannytaurusD
                    dannytaurus @orange
                    last edited by

                    @orange DO you draw the SVG in a button using LAF? So you get the button functionality but it looks like an icon. Or do you do something else with the SVG?

                    Meat Beats: https://meatbeats.com
                    Klippr Video: https://klippr.video

                    orangeO 1 Reply Last reply Reply Quote 0
                    • orangeO
                      orange @dannytaurus
                      last edited by

                      @dannytaurus Yes of course, svg can be used with LAF.

                      Here is the LAF collection, check out the first example, “Gandalf Magic” button which uses this method.

                      Link Preview Image
                      LAF Collection for everyone

                      Hello Hise family, Several friends asked me for some LAF examples lately. I think it's a good idea to share them here. If you'd like to share yor LAF stuff, ...

                      favicon

                      Forum (forum.hise.audio)

                      develop Branch / XCode 13.1
                      macOS Monterey / M1 Max

                      Christoph HartC 1 Reply Last reply Reply Quote 1
                      • Christoph HartC
                        Christoph Hart @orange
                        last edited by

                        Also for bigger projects I would recommend using one LAF class for all icon buttons and then create a JSON object that contains references to the icon and use the text property as key so you can reuse the same code plus have all those big strings that contain the icon data tucked away in a single file.

                        namespace IconManager
                        {
                        inline function makePath(b64)
                        {
                            local p = Content.createPath();
                            p.loadFromData(b64);
                            return p;
                        }
                        
                        const var icons = {
                          "deleteIcon": makePath("slkdnlksjdnksvdfvishk"),
                          "addIcon": makePath("lkandlndkjcnlkasdcjnalskdjcn")
                        };
                        
                        inline function getPath(obj)
                        {
                            return icons[obj.text];
                        }
                        }
                        
                        // in your Laf:
                        function drawIconButton(g, obj)
                        {
                            g.setColour(obj.textColour);
                            g.fillPath(IconManager.getPath(obj));
                        }
                        
                        d.healeyD 1 Reply Last reply Reply Quote 3
                        • d.healeyD
                          d.healey @Christoph Hart
                          last edited by

                          @Christoph-Hart said in Standard way to make icon buttons?:

                          LAF class for all icon buttons and then create a JSON object that contains references to the icon and use the text property as key

                          This is the way I do it too.

                          @dannytaurus I know you've seen this video already but if you need a refresh I demonstrate the idea Christoph is talking about in it - https://www.patreon.com/posts/customising-with-105377992

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          dannytaurusD 1 Reply Last reply Reply Quote 1
                          • dannytaurusD
                            dannytaurus @d.healey
                            last edited by

                            @d-healey Yes, thanks. I also found your custom checkboxes video very helpful too:

                            Quick question - is it common to have several LAFs? Or is it better to just use one per project?

                            Meat Beats: https://meatbeats.com
                            Klippr Video: https://klippr.video

                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @dannytaurus
                              last edited by

                              @dannytaurus said in Standard way to make icon buttons?:

                              is it common to have several LAF

                              Yes. You should make use of local look and feel where you can. The golden rule is to avoid repeating yourself, so if multiple controls can share the same laf there is no reason why they shouldn't.

                              For the few components that can only be styled globally you should use a single global laf object.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              30

                              Online

                              1.7k

                              Users

                              11.7k

                              Topics

                              102.0k

                              Posts