Skip to content

Commit

Permalink
User/tvandewalle/themes (#9)
Browse files Browse the repository at this point in the history
* Add JSON header library

* Themes and BrushCache first pass

Implementing basic functions for Themes (Get/Set colors, load default
settings) and BrushCache (Reset, Get color from cache)

* Switch brushes to use themes and brush cache

* WIP - Loading from file

* Implement Theme switching from menu

* Create New Theme opens CMT file for editing

* Support numpad entry

* Fix Warnings

* Stub out ability to take an action once a user stops typing

* First pass at being able to preview edits to a theme as you make them.

* Set active theme to the new one on create

* Better error handling when loading a theme by name
  • Loading branch information
vdwtanner authored Jun 2, 2023
1 parent 2f1e3cf commit 3739b0b
Show file tree
Hide file tree
Showing 14 changed files with 25,474 additions and 74 deletions.
25 changes: 25 additions & 0 deletions ColumnMode/ColumnMode.rc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ BEGIN
BEGIN
MENUITEM "Diagram Mode", ID_OPTIONS_DIAGRAMMODE, CHECKED
MENUITEM "Text Mode", ID_OPTIONS_TEXTMODE
POPUP "Themes"
BEGIN
MENUITEM "Create New Theme", ID_THEMES_CREATENEWTHEME
MENUITEM "Rescan", ID_THEMES_RESCAN
MENUITEM SEPARATOR
END
END
POPUP "Plugins"
BEGIN
Expand Down Expand Up @@ -146,6 +152,17 @@ BEGIN
EDITTEXT IDC_FIND_EDITBOX,66,7,106,14,ES_AUTOHSCROLL
END

IDD_THEMENAMEQUERY DIALOGEX 0, 0, 179, 53
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Create New Theme"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "OK",IDOK,64,28,50,14
PUSHBUTTON "CANCEL",IDCANCEL,122,28,50,14
LTEXT "Theme Name:",-1,7,9,45,8
EDITTEXT IDC_THEMENAME_EDITBOX,66,7,106,14,ES_AUTOHSCROLL
END


/////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -178,6 +195,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 46
END

IDD_THEMENAMEQUERY, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 172
TOPMARGIN, 7
BOTTOMMARGIN, 46
END
END
#endif // APSTUDIO_INVOKED

Expand Down
7 changes: 7 additions & 0 deletions ColumnMode/ColumnMode.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,27 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\External\json.hpp" />
<ClInclude Include="ColumnModePluginApi.h" />
<ClInclude Include="FindTool.h" />
<ClInclude Include="LayoutInfo.h" />
<ClInclude Include="Main.h" />
<ClInclude Include="MenuHelper.h" />
<ClInclude Include="PluginManager.h" />
<ClInclude Include="Program.h" />
<ClInclude Include="ColumnModeTypes.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Theme.h" />
<ClInclude Include="utf8Conversion.h" />
<ClInclude Include="Verify.h" />
<ClInclude Include="WindowManager.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="FindTool.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="MenuHelper.cpp" />
<ClCompile Include="PluginManager.cpp" />
<ClCompile Include="Program.cpp" />
<ClCompile Include="stdafx.cpp">
Expand All @@ -177,6 +182,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Theme.cpp" />
<ClCompile Include="WindowManager.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -187,6 +193,7 @@
<Image Include="small.ico" />
</ItemGroup>
<ItemGroup>
<None Include="idd_them.bin" />
<None Include="PluginFunctions.inl" />
<None Include="PluginManagerFunctions.inl" />
</ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions ColumnMode/ColumnMode.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\External">
<UniqueIdentifier>{97987d7c-ee66-4abd-85aa-8c2b8fe9637e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
Expand Down Expand Up @@ -51,6 +54,18 @@
<ClInclude Include="FindTool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\External\json.hpp">
<Filter>Header Files\External</Filter>
</ClInclude>
<ClInclude Include="Theme.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MenuHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utf8Conversion.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand All @@ -71,6 +86,12 @@
<ClCompile Include="FindTool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Theme.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MenuHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="small.ico">
Expand All @@ -92,5 +113,8 @@
<None Include="PluginFunctions.inl">
<Filter>Header Files</Filter>
</None>
<None Include="idd_them.bin">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
8 changes: 7 additions & 1 deletion ColumnMode/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ LRESULT CALLBACK TopLevelWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
case ID_OPTIONS_TEXTMODE:
OnTextMode(g_windowHandles);
break;
case ID_THEMES_RESCAN:
OnThemesRescan(g_windowHandles);
break;
case ID_THEMES_CREATENEWTHEME:
OnCreateTheme(hWnd, hInst);
break;
case ID_FILE_REFRESH:
OnRefresh(g_windowHandles);
break;
Expand All @@ -329,7 +335,7 @@ LRESULT CALLBACK TopLevelWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
DestroyWindow(hWnd);
break;
default:
if (!OnMaybePluginSelected(g_windowHandles, LOWORD(wParam)))
if (!OnMaybeDynamicMenuItemSelected(g_windowHandles, LOWORD(wParam)))
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
Expand Down
46 changes: 46 additions & 0 deletions ColumnMode/MenuHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "stdafx.h"

// Recursively look for the menu and position pair for the item identified by searchId
bool FindMenuPos(HMENU baseMenu, UINT searchId, HMENU& outRealBaseMenu, int& outPos)
{
int myPos;
if (baseMenu == NULL)
{
// Sorry, Wrong Number
outRealBaseMenu = NULL;
outPos = -1;
return true;
}
for (myPos = GetMenuItemCount(baseMenu) - 1; myPos >= 0; myPos--)
{
int Status = GetMenuState(baseMenu, myPos, MF_BYPOSITION);
HMENU mNewMenu;

if (Status == 0xFFFFFFFF)
{
// That was not a legal Menu/Position-Combination
outRealBaseMenu = NULL;
outPos = -1;
return true;
}
// Is this the real one?
if (GetMenuItemID(baseMenu, myPos) == searchId)
{
// Yep!
outRealBaseMenu = baseMenu;
outPos = myPos;
return true;
}
// Maybe a subMenu?
mNewMenu = GetSubMenu(baseMenu, myPos);
// This function will return NULL if ther is NO SubMenu
if (mNewMenu != NULL)
{
// recursivly look for the right menu, depth first search
bool found = FindMenuPos(mNewMenu, searchId, outRealBaseMenu, outPos);
if (found)
return true; // return this loop
}
}
return false; // iterate in the upper stackframe
}
3 changes: 3 additions & 0 deletions ColumnMode/MenuHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

bool FindMenuPos(HMENU baseMenu, UINT myID, HMENU& outMenu, int& pos);
Loading

0 comments on commit 3739b0b

Please sign in to comment.