Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_UI
Rectangle_LumaButton.cpp
Go to the documentation of this file.
1
#include "
Rectangle_LumaButton.hpp
"
2
#include "
LumaText.hpp
"
3
4
namespace
iv
5
{
6
7
Rectangle_LumaButton::Rectangle_LumaButton
(
iv::Instance
* inst,
ResourcePath
const
& icon,
char
const
* label,
LumaStyleId
style_id ) :
8
LumaButton
( inst, style_id ),
9
cm( inst, this,
"Rectangle_LumaButton"
),
10
img_icon( nullptr ),
11
text( nullptr )
12
{
13
this->
cm
.
inherits
( this->
LumaButton::cm
);
14
15
this->
attr_surface
.Set(
ResourcePath
(
"/ivorium_UI/LumaButton/surface.png"
) );
16
17
//-------------------------------------------
18
auto
divider = this->
surface_slot
.
createChild
<
iv::Align
>()
19
->dontExpand(
true
)
20
->
createChild
<
iv::Divider
>()
21
->axis(
Axis::X
)
22
->
axisOrder
(
AxisOrder::Incremental
);
23
24
// icon
25
if
( !icon.
empty
() )
26
{
27
this->img_icon = divider->createChild<
DividerSlot
>()
28
->lowerOrder( 0 )
29
->
createChild
<
iv::Align
>()
30
->keepAspect(
true
)
31
->
createChild
<
iv::Prefsize
>()
32
->prefsizeX( 16 )
33
->
prefsizeY
( 16 )
34
->
createChild
<
iv::Image
>()
35
->filename( icon );
36
}
37
38
// label
39
std::string label_trimmed =
iv::string_trim
( std::string( label ) );
40
if
( !label_trimmed.empty() )
41
{
42
if
( !icon.
empty
() )
43
{
44
divider->createChild<
DividerSlot
>()
45
->lowerOrder( 2 )
46
->
createChild
<
Prefsize
>()
47
->prefsizeX( 4 );
48
}
49
50
this->text = divider->createChild<
DividerSlot
>()
51
->lowerOrder( 1 )
52
->
createChild
<
iv::Border
>()
53
->createChild< iv::TextLayout >()
54
->
createChild
<
iv::LumaText
>()
55
->text( label_trimmed )
56
->
fontSize
( 15 );
57
}
58
59
//
60
this->
CallColorsChanged
();
61
}
62
63
void
Rectangle_LumaButton::ColorsChanged
(
float4
surface,
float4
on_surface )
64
{
65
if
( this->img_icon )
66
{
67
this->img_icon->
preblend
(
surface
);
68
this->img_icon->
colorTransform
(
ColorTransform::Scale
( on_surface ) );
69
}
70
71
if
( this->text )
72
{
73
this->text->
preblend
(
surface
);
74
this->text->
color
( on_surface );
75
}
76
}
77
78
}