/*
 * @file llpanelenvironmenttools.h
 * @brief Environment tools
 *
 * Copyright (c) 2016, Cinder Roxley <cinder@sdf.org>
 *
 * Permission is hereby granted, free of charge, to any person or organization
 * obtaining a copy of the software and accompanying documentation covered by
 * this license (the "Software") to use, reproduce, display, distribute,
 * execute, and transmit the Software, and to prepare derivative works of the
 * Software, and to permit third-parties to whom the Software is furnished to
 * do so, all subject to the following:
 *
 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer,
 * must be included in all copies of the Software, in whole or in part, and
 * all derivative works of the Software, unless such copies or derivative
 * works are solely in the form of machine-executable object code generated by
 * a source language processor.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef LL_PANELENVIRONMENTTOOLS_H
#define LL_PANELENVIRONMENTTOOLS_H

#include "llpanel.h"

class LLColorSwatchCtrl;
class LLComboBox;
class LLMultiSliderCtrl;
class LLSliderCtrl;
class LLTextureCtrl;
class LLUICtrl;
class LLWLParamManager;
struct LLWLParamKey;

struct WaterColorControl;
struct WaterVector3Control;
struct WaterVector2Control;
struct WaterFloatControl;
struct WaterExpFloatControl;

class LLPanelEnvironmentTools : public LLPanel
{
public:
	LLPanelEnvironmentTools();
	
	BOOL postBuild() override;
	void draw() override;
	
private:
	~LLPanelEnvironmentTools() {}
	
	void initSkyCallbacks();
	void initWaterCallbacks();
	
	void syncTimeSlider(LLWLParamManager& param_mgr);
	void syncSkyProperties(LLWLParamManager& param_mgr);
	void syncAtmosphericProperties(LLWLParamManager& param_mgr);
	void syncCloudProperties(LLWLParamManager& param_mgr);
	void syncWaterProperties();
	LLWLParamKey getSelectedPreset(const LLSD& userdata);
	
	// callbacks
	void refreshSkyPresetList();
	void refreshDayCycleList();
	void refreshWaterPresetList();
	
	void onSunMoved();
	void onSetAmbientColor();
	void onSetSunlightColor();
	void onSetCloudColor();
	void onSetBlueHorizonColor();
	void onSetBlueDensityColor();
	void onSetWaterFogColor();
	void onWaterNormalMapPicked();
	void onFloatControlMoved(LLUICtrl* ctrl, void* userdata);
	void onColorControlRMoved(LLUICtrl* ctrl, void* userdata);
	void onColorControlGMoved(LLUICtrl* ctrl, void* userdata);
	void onColorControlBMoved(LLUICtrl* ctrl, void* userdata);
	void onGlowMoved(LLUICtrl* ctrl, void* userdata);
	void onStarAlphaMoved(LLUICtrl* ctrl);
	void onCloudScrollXMoved(LLUICtrl* ctrl);
	void onCloudScrollYMoved(LLUICtrl* ctrl);
	void onCloudScrollXToggled(LLUICtrl* ctrl);
	void onCloudScrollYToggled(LLUICtrl* ctrl);
	void onSetDayCycle(const LLSD& userdata);
	void onSetSkyPreset(const LLSD& userdata);
	void onSetWaterCycle(const LLSD& userdata);
	void onDayCycleSelected(const LLSD& userdata);
	void onSkyPresetSelected(const LLSD& userdata);
	void onWaterPresetSelected(const LLSD& userdata);
	
	//void onWaterColorControlRMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl);
	//void onWaterColorControlGMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl);
	//void onWaterColorControlBMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl);
	//void onWaterColorControlAMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl);
	//void onWaterColorControlIMoved(LLUICtrl* ctrl, WaterColorControl* color_ctrl);
	void onVector3ControlXMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl);
	void onVector3ControlYMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl);
	void onVector3ControlZMoved(LLUICtrl* ctrl, WaterVector3Control* vector_ctrl);
	void onVector2ControlXMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl);
	void onVector2ControlYMoved(LLUICtrl* ctrl, WaterVector2Control* vector_ctrl);
	void onWaterFloatControlMoved(LLUICtrl* ctrl, WaterFloatControl* floatControl);
	void onExpFloatControlMoved(LLUICtrl* ctrl, WaterExpFloatControl* expFloatControl);
	
	LLComboBox* mDayCyclesCombo;
	LLComboBox* mSkyPresetsCombo;
	LLComboBox* mWaterPresetsCombo;
	LLMultiSliderCtrl* mSunPos;
	//LLSliderCtrl* mEastAngle;
	LLColorSwatchCtrl* mSunlightSwatch;
	LLColorSwatchCtrl* mAmbientSwatch;
	LLColorSwatchCtrl* mBlueDensitySwatch;
	LLColorSwatchCtrl* mBlueHorizonSwatch;
	LLColorSwatchCtrl* mCloudColorSwatch;
	LLColorSwatchCtrl* mWaterFogSwatch;
	LLTextureCtrl* mWaterNormalCtrl;
	LLSliderCtrl* mSunSizeCtrl;
	LLSliderCtrl* mSunFocusCtrl;
	LLSliderCtrl* mStarBrightnessCtrl;
	LLSliderCtrl* mGammaCtrl;
};

#endif // LL_PANELENVIRONMENTTOOLS_H
