1 2 // 3 // This source file is part of appleseed. 4 // Visit https://appleseedhq.net/ for additional information and resources. 5 // 6 // This software is released under the MIT license. 7 // 8 // Copyright (c) 2014-2018 Marius Avram, The appleseedhq Organization 9 // 10 // Permission is hereby granted, free of charge, to any person obtaining a copy 11 // of this software and associated documentation files (the "Software"), to deal 12 // in the Software without restriction, including without limitation the rights 13 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 // copies of the Software, and to permit persons to whom the Software is 15 // furnished to do so, subject to the following conditions: 16 // 17 // The above copyright notice and this permission notice shall be included in 18 // all copies or substantial portions of the Software. 19 // 20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 // THE SOFTWARE. 27 // 28 29 #pragma once 30 31 // appleseed.studio headers. 32 #include "utility/inputwidgetproxies.h" 33 34 // appleseed.foundation headers. 35 #include "foundation/platform/compiler.h" 36 #include "foundation/utility/api/specializedapiarrays.h" 37 38 // Qt headers. 39 #include <QFrame> 40 #include <QIcon> 41 #include <QObject> 42 43 // Standard headers. 44 #include <memory> 45 #include <string> 46 47 // Forward declarations. 48 namespace foundation { class Dictionary; } 49 namespace renderer { class ParamArray; } 50 namespace renderer { class Project; } 51 class QColor; 52 class QFormLayout; 53 class QMouseEvent; 54 class QString; 55 class QToolButton; 56 class QWidget; 57 58 namespace appleseed { 59 namespace studio { 60 61 class DisneyMaterialLayerUI 62 : public QFrame 63 { 64 Q_OBJECT 65 66 public: 67 DisneyMaterialLayerUI( 68 QWidget* parent, 69 const renderer::Project& project, 70 renderer::ParamArray& settings, 71 const foundation::Dictionary& values); 72 73 foundation::Dictionary get_values() const; 74 75 void mouseDoubleClickEvent(QMouseEvent* event) override; 76 77 signals: 78 void signal_move_layer_up(QWidget* layer_widget); 79 void signal_move_layer_down(QWidget* layer_widget); 80 void signal_delete_layer(QWidget* layer_widget); 81 void signal_apply(); 82 83 private slots: 84 void slot_fold_unfold_layer(); 85 void slot_move_layer_up(); 86 void slot_move_layer_down(); 87 void slot_delete_layer(); 88 89 void slot_open_color_picker(const QString& widget_name); 90 void slot_color_changed(const QString& widget_name, const QColor& color); 91 92 void slot_open_file_picker(const QString& widget_name); 93 94 void slot_open_expression_editor(const QString& widget_name); 95 void slot_expression_changed(const QString& widget_name, const QString& expression); 96 97 private: 98 const renderer::Project& m_project; 99 renderer::ParamArray& m_settings; 100 const foundation::DictionaryArray m_input_metadata; 101 102 const QIcon m_fold_icon; 103 const QIcon m_unfold_icon; 104 105 QToolButton* m_fold_unfold_button; 106 QWidget* m_header_widget; 107 QFormLayout* m_header_layout; 108 QWidget* m_content_widget; 109 QFormLayout* m_content_layout; 110 111 InputWidgetProxyCollection m_widget_proxies; 112 113 bool m_is_folded; 114 115 void create_layer_ui(); 116 void create_input_widgets(const foundation::Dictionary& values); 117 118 std::unique_ptr<IInputWidgetProxy> create_text_input_widgets(const foundation::Dictionary& metadata); 119 std::unique_ptr<IInputWidgetProxy> create_color_input_widgets(const foundation::Dictionary& metadata); 120 std::unique_ptr<IInputWidgetProxy> create_colormap_input_widgets(const foundation::Dictionary& metadata); 121 122 QWidget* create_texture_button(const std::string& name); 123 QWidget* create_expression_button(const std::string& name); 124 125 void fold(); 126 void unfold(); 127 }; 128 129 } // namespace studio 130 } // namespace appleseed 131