mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 18:38:11 +02:00
Graph: options for depth colours and dot sizes
This commit is contained in:
1 parent
cc7d624a57
commit
0372a73dd2
8 files changed
+78
-11
No files matched your search
+15
-4
@@ -220,6 +220,8 @@ class Layout:
|
||||
# Directories go down the heading colours by depth (h1 Mauve, h2 Blue, ...),
|
||||
# starting again after Red. Files are White.
|
||||
DepthColours = ["Mauve", "Blue", "Green", "Yellow", "Peach", "Red"]
|
||||
ShrinkPerDepth = 0.8 # with GraphShrinkByDepth, each level's directory dots are this much smaller
|
||||
SmallestDirectory = 3 # ...but never smaller than a file's dot
|
||||
|
||||
|
||||
def DirectoryColour(Depth: int) -> str:
|
||||
@@ -251,6 +253,9 @@ class GraphView(ft.Container):
|
||||
self.PanButton = "Left" if TheApp.Config.GraphPanButton == "Left" else "Right"
|
||||
self.OpenButton = "Right" if self.PanButton == "Left" else "Left"
|
||||
self.ShowDirectories = TheApp.Config.GraphShowDirectories
|
||||
self.ColourByDepth = TheApp.Config.GraphColourByDepth
|
||||
self.ShrinkByDepth = TheApp.Config.GraphShrinkByDepth
|
||||
self.Depths = np.zeros(0) # each dot's depth below the graph's directory
|
||||
self.Layout: Optional[Layout] = None
|
||||
self.ScopePath = ""
|
||||
self.Size = (800.0, 600.0)
|
||||
@@ -276,7 +281,9 @@ class GraphView(ft.Container):
|
||||
)
|
||||
self.CountText = ft.Text("", size=12, color=Palette.Overlay0)
|
||||
LegendItems: list[ft.Control] = []
|
||||
if self.ShowDirectories:
|
||||
if self.ShowDirectories and not self.ColourByDepth:
|
||||
LegendItems += [ft.Text("●", color=Palette.Mauve), ft.Text("Directory", size=12, color=Palette.Overlay0)]
|
||||
elif self.ShowDirectories:
|
||||
LegendItems += [ft.Text("●", color=Palette.Mauve), ft.Text("●", color=Palette.Blue), ft.Text("●", color=Palette.Green),
|
||||
ft.Text("Directories by depth", size=12, color=Palette.Overlay0)]
|
||||
LegendItems += [ft.Text("●", color=Palette.White), ft.Text("File", size=12, color=Palette.Overlay0),
|
||||
@@ -365,8 +372,9 @@ class GraphView(ft.Container):
|
||||
return
|
||||
self.Layout = Layout(Graph)
|
||||
Base = len(Path.split("/")) if Path else 0
|
||||
self.Colours = [DirectoryColour((len(Node["Id"].split("/")) if Node["Id"] else 0) - Base) if Node["IsDirectory"]
|
||||
else Palette.White for Node in self.Layout.Nodes]
|
||||
self.Depths = np.array([(len(Node["Id"].split("/")) if Node["Id"] else 0) - Base for Node in self.Layout.Nodes])
|
||||
self.Colours = [(DirectoryColour(int(Depth)) if self.ColourByDepth else Palette.Mauve) if Node["IsDirectory"]
|
||||
else Palette.White for Node, Depth in zip(self.Layout.Nodes, self.Depths)]
|
||||
self.StatusBox.visible = False
|
||||
self.StatusBox.update()
|
||||
# Settle in steps, drawing as it goes, like the web view's animation.
|
||||
@@ -393,7 +401,10 @@ class GraphView(ft.Container):
|
||||
Zoom = math.sqrt(Scale)
|
||||
IsDirectory = np.array([Node["IsDirectory"] for Node in self.Layout.Nodes])
|
||||
Degree = np.sqrt(self.Layout.Degree)
|
||||
self.Radius = np.maximum(2, np.where(IsDirectory, 5 + Degree * 1.6, 3 + Degree * 0.8) * Zoom)
|
||||
DirectoryRadius = 5 + Degree * 1.6
|
||||
if self.ShrinkByDepth:
|
||||
DirectoryRadius = np.maximum(SmallestDirectory, DirectoryRadius * ShrinkPerDepth ** self.Depths)
|
||||
self.Radius = np.maximum(2, np.where(IsDirectory, DirectoryRadius, 3 + Degree * 0.8) * Zoom)
|
||||
|
||||
def _Label(self, Number: int, Colour: str) -> cv.Text:
|
||||
X, Y = self.Screen[Number]
|
||||
|
||||
Reference in new issue
Block a user