GridSettingsVM was changing background to black when 'show_background' was false

This commit is contained in:
John Colvin committed 2019-12-05 16:29:18 -06:00
1 parent 3013b9a572
commit 8bc628e481
2 files changed
+19 -2

No files matched your search

@@ -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<OrderBookStartupData> {
@@ -26,6 +27,14 @@ namespace bts.shell {
}
public override Task<IShellWindow> 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<OrderBookGridSettings>(_settings_hub, state.grid_settings_wrapper(),
us => us.order_book_grid ?? OrderBookStartupData.DefaultGrid,
(us, s) => us.with(order_book_grid: s));
@@ -134,8 +134,16 @@ namespace mbts.spark {
foreach (IGrouping<TPredicateData, CellAnimation> 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<TRowData, TPredicateData>(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds)));
//
(List<RowAnimation> row_animations, List<SoundNotification> sounds, List<CellAnimation> cell_animations) animation_tuple(IEnumerable<RowAnimation> r = null, IEnumerable<SoundNotification> s = null, IGrouping<TPredicateData, CellAnimation> c = null) =>