diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a34ae8..3f6c960 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.3) project(hdrview) -set(HDRVIEW_VERSION "1.0.1") +set(HDRVIEW_VERSION "1.0.2") # Set ourselves as the startup project in visual studio. # Not available until cmake 3.6, but doesn't break older versions. @@ -299,4 +299,4 @@ if (CMAKE_GENERATOR STREQUAL "Ninja") endif() target_compile_features(HDRView PRIVATE cxx_std_17) -target_compile_features(hdrbatch PRIVATE cxx_std_17) \ No newline at end of file +target_compile_features(hdrbatch PRIVATE cxx_std_17) diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index b5931da..aa1ba2c 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -166,7 +166,7 @@ if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGL_SILENCE_DEPRECATION=1") endif() # set(NANOGUI_BACKEND "OpenGL" CACHE BOOL " " FORCE) -set(NANOGUI_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) +set(NANOGUI_BUILD_EXAMPLES OFF CACHE BOOL " ") set(NANOGUI_BUILD_SHARED OFF CACHE BOOL " " FORCE) set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE) add_subdirectory(nanogui) diff --git a/src/editimagepanel.cpp b/src/editimagepanel.cpp index ea7b1f7..9ca2455 100644 --- a/src/editimagepanel.cpp +++ b/src/editimagepanel.cpp @@ -85,6 +85,127 @@ void add_ok_cancel_btns(FormHelper * gui, Window * window, gui->add_widget("", w); } +PopupButton * create_color_btn(FormHelper * gui, Window * window, const string name, Color & bg, float & alpha, float & EV) +{ + // auto popup_btn = new ColorPicker(window, Color(bg.r(), bg.g(), bg.b(), alpha)); + // gui->add_widget(name, popup_btn); + + auto popup_btn = new PopupButton(window, "", 0); + popup_btn->set_background_color(Color(bg.r(), bg.g(), bg.b(), alpha)); + gui->add_widget(name, popup_btn); + + auto popup = popup_btn->popup(); + popup->set_layout(new GroupLayout()); + + auto colorwheel = new ColorWheel(popup); + colorwheel->set_color(Color(bg.r(), bg.g(), bg.b(), alpha)); + + auto panel = new Widget(popup); + // panel->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 0)); + auto agrid = new AdvancedGridLayout({0, 20, 0}, {}); + agrid->set_margin(0); + agrid->set_col_stretch(1, 1); + panel->set_layout(agrid); + + auto color_btn = new Button(popup, "Pick"); + + // + // opacity + // + + agrid->append_row(0); + agrid->set_anchor(new Label(panel, "Opacity:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); + + auto float_box = new FloatBox(panel, alpha * 100.0f); + agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); + float_box->set_units("%"); + float_box->number_format("%3.1f"); + float_box->set_editable(true); + float_box->set_min_value(0.f); + float_box->set_max_value(100.f); + float_box->set_spinnable(true); + float_box->set_fixed_width(60); + float_box->set_alignment(TextBox::Alignment::Right); + + agrid->append_row(0); + auto slider = new Slider(panel); + agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); + slider->set_value(alpha * 100.0f); + slider->set_range({0.0f,100.0f}); + + slider->set_callback([float_box,color_btn,&bg,&alpha,&EV](float a) { + alpha = a / 100.f; + float_box->set_value(a); + float f = pow(2.f, EV); + color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + }); + + float_box->set_callback([slider,color_btn,&bg,&alpha,&EV](float a) { + alpha = a / 100.f; + slider->set_value(a); + float f = pow(2.f, EV); + color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + }); + + agrid->append_row(10); + + // + // EV + // + agrid->append_row(0); + agrid->set_anchor(new Label(panel, "EV:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); + + float_box = new FloatBox(panel, 0.f); + agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); + float_box->number_format("%1.2f"); + float_box->set_editable(true); + float_box->set_spinnable(true); + float_box->set_fixed_width(60); + float_box->set_alignment(TextBox::Alignment::Right); + + agrid->append_row(0); + slider = new Slider(panel); + agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); + slider->set_value(0.0f); + slider->set_range({-9.0f,9.0f}); + + slider->set_callback([float_box,color_btn,&bg,&alpha,&EV](float ev) { + EV = ev; + float_box->set_value(EV); + float f = pow(2.f, EV); + color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + }); + + float_box->set_callback([slider,color_btn,&bg,&alpha,&EV](float ev) { + EV = ev; + slider->set_value(EV); + float f = pow(2.f, EV); + color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + }); + + + color_btn->set_background_color(Color(bg.r() * pow(2.f, EV), bg.g() * pow(2.f, EV), bg.b() * pow(2.f, EV), alpha)); + + colorwheel->set_callback([color_btn,&bg,&alpha,&EV](const Color &c) { + bg.r() = c.r(); + bg.g() = c.g(); + bg.b() = c.b(); + float f = pow(2.f, EV); + color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + }); + + color_btn->set_change_callback([popup_btn,&bg,&alpha,&EV](bool pushed) { + if (pushed) + { + float f = pow(2.f, EV); + popup_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); + popup_btn->set_pushed(false); + } + }); + + return popup_btn; +} + Button * create_colorspace_btn(Widget *parent, HDRViewScreen * screen, ImageListPanel * images_panel) { static string name = "Convert color space..."; @@ -301,15 +422,15 @@ Button * create_brightness_constract_btn(Widget *parent, HDRViewScreen * screen, }); add_ok_cancel_btns(gui, window, - [&]() - { - images_panel->modify_image( - [&](const shared_ptr &img) -> ImageCommandResult - { - return {make_shared(img->brightness_contrast(brightness, contrast, linear, channelMap[channel])), - nullptr}; - }); - }); + [&]() + { + images_panel->modify_image( + [&](const shared_ptr &img) -> ImageCommandResult + { + return {make_shared(img->brightness_contrast(brightness, contrast, linear, channelMap[channel])), + nullptr}; + }); + }); window->center(); window->request_focus(); @@ -478,19 +599,19 @@ Button * create_hsl_btn(Widget *parent, HDRViewScreen * screen, ImageListPanel * gui->add_widget("", dynamicRainbow); add_ok_cancel_btns(gui, window, - [&]() - { - images_panel->modify_image( - [&](const shared_ptr &img) -> ImageCommandResult - { - return {make_shared( - img->unaryExpr( - [](const Color4 & c) - { - return c.HSLAdjust(hue, (saturation+100.f)/100.f, (lightness)/100.f); - }).eval()), nullptr}; - }); - }); + [&]() + { + images_panel->modify_image( + [&](const shared_ptr &img) -> ImageCommandResult + { + return {make_shared( + img->unaryExpr( + [](const Color4 & c) + { + return c.HSLAdjust(hue, (saturation+100.f)/100.f, (lightness)/100.f); + }).eval()), nullptr}; + }); + }); window->center(); window->request_focus(); @@ -1083,7 +1204,7 @@ Button * create_canvas_size_btn(Widget *parent, HDRViewScreen * screen, ImageLis gui->set_fixed_size(Vector2i(75, 20)); auto window = gui->add_window(Vector2i(10, 10), name); - window->set_modal(true); + // window->set_modal(true); width = images_panel->current_image()->width(); auto w = gui->add_variable("Width:", width); @@ -1133,118 +1254,9 @@ Button * create_canvas_size_btn(Widget *parent, HDRViewScreen * screen, ImageLis spacer->set_fixed_height(5); gui->add_widget("", spacer); - auto popup_btn = new PopupButton(window, "", 0); - popup_btn->set_background_color(Color(bg.r(), bg.g(), bg.b(), alpha)); - gui->add_widget("Extension color:", popup_btn); - + auto popup_btn = create_color_btn(gui, window, "Background color:", bg, alpha, EV); auto popup = popup_btn->popup(); - popup->set_layout(new GroupLayout()); - - auto colorwheel = new ColorWheel(popup); - colorwheel->set_color(Color(bg.r(), bg.g(), bg.b(), alpha)); - - auto panel = new Widget(popup); -// panel->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 0)); - auto agrid = new AdvancedGridLayout({0, 20, 0}, {}); - agrid->set_margin(0); - agrid->set_col_stretch(1, 1); - panel->set_layout(agrid); - - auto color_btn = new Button(popup, "Pick"); - - // - // opacity - // - - agrid->append_row(0); - agrid->set_anchor(new Label(panel, "Opacity:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); - - auto float_box = new FloatBox(panel, alpha * 100.0f); - agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); - float_box->set_units("%"); - float_box->number_format("%3.1f"); - float_box->set_editable(true); - float_box->set_min_value(0.f); - float_box->set_max_value(100.f); - float_box->set_spinnable(true); - float_box->set_fixed_width(60); - float_box->set_alignment(TextBox::Alignment::Right); - - agrid->append_row(0); - auto slider = new Slider(panel); - agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); - slider->set_value(alpha * 100.0f); - slider->set_range({0.0f,100.0f}); - - slider->set_callback([float_box,color_btn](float a) { - alpha = a / 100.f; - float_box->set_value(a); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - float_box->set_callback([slider,color_btn](float a) { - alpha = a / 100.f; - slider->set_value(a); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - agrid->append_row(10); - - // - // EV - // - agrid->append_row(0); - agrid->set_anchor(new Label(panel, "EV:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); - - float_box = new FloatBox(panel, 0.f); - agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); - float_box->number_format("%1.2f"); - float_box->set_editable(true); - float_box->set_spinnable(true); - float_box->set_fixed_width(60); - float_box->set_alignment(TextBox::Alignment::Right); - - agrid->append_row(0); - slider = new Slider(panel); - agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); - slider->set_value(0.0f); - slider->set_range({-9.0f,9.0f}); - - slider->set_callback([float_box,color_btn](float ev) { - EV = ev; - float_box->set_value(EV); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - float_box->set_callback([slider,color_btn](float ev) { - EV = ev; - slider->set_value(EV); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - - color_btn->set_background_color(Color(bg.r() * pow(2.f, EV), bg.g() * pow(2.f, EV), bg.b() * pow(2.f, EV), alpha)); - - colorwheel->set_callback([color_btn](const Color &c) { - bg.r() = c.r(); - bg.g() = c.g(); - bg.b() = c.b(); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - color_btn->set_change_callback([popup_btn](bool pushed) { - if (pushed) - { - float f = pow(2.f, EV); - popup_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - popup_btn->set_pushed(false); - } - }); + screen->request_layout_update(); add_ok_cancel_btns(gui, window, [&, popup]() @@ -1577,118 +1589,9 @@ Button * create_flatten_btn(Widget *parent, HDRViewScreen * screen, ImageListPan auto window = gui->add_window(Vector2i(10, 10), name); window->set_modal(true); - auto popup_btn = new PopupButton(window, "", 0); - popup_btn->set_background_color(Color(bg.r(), bg.g(), bg.b(), alpha)); - gui->add_widget("Background color:", popup_btn); - + auto popup_btn = create_color_btn(gui, window, "Background color:", bg, alpha, EV); auto popup = popup_btn->popup(); - popup->set_layout(new GroupLayout()); - - auto colorwheel = new ColorWheel(popup); - colorwheel->set_color(Color(bg.r(), bg.g(), bg.b(), alpha)); - - auto panel = new Widget(popup); -// panel->set_layout(new GridLayout(Orientation::Horizontal, 3, Alignment::Fill, 0, 0)); - auto agrid = new AdvancedGridLayout({0, 20, 0}, {}); - agrid->set_margin(0); - agrid->set_col_stretch(1, 1); - panel->set_layout(agrid); - - auto color_btn = new Button(popup, "Pick"); - - // - // opacity - // - - agrid->append_row(0); - agrid->set_anchor(new Label(panel, "Opacity:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); - - auto float_box = new FloatBox(panel, alpha * 100.0f); - agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); - float_box->set_units("%"); - float_box->number_format("%3.1f"); - float_box->set_editable(true); - float_box->set_min_value(0.f); - float_box->set_max_value(100.f); - float_box->set_spinnable(true); - float_box->set_fixed_width(60); - float_box->set_alignment(TextBox::Alignment::Right); - - agrid->append_row(0); - auto slider = new Slider(panel); - agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); - slider->set_value(alpha * 100.0f); - slider->set_range({0.0f,100.0f}); - - slider->set_callback([float_box,color_btn](float a) { - alpha = a / 100.f; - float_box->set_value(a); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - float_box->set_callback([slider,color_btn](float a) { - alpha = a / 100.f; - slider->set_value(a); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - agrid->append_row(10); - - // - // EV - // - agrid->append_row(0); - agrid->set_anchor(new Label(panel, "EV:"), AdvancedGridLayout::Anchor(0, agrid->row_count()-1)); - - float_box = new FloatBox(panel, 0.f); - agrid->set_anchor(float_box, AdvancedGridLayout::Anchor(2, agrid->row_count()-1)); - float_box->number_format("%1.2f"); - float_box->set_editable(true); - float_box->set_spinnable(true); - float_box->set_fixed_width(60); - float_box->set_alignment(TextBox::Alignment::Right); - - agrid->append_row(0); - slider = new Slider(panel); - agrid->set_anchor(slider, AdvancedGridLayout::Anchor(0, agrid->row_count()-1, 3, 1)); - slider->set_value(0.0f); - slider->set_range({-9.0f,9.0f}); - - slider->set_callback([float_box,color_btn](float ev) { - EV = ev; - float_box->set_value(EV); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - float_box->set_callback([slider,color_btn](float ev) { - EV = ev; - slider->set_value(EV); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - - color_btn->set_background_color(Color(bg.r() * pow(2.f, EV), bg.g() * pow(2.f, EV), bg.b() * pow(2.f, EV), alpha)); - - colorwheel->set_callback([color_btn](const Color &c) { - bg.r() = c.r(); - bg.g() = c.g(); - bg.b() = c.b(); - float f = pow(2.f, EV); - color_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - }); - - color_btn->set_change_callback([popup_btn](bool pushed) { - if (pushed) - { - float f = pow(2.f, EV); - popup_btn->set_background_color(Color(bg.r() * f, bg.g() * f, bg.b() * f, alpha)); - popup_btn->set_pushed(false); - } - }); + screen->request_layout_update(); add_ok_cancel_btns(gui, window, [&, popup]()