2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "layout-utils.h"
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
24 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
25 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali-toolkit/devel-api/layouting/flex-layout.h>
36 Control CreateLeafControl( int width, int height )
38 auto control = Control::New();
39 control.SetName( "Leaf" );
41 auto pixelBuffer = Devel::PixelBuffer::New( 1, 1, Pixel::RGB888 );
42 unsigned char* pixels = pixelBuffer.GetBuffer();
46 auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGB888, 1, 1 );
47 auto pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
48 texture.Upload( pixelData );
49 std::string url = TextureManager::AddTexture( texture );
52 map[ Visual::Property::TYPE ] = Visual::IMAGE;
53 map[ ImageVisual::Property::URL ] = url;
54 map[ ImageVisual::Property::DESIRED_WIDTH ] = (float) width;
55 map[ ImageVisual::Property::DESIRED_HEIGHT ] = (float) height;
56 control.SetProperty( Control::Property::BACKGROUND, map );
60 } // namespace Toolkit