MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / UpdateSize

Method UpdateSize

ogsr_engine/xrGame/ui/UIFrameLine.cpp:52–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50//////////////////////////////////////////////////////////////////////////
51
52void CUIFrameLine::UpdateSize()
53{
54 VERIFY(g_bRendering);
55
56 float f_width = elements[flFirst].GetOriginalRect().width();
57 float f_height = elements[flFirst].GetOriginalRect().height();
58 elements[flFirst].SetPos(iPos.x, iPos.y);
59
60 // Right or bottom texture
61 float s_width = elements[flSecond].GetOriginalRect().width();
62 float s_height = elements[flSecond].GetOriginalRect().height();
63
64 (bHorizontalOrientation) ? elements[flSecond].SetPos(iPos.x + iSize - s_width, iPos.y) : elements[flSecond].SetPos(iPos.x, iPos.y + iSize - s_height);
65
66 // Dimentions of element textures must be the same
67 if (bHorizontalOrientation)
68 R_ASSERT(s_height == f_height);
69 else
70 R_ASSERT(f_width == s_width);
71
72 // Now stretch back texture to remaining space
73 float back_width, back_height;
74
75 if (bHorizontalOrientation)
76 {
77 back_width = iSize - f_width - s_width;
78 back_height = f_height;
79
80 // Size of frameline must be equal or greater than sum of size of two side textures
81 R_ASSERT(back_width > 0);
82 }
83 else
84 {
85 back_width = f_width;
86 back_height = iSize - f_height - s_height;
87
88 // Size of frameline must be equal or greater than sum of size of two side textures
89 R_ASSERT(back_height > 0);
90 }
91
92 // Now resize back texture
93 float rem;
94 int tile;
95
96 float b_width = elements[flBack].GetOriginalRect().width();
97 float b_height = elements[flBack].GetOriginalRect().height();
98
99 if (bHorizontalOrientation)
100 {
101 rem = fmod(back_width, b_width);
102 tile = iFloor(back_width / b_width);
103 elements[flBack].SetPos(iPos.x + f_width, iPos.y);
104 elements[flBack].SetTile(tile, 1, rem, 0);
105 }
106 else
107 {
108 rem = fmod(back_height, b_height);
109 tile = iFloor(back_height / b_height);

Callers 1

FrameClipMethod · 0.45

Calls 5

GetOriginalRectMethod · 0.80
SetTileMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
SetPosMethod · 0.45

Tested by

no test coverage detected