Skip to content

Commit

Permalink
app layout: support left/right layout for thumbnail bar
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed Feb 20, 2023
1 parent 544c843 commit a2ab37d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 29 deletions.
24 changes: 6 additions & 18 deletions v9/Components/ImageGlass.Settings/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,10 @@ public static class Config
/// </summary>
public static int ThumbnailCacheSizeInMb { get; set; } = 400;

///// <summary>
///// Gets, sets width of horizontal thumbnail bar
///// </summary>
//public static int ThumbnailBarWidth { get; set; } = new ThumbnailItemInfo(ThumbnailDimension, true).GetTotalDimension();
/// <summary>
/// Gets, sets width of horizontal thumbnail bar.
/// </summary>
public static int ThumbnailBarWidth { get; set; } = (int)(ThumbnailSize * 2.5);

/// <summary>
/// Gets, sets the number of images cached by <see cref="Base.Services.ImageBooster"/>.
Expand Down Expand Up @@ -914,19 +914,7 @@ public static void Load()
#region Load thumbnail bar width & position
ThumbnailSize = items.GetValue(nameof(ThumbnailSize), ThumbnailSize);
ThumbnailCacheSizeInMb = items.GetValue(nameof(ThumbnailCacheSizeInMb), ThumbnailCacheSizeInMb);

//if (IsThumbnailHorizontal)
//{
// // Get minimum width needed for thumbnail dimension
// var tbMinWidth = new ThumbnailItemInfo(ThumbnailDimension, true).GetTotalDimension();

// // Get the greater width value
// ThumbnailBarWidth = Math.Max(ThumbnailBarWidth, tbMinWidth);
//}
//else
//{
// ThumbnailBarWidth = items.GetValue(nameof(ThumbnailBarWidth), ThumbnailBarWidth);
//}
ThumbnailBarWidth = items.GetValue(nameof(ThumbnailBarWidth), ThumbnailBarWidth);
#endregion

ImageBoosterCacheCount = items.GetValue(nameof(ImageBoosterCacheCount), ImageBoosterCacheCount);
Expand Down Expand Up @@ -1411,7 +1399,7 @@ private static dynamic PrepareJsonSettingObjects()
settings.TryAdd(nameof(SlideshowIntervalTo), SlideshowIntervalTo);
settings.TryAdd(nameof(ThumbnailSize), ThumbnailSize);
settings.TryAdd(nameof(ThumbnailCacheSizeInMb), ThumbnailCacheSizeInMb);
//settings.TryAdd(nameof(ThumbnailBarWidth), ThumbnailBarWidth);
settings.TryAdd(nameof(ThumbnailBarWidth), ThumbnailBarWidth);
settings.TryAdd(nameof(ImageBoosterCacheCount), ImageBoosterCacheCount);
settings.TryAdd(nameof(ImageBoosterCacheMaxDimension), ImageBoosterCacheMaxDimension);
settings.TryAdd(nameof(ImageBoosterCacheMaxFileSizeInMb), ImageBoosterCacheMaxFileSizeInMb);
Expand Down
18 changes: 16 additions & 2 deletions v9/ImageGlass/FrmMain/FrmMain.Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ private void ApplyAppLayout()
{
const string SEPARATOR = ";";

// Toolbar
// load Toolbar layout setting
var toolbarDock = DockStyle.Top;
var toolbarDockingOrder = 0;
if (Config.Layout.TryGetValue(nameof(Toolbar), out var toolbarLayoutStr))
Expand All @@ -1019,7 +1019,7 @@ private void ApplyAppLayout()
}


// Gallery
// load Gallery layout setting
var galleryDock = DockStyle.Bottom;
var galleryDockingOrder = 0;
if (Config.Layout.TryGetValue(nameof(Gallery), out var galleryLayoutStr))
Expand All @@ -1037,11 +1037,23 @@ private void ApplyAppLayout()
}


// update layout
#region update layout
SuspendLayout();

// update position
Toolbar.Dock = toolbarDock;
Gallery.Dock = galleryDock;
if (galleryDock == DockStyle.Left || galleryDock == DockStyle.Right)
{
Gallery.View = ImageGlass.Gallery.View.Thumbnails;
Gallery.ScrollBars = true;
}
else
{
Gallery.ScrollBars = Config.ShowThumbnailScrollbars || Gallery.View == ImageGlass.Gallery.View.Thumbnails;
}
UpdateGallerySize();


// update docking order
Expand All @@ -1058,6 +1070,8 @@ private void ApplyAppLayout()
PicMain.BringToFront();

ResumeLayout(false);
#endregion // update layout

}

}
Expand Down
36 changes: 27 additions & 9 deletions v9/ImageGlass/FrmMain/FrmMain.IGMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public bool IG_ToggleGallery(bool? visible = null)
visible ??= !Config.ShowThumbnails;
Config.ShowThumbnails = visible.Value;

Gallery.ScrollBars = Config.ShowThumbnailScrollbars;
Gallery.ScrollBars = Config.ShowThumbnailScrollbars || Gallery.View == ImageGlass.Gallery.View.Thumbnails;
Gallery.ShowItemText = Config.ShowThumbnailFilename;

// update gallery size
Expand All @@ -536,21 +536,39 @@ private void UpdateGallerySize()
{
if (!Config.ShowThumbnails) return;


var scrollBarSize = this.ScaleToDpi(1.5f); // random gap
if (Config.ShowThumbnailScrollbars && Gallery.HScrollBar.Visible)
if (Gallery.ScrollBars && Gallery.HScrollBar.Visible)
{
Gallery.HScrollBar.Height = (int)(SystemInformation.HorizontalScrollBarHeight * 0.75f);
Gallery.VScrollBar.Height =
Gallery.HScrollBar.Height =
(int)(SystemInformation.HorizontalScrollBarHeight * 0.75f);

scrollBarSize += Gallery.HScrollBar.Height;
}

// update thumbnail size
Gallery.ThumbnailSize = this.ScaleToDpi(new SizeF(Config.ThumbnailSize, Config.ThumbnailSize)).ToSize();
Gallery.ThumbnailSize = this.ScaleToDpi(new Size(Config.ThumbnailSize, Config.ThumbnailSize));


// Thumbnails view
if (Gallery.View == ImageGlass.Gallery.View.Thumbnails)
{
var minWidth = Gallery.ThumbnailSize.Width
+ (int)scrollBarSize
+ (int)(Gallery.Renderer.MeasureItemMargin(Gallery.View).Width * 6.5f);

// Gallery bar
Gallery.Height = Gallery.ThumbnailSize.Height
+ (int)scrollBarSize
+ (int)(Gallery.Renderer.MeasureItemMargin(Gallery.View).Height * 6.5f);
Gallery.Width = Math.Max(minWidth, Config.ThumbnailBarWidth);
Config.ThumbnailBarWidth = Gallery.Width;
}
// HorizontalStrip view
else
{
// Gallery bar
Gallery.Height = Gallery.ThumbnailSize.Height
+ (int)scrollBarSize
+ (int)(Gallery.Renderer.MeasureItemMargin(Gallery.View).Height * 6.5f);
}

}


Expand Down

0 comments on commit a2ab37d

Please sign in to comment.