Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode

    Plugin Development
    4
    8
    589
    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.
    • donho
      donho last edited by

      Usage:
      void NPPM_ADDTOOLBARICON_FORDARKMODE(UINT funcItem[X]._cmdID, toolbarIconsWithDarkMode iconHandles)

      This new API NPPM_ADDTOOLBARICON_FORDARKMODE is for replacing obsolete NPPM_ADDTOOLBARICON which doesn’t support the dark mode.
      2 formats / 3 icons are needed: 1 * BMP + 2 * ICO

      All 3 handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users, also in dark mode.

      	struct toolbarIconsWithDarkMode {
      		HBITMAP	hToolbarBmp;
      		HICON	hToolbarIcon;
      		HICON	hToolbarIconDarkMode;
      	};
      

      You can find the demo here:
      https://github.com/npp-plugins/plugindemo

      mattesh 1 Reply Last reply Reply Quote 1
      • dail
        dail last edited by

        Hi @donho

        Since the NPPM_ADDTOOLBARICON message is being deprecated I do have a suggestion.

        Many existing plugins are still using this old message. This causes missing icons on the toolbar for plugins when Notepad++ is configured to use Fluent UI.

        I would suggest slightly modifying the behavior of NPPM_ADDTOOLBARICON so that it reuses the hToolbarIcon icon in place of the hToolbarIconDarkMode icon.

        This would at least allow a plugin to have ugly icons when using Fluent UI rather than icons that are completely missing.

        donho 1 Reply Last reply Reply Quote 6
        • donho
          donho @dail last edited by

          @dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:

          Many existing plugins are still using this old message. This causes missing icons on the toolbar for plugins when Notepad++ is configured to use Fluent UI.
          I would suggest slightly modifying the behavior of NPPM_ADDTOOLBARICON so that it reuses the hToolbarIcon icon in place of the hToolbarIconDarkMode icon.
          This would at least allow a plugin to have ugly icons when using Fluent UI rather than icons that are completely missing.

          Message NPPM_ADDTOOLBARICON works as usual in the newest version of Notepad++ for all plugins which use this message. It doesn’t support only dark mode.

          The new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode is here for substituting NPPM_ADDTOOLBARICON, so the retro-compatibility is remained.

          OTOH, there’s no way to extend NPPM_ADDTOOLBARICON since the pointer of icons handles structure is passed as arguments.

          dail 1 Reply Last reply Reply Quote 0
          • dail
            dail @donho last edited by

            @donho said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:

            OTOH, there’s no way to extend NPPM_ADDTOOLBARICON since the pointer of icons handles structure is passed as arguments.

            I’m not suggesting modifying the struct, just to use the one icon in the struct in all cases to prevent missing icons.

            1 Reply Last reply Reply Quote 0
            • donho
              donho last edited by

              @dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:

              I’m not suggesting modifying the struct, just to use the one icon in the struct in all cases to prevent missing icons.

              I will see what I can do about it.

              1 Reply Last reply Reply Quote 2
              • donho
                donho last edited by

                @dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:

                Your suggestion has been implemented and merged in master:
                https://github.com/notepad-plus-plus/notepad-plus-plus/commit/302bab894fd421fde371e04247357bc45728d729

                Michael Vincent 1 Reply Last reply Reply Quote 7
                • Michael Vincent
                  Michael Vincent @donho last edited by

                  @donho said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:

                  Your suggestion has been implemented and merged in master:

                  Using Fluent icons in non-dark mode with some non-fluent plugin icons and Customize Toolbar plugin - ALL WORKS!!!

                  115c11d2-777e-42d5-a558-405cb27eb89c-image.png

                  Great!

                  Thank you!

                  Cheers.

                  1 Reply Last reply Reply Quote 3
                  • mattesh
                    mattesh @donho last edited by

                    @donho
                    Was just starting to implement darkmode icons…
                    What happens with plugins used in older versions of NPP?
                    I guess I’m not the only one facing this for some time.
                    I would implement both messages and make the choice by the NPP version:

                             if (8 <= HIWORD(execute(nppHandle, NPPM_GETNPPVERSION))) { // version 8 did introduce the dark mode
                                g_TBIconsDrk.hToolbarBmp = (HBITMAP)::LoadImage(_findDlg.getHinst(), MAKEINTRESOURCE(IDB_TB_ANALYSE), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));
                                g_TBIconsDrk.hToolbarIcon = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE_NEW));
                                g_TBIconsDrk.hToolbarIconDarkMode = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE_NEW_DRK));
                                execute(nppHandle, NPPM_ADDTOOLBARICON_FORDARKMODE, (WPARAM)funcItem[SHOWFINDDLG]._cmdID, (LPARAM)&g_TBIconsDrk);
                             }
                             else {
                                g_TBIconsOld.hToolbarBmp = (HBITMAP)::LoadImage(_findDlg.getHinst(), MAKEINTRESOURCE(IDB_TB_ANALYSE), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS));
                                g_TBIconsOld.hToolbarIcon = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE));
                                execute(nppHandle, NPPM_ADDTOOLBARICON_DEPRECATED, (WPARAM)funcItem[SHOWFINDDLG]._cmdID, (LPARAM)&g_TBIconsOld);
                             }
                    

                    This works with older versions also.
                    Comments?
                    rgds, Mattes

                    1 Reply Last reply Reply Quote 1
                    • Unpinned by  donho donho 
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors