private void HandleColorPanelButtonPressEvent(object sender, ButtonPressEventArgs args) { if (args.Event.Type != Gdk.EventType.TwoButtonPress) { return; } Gtk.ColorSelectionDialog csd = new Gtk.ColorSelectionDialog("Choose Color"); ColorPanelWidget panel = (ColorPanelWidget)sender; csd.ColorSelection.PreviousColor = panel.CairoColor.ToGdkColor(); csd.ColorSelection.CurrentColor = panel.CairoColor.ToGdkColor(); csd.ColorSelection.CurrentAlpha = panel.CairoColor.GdkColorAlpha(); int response = csd.Run(); if (response == (int)Gtk.ResponseType.Ok) { ColorBgra col = csd.ColorSelection.CurrentColor.ToBgraColor(); if (panel == colorpanelInLow) { Levels.ColorInLow = col; } else if (panel == colorpanelInHigh) { Levels.ColorInHigh = col; } else if (panel == colorpanelOutLow) { Levels.ColorOutLow = col; // } else if (panel == colorpanelOutMid) { // ColorBgra lo = Levels.ColorInLow; // ColorBgra md = histogramInput.Histogram.GetMeanColor(); // ColorBgra hi = Levels.ColorInHigh; // ColorBgra out_lo = Levels.ColorOutLow; // ColorBgra out_hi = Levels.ColorOutHigh; // // for (int i = 0; i < 3; i++) { // double logA = (col[i] - out_lo[i]) / (out_hi[i] - out_lo[i]); // double logBase = (md[i] - lo[i]) / (hi[i] - lo[i]); // double logVal = (logBase == 1.0) ? 0.0 : Math.Log (logA, logBase); // // Levels.SetGamma(i, (float)Utility.Clamp (logVal, 0.1, 10.0)); // } } else if (panel == colorpanelOutHigh) { Levels.ColorOutHigh = col; } } csd.Destroy(); UpdateFromLevelsOp(); UpdateLevels(); }
private void HandleColorPanelButtonPressEvent(object sender, ButtonPressEventArgs args) { if (args.Event.Type != Gdk.EventType.TwoButtonPress) { return; } ColorPanelWidget panel = (ColorPanelWidget)sender; using (var ccd = new Gtk.ColorChooserDialog(Translations.GetString("Choose Color"), PintaCore.Chrome.MainWindow)) { ccd.UseAlpha = true; ccd.Rgba = panel.CairoColor.ToGdkRGBA(); var response = (Gtk.ResponseType)ccd.Run(); if (response == Gtk.ResponseType.Ok) { ColorBgra col = ccd.Rgba.ToCairoColor().ToGdkColor().ToBgraColor(); if (panel == colorpanelInLow) { Levels.ColorInLow = col; } else if (panel == colorpanelInHigh) { Levels.ColorInHigh = col; } else if (panel == colorpanelOutLow) { Levels.ColorOutLow = col; // } else if (panel == colorpanelOutMid) { // ColorBgra lo = Levels.ColorInLow; // ColorBgra md = histogramInput.Histogram.GetMeanColor(); // ColorBgra hi = Levels.ColorInHigh; // ColorBgra out_lo = Levels.ColorOutLow; // ColorBgra out_hi = Levels.ColorOutHigh; // // for (int i = 0; i < 3; i++) { // double logA = (col[i] - out_lo[i]) / (out_hi[i] - out_lo[i]); // double logBase = (md[i] - lo[i]) / (hi[i] - lo[i]); // double logVal = (logBase == 1.0) ? 0.0 : Math.Log (logA, logBase); // // Levels.SetGamma(i, (float)Utility.Clamp (logVal, 0.1, 10.0)); // } } else if (panel == colorpanelOutHigh) { Levels.ColorOutHigh = col; } } } UpdateFromLevelsOp(); UpdateLevels(); }
private void Build() { const int spacing = 6; Resizable = false; var hboxChecks = new HBox() { Spacing = spacing }; checkRed = new CheckButton(Translations.GetString("Red")) { Active = true }; hboxChecks.PackStart(checkRed, false, false, 0); checkGreen = new CheckButton(Translations.GetString("Green")) { Active = true }; hboxChecks.PackStart(checkGreen, false, false, 0); checkBlue = new CheckButton(Translations.GetString("Blue")) { Active = true }; hboxChecks.PackStart(checkBlue, false, false, 0); buttonReset = new Button() { Label = Translations.GetString("Reset"), WidthRequest = 80 }; buttonAuto = new Button() { Label = Translations.GetString("Auto"), WidthRequest = 80 }; AddActionWidget(buttonAuto, ResponseType.None); AddActionWidget(buttonReset, ResponseType.None); AddActionWidget(hboxChecks, ResponseType.None); var buttons = GtkExtensions.DialogButtonsCancelOk(); AddButton((string)buttons[0], (Gtk.ResponseType)buttons[1]); AddButton((string)buttons[2], (Gtk.ResponseType)buttons[3]); spinInLow = new SpinButton(0, 254, 1); spinInHigh = new SpinButton(1, 255, 1) { Value = 255 }; spinOutLow = new SpinButton(0, 252, 1); spinOutHigh = new SpinButton(2, 255, 1) { Value = 255 }; spinOutGamma = new SpinButton(0, 100, 0.1) { Value = 1 }; gradientInput = new ColorGradientWidget(2) { WidthRequest = 40 }; gradientOutput = new ColorGradientWidget(3) { WidthRequest = 40 }; colorpanelInHigh = new ColorPanelWidget() { HeightRequest = 24 }; colorpanelInLow = new ColorPanelWidget() { HeightRequest = 24 }; colorpanelOutLow = new ColorPanelWidget() { HeightRequest = 24 }; colorpanelOutMid = new ColorPanelWidget() { HeightRequest = 24 }; colorpanelOutHigh = new ColorPanelWidget() { HeightRequest = 24 }; histogramInput = new HistogramWidget() { WidthRequest = 130, FlipHorizontal = true }; histogramOutput = new HistogramWidget() { WidthRequest = 130 }; var hboxLayout = new HBox() { Spacing = spacing, BorderWidth = spacing };