From 8bc628e481fb90e3c7606ebee8f216f953d3fc84 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 4 Dec 2019 16:50:18 -0600 Subject: [PATCH] GridSettingsVM was changing background to black when 'show_background' was false --- .../Trading/OrderBook/OrderBookWindowFactory.cs | 9 +++++++++ .../view/Controls/DIYGrid/Settings/GridSettingsVM.cs | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs index f1ac4429a..0f3862f0e 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs @@ -7,6 +7,7 @@ using mbts.ui; using System; using System.Reactive.Linq; using System.Threading.Tasks; +using System.Windows.Media; namespace bts.shell { internal class OrderBookWindowFactory : ShellWindowFactory { @@ -26,6 +27,14 @@ namespace bts.shell { } public override Task load(OrderBookStartupData state) { + // A fairly major grid settings revamp is in the works, + // which will correctly negotiate background color settings as defined at the grid and column level. + // The hack is neccessary bc a previously benign bug (which has been fixed in this 'mview popups' patch) in the GridSettingsVM + // always changed the grid background color to black. + // Fortunately, the bug only affects the OrderBook as other windows use SimpleGridSettingsVM, which does not have such a bug. + if (state != null && !state.orderbook_grid.general.enable_background_color && state.orderbook_grid.general.background_color.argb_color().A > 0) { + state.orderbook_grid.general = state.orderbook_grid.general.with(background: Colors.Transparent.rgb_color()); + } var settings_manager = new WindowSettingsManager(_settings_hub, state.grid_settings_wrapper(), us => us.order_book_grid ?? OrderBookStartupData.DefaultGrid, (us, s) => us.with(order_book_grid: s)); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 1ef68370c..58e6b75d3 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -134,8 +134,16 @@ namespace mbts.spark { foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } - return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.color.rgb_color(), col_settings, - background: background_color.color.with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)).rgb_color()), + var gs = new GridSettings( + font_family.name(), + font_size, + font_weight, + font_color.color.rgb_color(), + selection_highlight.color.rgb_color(), + col_settings); + if (show_background_color) + gs = gs.with(background: background_color.color.rgb_color()); + return _create_settings_obj(gs, animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) =>