Change how histogram RGB indicators are rendered

Show/hide them instead of removing/adding and fix the width of the
vertical indicator.
This commit is contained in:
Lawrence Lee
2020-10-10 15:15:28 -07:00
parent ee1c85879d
commit 992a5ad3d9

View File

@@ -73,11 +73,9 @@ HistogramPanel::HistogramPanel () :
histogramRGBAreaHori.reset(new HistogramRGBAreaHori()); histogramRGBAreaHori.reset(new HistogramRGBAreaHori());
setExpandAlignProperties(histogramRGBAreaHori.get(), true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_END); setExpandAlignProperties(histogramRGBAreaHori.get(), true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_END);
histogramRGBAreaHori->show();
histogramRGBAreaVert.reset(new HistogramRGBAreaVert()); histogramRGBAreaVert.reset(new HistogramRGBAreaVert());
setExpandAlignProperties(histogramRGBAreaVert.get(), false, true, Gtk::ALIGN_END, Gtk::ALIGN_FILL); setExpandAlignProperties(histogramRGBAreaVert.get(), false, true, Gtk::ALIGN_END, Gtk::ALIGN_FILL);
histogramRGBAreaVert->show();
switch (options.histogramScopeType) { switch (options.histogramScopeType) {
case ScopeType::NONE: case ScopeType::NONE:
@@ -102,13 +100,14 @@ HistogramPanel::HistogramPanel () :
gfxGrid = Gtk::manage (new Gtk::Grid ()); gfxGrid = Gtk::manage (new Gtk::Grid ());
gfxGrid->set_row_spacing(1); gfxGrid->set_row_spacing(1);
gfxGrid->set_column_spacing(1); gfxGrid->set_column_spacing(1);
histogramRGBAreaHori->setParent(gfxGrid);
histogramRGBAreaVert->setParent(gfxGrid);
gfxGrid->add(*histogramArea); gfxGrid->add(*histogramArea);
gfxGrid->attach_next_to(
if (options.histogramBar) { *histogramRGBAreaVert, *histogramArea,
showRGBBar(); options.histogramPosition == 1 ? Gtk::POS_RIGHT : Gtk::POS_LEFT
} );
gfxGrid->attach_next_to(*histogramRGBAreaHori, *histogramArea, Gtk::POS_BOTTOM);
histogramRGBAreaHori->set_no_show_all();
histogramRGBAreaVert->set_no_show_all();
redImage = new RTImage ("histogram-red-on-small.png"); redImage = new RTImage ("histogram-red-on-small.png");
greenImage = new RTImage ("histogram-green-on-small.png"); greenImage = new RTImage ("histogram-green-on-small.png");
@@ -379,26 +378,19 @@ HistogramPanel::~HistogramPanel ()
void HistogramPanel::showRGBBar() void HistogramPanel::showRGBBar()
{ {
Gtk::PositionType pos; histogramRGBAreaHori->set_visible(
histogramRGBArea == histogramRGBAreaHori.get() && showBAR->get_active());
histogramRGBAreaVert->set_visible(
histogramRGBArea == histogramRGBAreaVert.get() && showBAR->get_active());
histogramRGBAreaHori->setShow(false);
histogramRGBAreaVert->setShow(false);
if (histogramRGBArea == histogramRGBAreaHori.get()) { if (!histogramRGBArea) {
pos = Gtk::POS_BOTTOM;
} else if (histogramRGBArea == nullptr) {
return; return;
} else {
if (options.histogramPosition == 1) {
pos = Gtk::POS_RIGHT;
} else {
pos = Gtk::POS_LEFT;
}
} }
gfxGrid->attach_next_to(*histogramRGBArea, *histogramArea, pos);
setHistRGBInvalid(); setHistRGBInvalid();
histogramRGBArea->setShow( histogramRGBArea->setShow(showBAR->get_active());
options.histogramScopeType == ScopeType::HISTOGRAM
|| options.histogramScopeType == ScopeType::WAVEFORM
);
} }
void HistogramPanel::resized (Gtk::Allocation& req) void HistogramPanel::resized (Gtk::Allocation& req)
@@ -510,11 +502,6 @@ void HistogramPanel::type_selected(Gtk::RadioButton* button)
void HistogramPanel::type_changed() void HistogramPanel::type_changed()
{ {
if (showBAR->get_active() && histogramRGBArea) {
histogramRGBArea->setShow(false);
gfxGrid->remove(*histogramRGBArea);
}
switch (options.histogramScopeType) { switch (options.histogramScopeType) {
case ScopeType::HISTOGRAM: case ScopeType::HISTOGRAM:
showRed->show(); showRed->show();
@@ -570,21 +557,14 @@ void HistogramPanel::type_changed()
panel_listener->scopeTypeChanged(options.histogramScopeType); panel_listener->scopeTypeChanged(options.histogramScopeType);
} }
if (showBAR->get_active()) {
showRGBBar(); showRGBBar();
}
} }
void HistogramPanel::bar_toggled () void HistogramPanel::bar_toggled ()
{ {
showBAR->set_image(showBAR->get_active() ? *barImage : *barImage_g); showBAR->set_image(showBAR->get_active() ? *barImage : *barImage_g);
rgbv_toggled(); rgbv_toggled();
if (showBAR->get_active()) {
showRGBBar(); showRGBBar();
} else if (histogramRGBArea) {
gfxGrid->remove(*histogramRGBArea);
}
} }
void HistogramPanel::rgbv_toggled () void HistogramPanel::rgbv_toggled ()
@@ -625,10 +605,8 @@ void HistogramPanel::reorder (Gtk::PositionType align)
add (*gfxGrid); add (*gfxGrid);
gfxGrid->unreference(); gfxGrid->unreference();
if (histogramRGBArea == histogramRGBAreaVert.get()) { gfxGrid->remove(*histogramRGBAreaVert);
gfxGrid->remove(*histogramRGBArea); gfxGrid->add(*histogramRGBAreaVert);
gfxGrid->add(*histogramRGBArea);
}
optionButtons->reference(); optionButtons->reference();
removeIfThere(buttonGrid, optionButtons, false); removeIfThere(buttonGrid, optionButtons, false);
@@ -640,10 +618,8 @@ void HistogramPanel::reorder (Gtk::PositionType align)
add (*buttonGrid); add (*buttonGrid);
buttonGrid->unreference(); buttonGrid->unreference();
if (histogramRGBArea == histogramRGBAreaVert.get()) { gfxGrid->remove(*histogramRGBAreaVert);
gfxGrid->remove(*histogramArea); gfxGrid->attach_next_to(*histogramRGBAreaVert, *histogramArea, Gtk::POS_LEFT);
gfxGrid->add(*histogramArea);
}
persistentButtons->reference(); persistentButtons->reference();
removeIfThere(buttonGrid, persistentButtons, false); removeIfThere(buttonGrid, persistentButtons, false);
@@ -1021,7 +997,8 @@ void HistogramRGBAreaVert::get_preferred_height_vfunc (int &minimum_height, int
void HistogramRGBAreaVert::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const void HistogramRGBAreaVert::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const
{ {
getPreferredThickness(minimum_width, natural_width); minimum_width = 10 * RTScalable::getScale();
natural_width = minimum_width;
} }
void HistogramRGBAreaVert::get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const void HistogramRGBAreaVert::get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const
@@ -1031,7 +1008,7 @@ void HistogramRGBAreaVert::get_preferred_height_for_width_vfunc (int width, int
void HistogramRGBAreaVert::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const void HistogramRGBAreaVert::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const
{ {
getPreferredThicknessForLength(height, minimum_width, natural_width); get_preferred_width_vfunc(minimum_width, natural_width);
} }
// //