Line data Source code
1 : /** 2 : Copyright (c) 2024 Stappler LLC <admin@stappler.dev> 3 : 4 : Permission is hereby granted, free of charge, to any person obtaining a copy 5 : of this software and associated documentation files (the "Software"), to deal 6 : in the Software without restriction, including without limitation the rights 7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 : copies of the Software, and to permit persons to whom the Software is 9 : furnished to do so, subject to the following conditions: 10 : 11 : The above copyright notice and this permission notice shall be included in 12 : all copies or substantial portions of the Software. 13 : 14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 : THE SOFTWARE. 21 : **/ 22 : 23 : #include "MaterialScene.h" 24 : #include "XL2dSceneContent.h" 25 : #include "XL2dSceneLight.h" 26 : 27 : namespace STAPPLER_VERSIONIZED stappler::xenolith::material2d { 28 : 29 10 : void Scene::addContentNodes(SceneContent *content) { 30 10 : Scene2d::addContentNodes(content); 31 : 32 10 : _styleContainer = content->addComponent(Rc<material2d::StyleContainer>::create()); 33 10 : _styleContainer->setPrimaryScheme(material2d::ThemeType::LightTheme, Color::Teal_500.asColor4F(), false); 34 : 35 10 : _surfaceInterior = content->addComponent(Rc<material2d::SurfaceInterior>::create(material2d::SurfaceStyle( 36 0 : material2d::ColorRole::Background, 37 0 : material2d::NodeStyle::SurfaceTonal, 38 10 : material2d::Elevation::Level0 39 : ))); 40 : 41 10 : if (auto c2d = dynamic_cast<SceneContent2d *>(content)) { 42 : // standart material light model 43 : 44 10 : auto color = Color4F::WHITE; 45 10 : color.a = 0.5f; 46 : 47 10 : auto light = Rc<basic2d::SceneLight>::create(basic2d::SceneLightType::Ambient, Vec2(0.0f, 0.3f), 1.5f, color); 48 10 : auto ambient = Rc<basic2d::SceneLight>::create(basic2d::SceneLightType::Ambient, Vec2(0.0f, 0.0f), 1.5f, color); 49 : 50 10 : c2d->setGlobalLight(Color4F::WHITE); 51 10 : c2d->removeAllLights(); 52 10 : c2d->addLight(move(light)); 53 10 : c2d->addLight(move(ambient)); 54 10 : } 55 10 : } 56 : 57 : }