@@ -36,11 +36,23 @@ namespace Snowcloak.UI;
3636
3737public partial class CompactUi
3838{
39- private const float ExpandedSidebarWidth = ModernSidebar . ExpandedWidth ;
39+ private const float ExpandedSidebarWidth = ModernSidebar . ExpandedWidth - 15f ;
4040 private const float CollapsedSidebarWidth = 28f ;
4141 private const float CollapseToggleRowHeight = 26f ;
42+ private const float SidebarItemSpacingY = 4f ;
43+ private const float SidebarSeparatorHeight = 9f ;
44+ private const float SidebarTopGap = 4f ;
45+ private const float CollapsedSidebarPaddingX = 4f ;
46+ private const float CollapsedSidebarButtonHeight = 26f ;
4247
43- private static void DrawSidebarSeparator ( ) => ModernSidebar . DrawSeparator ( ) ;
48+ private static void DrawSidebarSeparator ( )
49+ {
50+ var scale = ImGuiHelpers . GlobalScale ;
51+ var start = ImGui . GetCursorScreenPos ( ) + new Vector2 ( 8f * scale , 4f * scale ) ;
52+ var end = start with { X = start . X + ImGui . GetContentRegionAvail ( ) . X - 16f * scale } ;
53+ ImGui . GetWindowDrawList ( ) . AddLine ( start , end , Colour . Vector4ToColour ( SnowcloakColours . CompactBorderSubtle ) , 1f * scale ) ;
54+ ImGui . Dummy ( new Vector2 ( 1f , SidebarSeparatorHeight * scale ) ) ;
55+ }
4456
4557 private void DrawSidebarButton ( Menu menu , FontAwesomeIcon icon , string label )
4658 {
@@ -75,7 +87,10 @@ private void DrawSidebar()
7587 var sidebarWidth = ( collapsed ? CollapsedSidebarWidth : ExpandedSidebarWidth ) * ImGuiHelpers . GlobalScale ;
7688
7789 using var childBg = ImRaii . PushColor ( ImGuiCol . ChildBg , SnowcloakColours . CompactPanel ) ;
78- using var childPadding = ImRaii . PushStyle ( ImGuiStyleVar . WindowPadding , new Vector2 ( 14f , 12f ) * ImGuiHelpers . GlobalScale ) ;
90+ var childPaddingValue = collapsed
91+ ? new Vector2 ( CollapsedSidebarPaddingX , 12f )
92+ : new Vector2 ( 14f , 12f ) ;
93+ using var childPadding = ImRaii . PushStyle ( ImGuiStyleVar . WindowPadding , childPaddingValue * ImGuiHelpers . GlobalScale ) ;
7994 using ( var child = ImRaii . Child ( "Sidebar" , new Vector2 ( sidebarWidth , - 1 ) , false ) )
8095 {
8196 if ( collapsed )
@@ -85,8 +100,8 @@ private void DrawSidebar()
85100 }
86101
87102 using var sidebarPadding = ImRaii . PushStyle ( ImGuiStyleVar . FramePadding , new Vector2 ( 10f , 9f ) * ImGuiHelpers . GlobalScale ) ;
88- using var sidebarSpacing = ImRaii . PushStyle ( ImGuiStyleVar . ItemSpacing , new Vector2 ( ImGui . GetStyle ( ) . ItemSpacing . X , 8f * ImGuiHelpers . GlobalScale ) ) ;
89- ImGuiHelpers . ScaledDummy ( 9 ) ;
103+ using var sidebarSpacing = ImRaii . PushStyle ( ImGuiStyleVar . ItemSpacing , new Vector2 ( ImGui . GetStyle ( ) . ItemSpacing . X , SidebarItemSpacingY * ImGuiHelpers . GlobalScale ) ) ;
104+ ImGuiHelpers . ScaledDummy ( SidebarTopGap ) ;
90105
91106 // Buttons with state change
92107 DrawSidebarButton ( Menu . IndividualPairs , FontAwesomeIcon . User , "Direct Pairs" ) ;
@@ -143,6 +158,42 @@ private void DrawSidebar()
143158
144159 private void DrawCollapsedSidebar ( )
145160 {
161+ using var sidebarSpacing = ImRaii . PushStyle ( ImGuiStyleVar . ItemSpacing , new Vector2 ( 0f , SidebarItemSpacingY * ImGuiHelpers . GlobalScale ) ) ;
162+ ImGuiHelpers . ScaledDummy ( SidebarTopGap ) ;
163+
164+ DrawCollapsedSidebarButton ( Menu . IndividualPairs , FontAwesomeIcon . User , "Direct Pairs" ) ;
165+ DrawCollapsedSidebarButton ( Menu . Syncshells , FontAwesomeIcon . PeopleGroup , "Syncshells" ) ;
166+ if ( _configService . Current . ShowCompactUiPerformanceTab )
167+ {
168+ DrawCollapsedSidebarButton ( Menu . Performance , FontAwesomeIcon . ChartBar , "Performance" ) ;
169+ }
170+ DrawCollapsedSidebarSeparator ( ) ;
171+ if ( _apiController . ServerState is ServerState . Connected )
172+ {
173+ DrawCollapsedSidebarButton ( Menu . Frostbrand , FontAwesomeIcon . Snowflake , GetFrostbrandSidebarLabel ( ) ) ;
174+ }
175+ DrawCollapsedSidebarSeparator ( ) ;
176+ DrawCollapsedSidebarAction ( FontAwesomeIcon . ChartBar , "Character Analysis" ,
177+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( DataAnalysisUi ) ) ) ) ;
178+ DrawCollapsedSidebarAction ( FontAwesomeIcon . UserFriends , "Character Hub" ,
179+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( CharaDataHubUi ) ) ) ) ;
180+ DrawCollapsedSidebarAction ( FontAwesomeIcon . MapMarkedAlt , "Venues" ,
181+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( VenueAdsWindow ) ) ) ) ;
182+ DrawCollapsedSidebarAction ( FontAwesomeIcon . Comments , "Chat [BETA]" ,
183+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( ChatWindow ) ) ) ) ;
184+ DrawCollapsedSidebarAction ( FontAwesomeIcon . Cog , "Settings" ,
185+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( SettingsUi ) ) ) ) ;
186+ DrawCollapsedSidebarSeparator ( ) ;
187+
188+ if ( _apiController . ServerState is ServerState . Connected )
189+ {
190+ DrawCollapsedSidebarAction ( FontAwesomeIcon . UserCircle , "Edit Profile" ,
191+ ( ) => Mediator . Publish ( new UiToggleMessage ( typeof ( EditProfileUi ) ) ) ) ;
192+ }
193+
194+ DrawCollapsedSidebarAction ( FontAwesomeIcon . Book , "User Guide" ,
195+ ( ) => Util . OpenLink ( "https://docs.snowcloak-sync.com" ) ) ;
196+
146197 var availableSpace = ImGui . GetContentRegionAvail ( ) . Y ;
147198 var toggleHeight = CollapseToggleRowHeight * ImGuiHelpers . GlobalScale ;
148199 if ( availableSpace > toggleHeight )
@@ -153,6 +204,67 @@ private void DrawCollapsedSidebar()
153204 DrawSidebarCollapseToggle ( collapsed : true ) ;
154205 }
155206
207+ private static void DrawCollapsedSidebarSeparator ( )
208+ {
209+ var scale = ImGuiHelpers . GlobalScale ;
210+ var min = ImGui . GetCursorScreenPos ( ) ;
211+ var width = ImGui . GetContentRegionAvail ( ) . X ;
212+ var y = min . Y + 4f * scale ;
213+ ImGui . GetWindowDrawList ( ) . AddLine ( new Vector2 ( min . X + 3f * scale , y ) , new Vector2 ( min . X + width - 3f * scale , y ) ,
214+ Colour . Vector4ToColour ( SnowcloakColours . CompactBorderSubtle ) , 1f * scale ) ;
215+ ImGui . Dummy ( new Vector2 ( 1f , SidebarSeparatorHeight * scale ) ) ;
216+ }
217+
218+ private void DrawCollapsedSidebarButton ( Menu menu , FontAwesomeIcon icon , string label )
219+ {
220+ if ( DrawCollapsedSidebarIcon ( icon , label , _selectedMenu == menu ) )
221+ {
222+ _selectedMenu = menu ;
223+ }
224+ }
225+
226+ private static void DrawCollapsedSidebarAction ( FontAwesomeIcon icon , string label , Action onClick )
227+ {
228+ if ( DrawCollapsedSidebarIcon ( icon , label , active : false ) )
229+ {
230+ onClick ( ) ;
231+ }
232+ }
233+
234+ private static bool DrawCollapsedSidebarIcon ( FontAwesomeIcon icon , string tooltip , bool active )
235+ {
236+ var scale = ImGuiHelpers . GlobalScale ;
237+ var width = ImGui . GetContentRegionAvail ( ) . X ;
238+ var height = CollapsedSidebarButtonHeight * scale ;
239+ var min = ImGui . GetCursorScreenPos ( ) ;
240+
241+ ImGui . InvisibleButton ( $ "##collapsed-sidebar-{ tooltip } ", new Vector2 ( width , height ) ) ;
242+ var clicked = ImGui . IsItemClicked ( ImGuiMouseButton . Left ) ;
243+ var hovered = ImGui . IsItemHovered ( ) ;
244+ var max = min + new Vector2 ( width , height ) ;
245+ var drawList = ImGui . GetWindowDrawList ( ) ;
246+
247+ if ( active )
248+ {
249+ drawList . AddRectFilled ( min , max , Colour . Vector4ToColour ( new Vector4 ( SnowcloakUi . AccentColor . X , SnowcloakUi . AccentColor . Y , SnowcloakUi . AccentColor . Z , 0.24f ) ) , 3f * scale ) ;
250+ drawList . AddRectFilled ( min , min + new Vector2 ( 2f * scale , height ) , Colour . Vector4ToColour ( SnowcloakUi . AccentColor ) , 0f ) ;
251+ }
252+ else if ( hovered )
253+ {
254+ drawList . AddRectFilled ( min , max , Colour . Vector4ToColour ( new Vector4 ( 0.090f , 0.150f , 0.220f , 0.54f ) ) , 3f * scale ) ;
255+ }
256+
257+ var iconText = icon . ToIconString ( ) ;
258+ ImGui . PushFont ( UiBuilder . IconFont ) ;
259+ var iconSize = ImGui . CalcTextSize ( iconText ) ;
260+ drawList . AddText ( min + new Vector2 ( ( width - iconSize . X ) * 0.5f , ( height - iconSize . Y ) * 0.5f ) ,
261+ Colour . Vector4ToColour ( active ? Vector4 . One : SnowcloakColours . CompactTextMuted ) , iconText ) ;
262+ ImGui . PopFont ( ) ;
263+
264+ ElezenImgui . AttachTooltip ( tooltip ) ;
265+ return clicked ;
266+ }
267+
156268 private void DrawSidebarCollapseToggle ( bool collapsed )
157269 {
158270 var scale = ImGuiHelpers . GlobalScale ;
0 commit comments