From ea2aee5044f8e2b3f7acba64a8df91128d48045a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 14 Aug 2019 15:04:40 -0500 Subject: [PATCH] utilzing new argb --- .../spark/view/Controls/DIYGrid/Columns/ColumnBase.cs | 2 +- .../view/Controls/DIYGrid/Settings/GridSettingsManager.cs | 4 ++-- .../view/Controls/DIYGrid/Settings/GridSettingsVM.cs | 6 ++++-- .../DIYGrid/Settings/SimpleGridSettingsManager.cs | 4 ++-- .../Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs | 8 +++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 062e17c68..51596963c 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -186,7 +186,7 @@ namespace mbts.ui.controls { var gs = GridSettings.Default; _fallback_font_weight = gs.font_weight; _fallback_font_color = gs.font_color.rgb_color(); - _fallback_background_color = gs.background_color.value; + _fallback_background_color = gs.background_color.argb; _fallback_font_size = gs.font_size; _fallback_font_family = new FontFamily(gs.font_family); original_width = double.NaN; diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 8cf976235..bdf1e64f9 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -77,7 +77,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); } public void Dispose() => @@ -114,7 +114,7 @@ namespace mbts.ui { var grid = value.general ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); foreach (var pa in _predicate_animations_data) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 539c17e36..cd3bea93a 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -132,7 +132,9 @@ 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.to_proto(), col_settings, background_color: new NullableColorProto(background_color.color.rgb_color())), + return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings, + background_color: new NullableColorProto(background_color.color + .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))), 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) => @@ -145,7 +147,7 @@ namespace mbts.spark { font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); if (sd.general.background_color.value.HasValue) { - background_color.load_from(sd.general.background_color.value.Value.to_solid_brush()); + background_color.load_from(sd.general.background_color.argb.Value.to_solid_brush()); } _font_size.set(sd.general.font_size); var col_animations = new Dictionary>>(); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs index 0a002ac62..50a1cf7f7 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsManager.cs @@ -35,7 +35,7 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _background_color = backing(nameof(background_color), () => grid_settings.background_color.value?.rgb_color().rgb_solid_brush().frozen(), nameof(grid_settings)); + _background_color = backing(nameof(background_color), () => grid_settings.background_color.argb?.to_solid_brush().frozen(), nameof(grid_settings)); _row_vms = row_vms; } @@ -88,7 +88,7 @@ namespace mbts.ui { grid = grid ?? GridSettings.Default; _grid_settings.set(grid); foreach (ColumnBase col in _columns) - col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.value); + col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight, grid.background_color.argb); // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** if (grid_settings.columns != null) { diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs index 5c01ac440..f5945e1bd 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsVM.cs @@ -106,7 +106,9 @@ namespace mbts.spark { } public GridSettings create() => - new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), background_color: new NullableColorProto(background_color.color.rgb_color())); + new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), columns.Select(c => c.create()), + background_color: new NullableColorProto(background_color.color + .with((byte)(MathUtils.within_range(0, 1, background_color.opacity) * 255.0)))); public void load_from(GridSettings value) { if (value == null) @@ -116,8 +118,8 @@ namespace mbts.spark { _font_weight.set(value.font_weight); font_color.load_from(value.font_color.rgb_solid_brush()); selection_highlight.load_from(value.selection_highlight.to_brush()); - if (value.background_color.value.HasValue) { - background_color.load_from(value.background_color.value.Value.to_solid_brush()); + if (value.background_color.argb.HasValue) { + background_color.load_from(value.background_color.argb.Value.to_solid_brush()); } _font_size.set(value.font_size); var curr_col_id = current_column?.id;