Allow custom color for Document Map

Fix #10052, close #10422
This commit is contained in:
ozone10 2021-08-21 16:07:34 +02:00 committed by Don Ho
parent e12b161d48
commit 68d293e711
10 changed files with 87 additions and 7 deletions

View File

@ -1400,5 +1400,6 @@ License: GPL2
<WidgetStyle name="Active tab text" styleID="0" fgColor="101010" /> <WidgetStyle name="Active tab text" styleID="0" fgColor="101010" />
<WidgetStyle name="Inactive tabs" styleID="0" fgColor="808080" bgColor="C0C0C0" /> <WidgetStyle name="Inactive tabs" styleID="0" fgColor="808080" bgColor="C0C0C0" />
<WidgetStyle name="URL hovered" styleID="0" fgColor="A3DCA3" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="A3DCA3" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -367,6 +367,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
TabBarPlus::setVertical((tabBarStatus & TAB_VERTICAL) != 0); TabBarPlus::setVertical((tabBarStatus & TAB_VERTICAL) != 0);
drawTabbarColoursFromStylerArray(); drawTabbarColoursFromStylerArray();
// Document Map
drawDocumentMapColoursFromStylerArray();
//--Splitter Section--// //--Splitter Section--//
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL); bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);
@ -5798,6 +5801,15 @@ void Notepad_plus::drawTabbarColoursFromStylerArray()
TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg); TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg);
} }
void Notepad_plus::drawDocumentMapColoursFromStylerArray()
{
Style* docMap = getStyleFromName(VIEWZONE_DOCUMENTMAP);
if (docMap && docMap->_fgColor != -1)
ViewZoneDlg::setColour(docMap->_fgColor, ViewZoneDlg::ViewZoneColorIndex::focus);
if (docMap && docMap->_bgColor != -1)
ViewZoneDlg::setColour(docMap->_bgColor, ViewZoneDlg::ViewZoneColorIndex::frost);
}
void Notepad_plus::prepareBufferChangedDialog(Buffer * buffer) void Notepad_plus::prepareBufferChangedDialog(Buffer * buffer)
{ {
// immediately show window if it was minimized before // immediately show window if it was minimized before

View File

@ -592,6 +592,7 @@ private:
Style * getStyleFromName(const TCHAR *styleName); Style * getStyleFromName(const TCHAR *styleName);
bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func
void drawTabbarColoursFromStylerArray(); void drawTabbarColoursFromStylerArray();
void drawDocumentMapColoursFromStylerArray();
std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams) { std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams) {
const CmdLineParamsDTO dto = CmdLineParamsDTO::FromCmdLineParams(*pCmdParams); const CmdLineParamsDTO dto = CmdLineParamsDTO::FromCmdLineParams(*pCmdParams);

View File

@ -1793,6 +1793,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
drawTabbarColoursFromStylerArray(); drawTabbarColoursFromStylerArray();
drawDocumentMapColoursFromStylerArray();
// Update default fg/bg colors in Parameters for both internal/plugins docking dialog // Update default fg/bg colors in Parameters for both internal/plugins docking dialog
StyleArray & globalStyles = (NppParameters::getInstance()).getGlobalStylers(); StyleArray & globalStyles = (NppParameters::getInstance()).getGlobalStylers();
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT); int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);

View File

@ -18,6 +18,7 @@
#include <shlwapi.h> #include <shlwapi.h>
#include "WordStyleDlg.h" #include "WordStyleDlg.h"
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
#include "documentMap.h"
using namespace std; using namespace std;
@ -476,6 +477,10 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
{ {
TabBarPlus::setColour(_pFgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex); TabBarPlus::setColour(_pFgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex);
} }
else if (isDocumentMapStyle())
{
ViewZoneDlg::setColour(_pFgColour->getColour(), ViewZoneDlg::ViewZoneColorIndex::focus);
}
apply(); apply();
return TRUE; return TRUE;
} }
@ -489,6 +494,10 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
tabColourIndex = (tabColourIndex == TabBarPlus::inactiveText ? TabBarPlus::inactiveBg : tabColourIndex); tabColourIndex = (tabColourIndex == TabBarPlus::inactiveText ? TabBarPlus::inactiveBg : tabColourIndex);
TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex); TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex);
} }
else if (isDocumentMapStyle())
{
ViewZoneDlg::setColour(_pBgColour->getColour(), ViewZoneDlg::ViewZoneColorIndex::frost);
}
apply(); apply();
return TRUE; return TRUE;
} }
@ -581,6 +590,23 @@ int WordStyleDlg::whichTabColourIndex()
return -1; return -1;
} }
bool WordStyleDlg::isDocumentMapStyle()
{
const auto i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0);
if (i == LB_ERR)
return false;
constexpr size_t styleNameLen = 128;
TCHAR styleName[styleNameLen + 1] = { 0 };
const auto lbTextLen = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXTLEN, i, 0);
if (lbTextLen > styleNameLen)
return false;
::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, reinterpret_cast<LPARAM>(styleName));
return (lstrcmp(styleName, VIEWZONE_DOCUMENTMAP) == 0);
}
void WordStyleDlg::updateColour(bool which) void WordStyleDlg::updateColour(bool which)
{ {
Style & style = getCurrentStyler(); Style & style = getCurrentStyler();

View File

@ -164,6 +164,7 @@ private :
}; };
int whichTabColourIndex(); int whichTabColourIndex();
bool isDocumentMapStyle();
void move2CtrlRight(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight); void move2CtrlRight(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight);
void updateColour(bool which); void updateColour(bool which);
void updateFontStyleStatus(fontStyleType whitchStyle); void updateFontStyleStatus(fontStyleType whitchStyle);

View File

@ -345,7 +345,9 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
_pMapView->showMargin(1, false); _pMapView->showMargin(1, false);
_pMapView->showMargin(2, false); _pMapView->showMargin(2, false);
_pMapView->showMargin(3, false); _pMapView->showMargin(3, false);
NppDarkMode::setBorder(_hwndScintilla);
return TRUE; return TRUE;
} }
@ -442,14 +444,36 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
return DockingDlgInterface::run_dlgProc(message, wParam, lParam); return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
} }
COLORREF ViewZoneDlg::_focus = RGB(0xFF, 0x80, 0x00);
COLORREF ViewZoneDlg::_frost = RGB(0xFF, 0xFF, 0xFF);
void ViewZoneDlg::setColour(COLORREF colour2Set, ViewZoneColorIndex i)
{
switch (i)
{
case ViewZoneColorIndex::focus:
{
_focus = colour2Set;
break;
}
case ViewZoneColorIndex::frost:
{
_frost = colour2Set;
break;
}
default:
return;
}
}
void ViewZoneDlg::drawPreviewZone(DRAWITEMSTRUCT *pdis) void ViewZoneDlg::drawPreviewZone(DRAWITEMSTRUCT *pdis)
{ {
RECT rc = pdis->rcItem; RECT rc = pdis->rcItem;
const COLORREF orange = RGB(0xFF, 0x80, 0x00); HBRUSH hbrushFg = CreateSolidBrush(ViewZoneDlg::_focus);
const COLORREF white = RGB(0xFF, 0xFF, 0xFF); HBRUSH hbrushBg = CreateSolidBrush(ViewZoneDlg::_frost);
HBRUSH hbrushFg = CreateSolidBrush(orange);
HBRUSH hbrushBg = CreateSolidBrush(white);
FillRect(pdis->hDC, &rc, hbrushBg); FillRect(pdis->hDC, &rc, hbrushBg);
rc.top = _higherY; rc.top = _higherY;

View File

@ -26,6 +26,8 @@
#define DOCUMENTMAP_MOUSECLICKED (WM_USER + 2) #define DOCUMENTMAP_MOUSECLICKED (WM_USER + 2)
#define DOCUMENTMAP_MOUSEWHEEL (WM_USER + 3) #define DOCUMENTMAP_MOUSEWHEEL (WM_USER + 3)
const TCHAR VIEWZONE_DOCUMENTMAP[64] = TEXT("Document map");
class ScintillaEditView; class ScintillaEditView;
class Buffer; class Buffer;
struct MapPosition; struct MapPosition;
@ -44,6 +46,11 @@ class ViewZoneDlg : public StaticDialog
public : public :
ViewZoneDlg() : StaticDialog(), _viewZoneCanvas(NULL), _canvasDefaultProc(nullptr), _higherY(0), _lowerY(0) {} ViewZoneDlg() : StaticDialog(), _viewZoneCanvas(NULL), _canvasDefaultProc(nullptr), _higherY(0), _lowerY(0) {}
enum class ViewZoneColorIndex {
focus,
frost
};
void doDialog(); void doDialog();
virtual void destroy() {}; virtual void destroy() {};
@ -63,12 +70,17 @@ public :
return (_lowerY - _higherY)/2 + _higherY; return (_lowerY - _higherY)/2 + _higherY;
}; };
static void setColour(COLORREF colour2Set, ViewZoneColorIndex i);
protected : protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK canvasStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK canvasStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK canvas_runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK canvas_runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
static COLORREF _focus;
static COLORREF _frost;
void drawPreviewZone(DRAWITEMSTRUCT *pdis); void drawPreviewZone(DRAWITEMSTRUCT *pdis);
private : private :

View File

@ -1420,5 +1420,6 @@
<WidgetStyle name="Active tab text" styleID="0" fgColor="000000" /> <WidgetStyle name="Active tab text" styleID="0" fgColor="000000" />
<WidgetStyle name="Inactive tabs" styleID="0" fgColor="808080" bgColor="C0C0C0" /> <WidgetStyle name="Inactive tabs" styleID="0" fgColor="808080" bgColor="C0C0C0" />
<WidgetStyle name="URL hovered" styleID="0" fgColor="0000FF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="0000FF" />
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -229,7 +229,7 @@
#define SCE_USER_STYLE_IDENTIFIER 24 #define SCE_USER_STYLE_IDENTIFIER 24
#define SCE_USER_STYLE_TOTAL_STYLES SCE_USER_STYLE_IDENTIFIER #define SCE_USER_STYLE_TOTAL_STYLES SCE_USER_STYLE_IDENTIFIER
#define SCE_USER_STYLE_MAPPER_TOTAL 17 #define SCE_USER_STYLE_MAPPER_TOTAL 17
#define SCE_STYLE_ARRAY_SIZE 30 // must cover sizes of NppParameters::_lexerStyler and NppParameters::_widgetStyle #define SCE_STYLE_ARRAY_SIZE 38 // must cover sizes of NppParameters::_lexerStyler
#define SCE_USER_MASK_NESTING_NONE 0 #define SCE_USER_MASK_NESTING_NONE 0
#define SCE_USER_MASK_NESTING_DELIMITER1 0x1 #define SCE_USER_MASK_NESTING_DELIMITER1 0x1