[mac] SparkleSetup: support @2x images
Since the plugin images come from a manifest with full paths, to support @2x images we have to do a little more work by rebuilding the image path based on NSWindow.BackingScaleFactor. Theoretically this is forward compatible with future scalings (e.g. @3x, @9000x).
This commit is contained in:
parent
5d7f3e2386
commit
19e460f8ad
|
@ -253,7 +253,7 @@ namespace SparkleShare {
|
|||
TableView.AddColumn (IconColumn);
|
||||
TableView.AddColumn (DescriptionColumn);
|
||||
|
||||
DataSource = new SparkleDataSource (Controller.Plugins);
|
||||
DataSource = new SparkleDataSource (BackingScaleFactor, Controller.Plugins);
|
||||
|
||||
TableView.DataSource = DataSource;
|
||||
TableView.ReloadData ();
|
||||
|
@ -725,13 +725,16 @@ namespace SparkleShare {
|
|||
public List<object> Items;
|
||||
public NSAttributedString [] Cells, SelectedCells;
|
||||
|
||||
int backingScaleFactor;
|
||||
|
||||
public SparkleDataSource (List<SparklePlugin> plugins)
|
||||
public SparkleDataSource (float backingScaleFactor, List<SparklePlugin> plugins)
|
||||
{
|
||||
Items = new List <object> ();
|
||||
Cells = new NSAttributedString [plugins.Count];
|
||||
SelectedCells = new NSAttributedString [plugins.Count];
|
||||
|
||||
this.backingScaleFactor = (int)backingScaleFactor;
|
||||
|
||||
int i = 0;
|
||||
foreach (SparklePlugin plugin in plugins) {
|
||||
Items.Add (plugin);
|
||||
|
@ -815,7 +818,22 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
} else {
|
||||
return new NSImage ((Items [row_index] as SparklePlugin).ImagePath) {
|
||||
var plugin = (SparklePlugin)Items [row_index];
|
||||
var path = plugin.ImagePath;
|
||||
|
||||
if (backingScaleFactor >= 2) {
|
||||
var hi_path = String.Format ("{0}@{1}x{2}",
|
||||
Path.Combine (Path.GetDirectoryName (path), Path.GetFileNameWithoutExtension (path)),
|
||||
backingScaleFactor,
|
||||
Path.GetExtension (path)
|
||||
);
|
||||
|
||||
if (File.Exists (hi_path)) {
|
||||
path = hi_path;
|
||||
}
|
||||
}
|
||||
|
||||
return new NSImage (path) {
|
||||
Size = new SizeF (24, 24)
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue