Skip to content

Commit

Permalink
add dark mode icons for tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
molsonkiko committed Jun 16, 2024
1 parent 9893620 commit 030a6c3
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 88 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

1. Made the tree view font size configurable with the [`tree_view_font_size` setting](/docs/README.md#styling-of-forms). Fixes [issue 66](https://github.com/molsonkiko/JsonToolsNppPlugin/issues/66).
2. Added dark mode tree view icons (addresses [this GH issue comment](https://github.com/molsonkiko/JsonToolsNppPlugin/issues/66#issuecomment-2169216078)).

### Fixed

Expand Down
7 changes: 7 additions & 0 deletions JsonToolsNppPlugin/Forms/TreeViewer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 53 additions & 20 deletions JsonToolsNppPlugin/Forms/TreeViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public partial class TreeViewer : Form
/// <summary>the most recently used quote character for s_csv in a RemesPath query</summary>
public char csvQuote;

/// <summary>
/// whether to use dark mode type icons
/// </summary>
public bool isDarkMode = false;

// event handlers for the node mouseclick drop down menu
private static MouseEventHandler valToClipboardHandler = null;
private static MouseEventHandler pathToClipboardHandler_Remespath = null;
Expand Down Expand Up @@ -211,20 +216,23 @@ private void QueryBox_KeyPress(object sender, KeyPressEventArgs e)
// TODO: maybe add some way to highlight unclosed braces?
}

public static void SetImageOfTreeNode(TreeNode root, JNode json)
public static void SetImageOfTreeNode(TreeNode root, JNode json, bool isDarkMode)
{
int imageIndex = isDarkMode ? 8 : 0;
switch (json.type)
{
case Dtype.ARR: root.ImageIndex = 0; root.SelectedImageIndex = 0; break;
case Dtype.BOOL: root.ImageIndex = 1; root.SelectedImageIndex = 1; break;
case Dtype.ARR: imageIndex += 0; break;
case Dtype.BOOL: imageIndex += 1; break;
case Dtype.DATE:
case Dtype.DATETIME: root.ImageIndex = 2; root.SelectedImageIndex = 2; break;
case Dtype.FLOAT: root.ImageIndex = 3; root.SelectedImageIndex = 3; break;
case Dtype.INT: root.ImageIndex = 4; root.SelectedImageIndex = 4; break;
case Dtype.OBJ: root.ImageIndex = 5; root.SelectedImageIndex = 5; break;
case Dtype.STR: root.ImageIndex = 6; root.SelectedImageIndex = 6; break;
default: root.ImageIndex = 7; root.SelectedImageIndex = 7; break;
case Dtype.DATETIME: imageIndex += 2; break;
case Dtype.FLOAT: imageIndex += 3; break;
case Dtype.INT: imageIndex += 4; break;
case Dtype.OBJ: imageIndex += 5; break;
case Dtype.STR: imageIndex += 6; break;
default: imageIndex = 7; break; // null type icon is same for light and dark mode
}
root.ImageIndex = imageIndex;
root.SelectedImageIndex = imageIndex;
}

public void JsonTreePopulate(JNode json, TreeView tree = null)
Expand Down Expand Up @@ -256,7 +264,7 @@ public void JsonTreePopulate(JNode json, TreeView tree = null)
pathsToJNodes.Clear();
TreeNode root = new TreeNode();
if (Main.settings.tree_node_images)
SetImageOfTreeNode(root, json);
SetImageOfTreeNode(root, json, isDarkMode);
if (json is JArray arr)
{
root.Text = TextForTreeNode("JSON", json);
Expand Down Expand Up @@ -286,6 +294,29 @@ public void JsonTreePopulate(JNode json, TreeView tree = null)
pathsToJNodes[root.FullPath] = json;
}

public void ToggleIconDarkMode(bool newIsDarkMode)
{
if (newIsDarkMode == isDarkMode)
return;
Tree.BeginUpdate();
isDarkMode = newIsDarkMode;
if (Tree.Nodes.Count > 0)
ToggleIconDarkModeHelper(Tree.Nodes[0], isDarkMode);
Tree.EndUpdate();
}

private static void ToggleIconDarkModeHelper(TreeNode node, bool isDarkMode)
{
if (node.ImageIndex != 7) // null type icon is same for dark and light mode
{
int imageIndexChange = isDarkMode ? +8 : -8;
node.ImageIndex += imageIndexChange;
node.SelectedImageIndex += imageIndexChange;
}
foreach (TreeNode child in node.Nodes)
ToggleIconDarkModeHelper(child, isDarkMode);
}

public static int IntervalBetweenJNodesWithTreeNodes(JNode json)
{
int interval = 0;
Expand All @@ -310,7 +341,8 @@ private static void JsonTreePopulateHelper_DirectChildren(TreeView tree,
TreeNode root,
JNode json,
Dictionary<string, JNode> pathsToJNodes,
bool usesSelections)
bool usesSelections,
bool isDarkMode)
{
tree.BeginUpdate();
try
Expand All @@ -330,7 +362,7 @@ private static void JsonTreePopulateHelper_DirectChildren(TreeView tree,
childNode.Nodes.Add("");
}
if (Main.settings.tree_node_images)
SetImageOfTreeNode(childNode, child);
SetImageOfTreeNode(childNode, child, isDarkMode);
pathsToJNodes[childNode.FullPath] = child;
}
}
Expand All @@ -351,7 +383,7 @@ private static void JsonTreePopulateHelper_DirectChildren(TreeView tree,
childNode.Nodes.Add("");
}
if (Main.settings.tree_node_images)
SetImageOfTreeNode(childNode, child);
SetImageOfTreeNode(childNode, child, isDarkMode);
pathsToJNodes[childNode.FullPath] = child;
}
}
Expand Down Expand Up @@ -706,7 +738,7 @@ private void ReplaceSentinelWithChildren(TreeView tree, TreeNode node)
{
nodes.RemoveAt(0);
JNode jnode = pathsToJNodes[node.FullPath];
JsonTreePopulateHelper_DirectChildren(tree, node, jnode, pathsToJNodes, UsesSelections());
JsonTreePopulateHelper_DirectChildren(tree, node, jnode, pathsToJNodes, UsesSelections(), isDarkMode);
}
}

Expand All @@ -725,7 +757,8 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree,
TreeNode root,
JNode json,
Dictionary<string, JNode> pathsToJNodes,
bool usesSelections)
bool usesSelections,
bool isDarkMode)
{
int interval = IntervalBetweenJNodesWithTreeNodes(json);
if (HasSentinelChild(root))
Expand All @@ -743,7 +776,7 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree,
JNode child = jar[ii];
TreeNode childNode = root.Nodes.Add(TextForTreeNode(ii.ToString(), child));
if (Main.settings.tree_node_images)
SetImageOfTreeNode(childNode, child);
SetImageOfTreeNode(childNode, child, isDarkMode);
pathsToJNodes[childNode.FullPath] = child;
}
}
Expand All @@ -759,7 +792,7 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree,
JNode child = jobj[key];
TreeNode childNode = root.Nodes.Add(key, TextForTreeNode(key, child));
if (Main.settings.tree_node_images)
SetImageOfTreeNode(childNode, child);
SetImageOfTreeNode(childNode, child, isDarkMode);
pathsToJNodes[childNode.FullPath] = child;
}
}
Expand All @@ -784,7 +817,7 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree,
if ((child is JArray childarr && childarr.Length > 0)
|| (child is JObject childobj && childobj.Length > 0))
{
JsonTreePopulate_FullRecursive(tree, childNode, child, pathsToJNodes, false);
JsonTreePopulate_FullRecursive(tree, childNode, child, pathsToJNodes, false, isDarkMode);
}
}
}
Expand All @@ -799,7 +832,7 @@ private static void JsonTreePopulate_FullRecursive(TreeView tree,
if ((child is JArray childarr && childarr.Length > 0)
|| (child is JObject childobj && childobj.Length > 0))
{
JsonTreePopulate_FullRecursive(tree, childNode, child, pathsToJNodes, false);
JsonTreePopulate_FullRecursive(tree, childNode, child, pathsToJNodes, false, isDarkMode);
}
}
}
Expand Down Expand Up @@ -961,7 +994,7 @@ private void Tree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
// node.ExpandAll() is VERY VERY SLOW if we don't do it this way
Tree.BeginUpdate();
isExpandingAllSubtrees = true;
JsonTreePopulate_FullRecursive(Tree, node, nodeJson, pathsToJNodes, UsesSelections());
JsonTreePopulate_FullRecursive(Tree, node, nodeJson, pathsToJNodes, UsesSelections(), isDarkMode);
node.ExpandAll();
isExpandingAllSubtrees = false;
Tree.EndUpdate();
Expand Down
61 changes: 39 additions & 22 deletions JsonToolsNppPlugin/Forms/TreeViewer.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuP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n/AfIB7AGSAfQK/wH0Bf8B9JX/
AUIBTQE+BwABPgMAASgDAAFAAwABQAMAAQEBAAEBBgABAhYAA///AP8AAwAL
</value>
</data>
<metadata name="NodeRightClickMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>303, 10</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
<value>69</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
4 changes: 2 additions & 2 deletions JsonToolsNppPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("7.2.0.1")]
[assembly: AssemblyFileVersion("7.2.0.1")]
[assembly: AssemblyVersion("7.2.0.2")]
[assembly: AssemblyFileVersion("7.2.0.2")]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion JsonToolsNppPlugin/Utils/FormStyle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Kbg.NppPluginNET;
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
Expand Down Expand Up @@ -34,6 +35,12 @@ public static void ApplyStyle(Control ctrl, bool useNppStyle, bool darkMode = fa
}
}
Color backColor = Npp.notepad.GetDefaultBackgroundColor();
if (ctrl is Forms.TreeViewer trev)
{
// determine whether to use dark mode icons (use if NPP background is very dark)
bool newIsDarkMode = useNppStyle && backColor.R <= 66 && backColor.G <= 66 && backColor.B <= 66;
trev.ToggleIconDarkMode(newIsDarkMode);
}
if (!useNppStyle || (
backColor.R > 240 &&
backColor.G > 240 &&
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you have any issues, see if [updating to the latest release](https://github.c
* [Python-style comments](/CHANGELOG.md#4120---2023-03-28)
* Missing commas and colons
* Unterminated strings, arrays, and objects
5. [Get the path to the current line](/docs/README.md#path-to-current-line)
5. [Get the path to the current position](/docs/README.md#path-to-current-position)
6. Query and edit JSON with:
* a [find/replace form](/docs/README.md#find-and-replace-form)
* an [array sorting form](/docs/README.md#sort-form)
Expand Down
Loading

0 comments on commit 030a6c3

Please sign in to comment.