• Login
Community
  • Login

Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
8 Posts 4 Posters 1.3k 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.
  • D
    donho
    last edited by Aug 13, 2021, 11:05 AM

    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

    M 1 Reply Last reply Dec 26, 2021, 1:01 AM Reply Quote 1
    • D
      dail
      last edited by Aug 13, 2021, 1:04 PM

      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.

      D 1 Reply Last reply Aug 14, 2021, 11:53 AM Reply Quote 6
      • D
        donho @dail
        last edited by Aug 14, 2021, 11:53 AM

        @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.

        D 1 Reply Last reply Aug 14, 2021, 12:09 PM Reply Quote 0
        • D
          dail @donho
          last edited by Aug 14, 2021, 12:09 PM

          @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
          • D
            donho
            last edited by Aug 14, 2021, 2:06 PM

            @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
            • D
              donho
              last edited by Aug 16, 2021, 12:25 AM

              @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

              M 1 Reply Last reply Aug 16, 2021, 12:46 AM Reply Quote 7
              • M
                Michael Vincent @donho
                last edited by Aug 16, 2021, 12:46 AM

                @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
                • M
                  mattesh @donho
                  last edited by Dec 26, 2021, 1:01 AM

                  @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
                  • D donho unpinned this topic on Apr 16, 2022, 1:20 AM
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors