MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _compute_split_offset

Method _compute_split_offset

scene/gui/split_container.cpp:245–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245void SplitContainer::_compute_split_offset(bool p_clamp) {
246 Control *first = _get_sortable_child(0);
247 Control *second = _get_sortable_child(1);
248 int axis_index = vertical ? 1 : 0;
249 int size = get_size()[axis_index];
250 int sep = _get_separation();
251
252 // Compute the wished size.
253 int wished_size = 0;
254 int split_offset_with_collapse = 0;
255 if (!collapsed) {
256 split_offset_with_collapse = split_offset;
257 }
258 bool first_is_expanded = (vertical ? first->get_v_size_flags() : first->get_h_size_flags()) & SIZE_EXPAND;
259 bool second_is_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND;
260
261 if (first_is_expanded && second_is_expanded) {
262 float ratio = first->get_stretch_ratio() / (first->get_stretch_ratio() + second->get_stretch_ratio());
263 wished_size = size * ratio - sep * 0.5 + split_offset_with_collapse;
264 } else if (first_is_expanded) {
265 wished_size = size - sep + split_offset_with_collapse;
266 } else {
267 wished_size = split_offset_with_collapse;
268 }
269
270 // Clamp the split offset to acceptable values.
271 int first_min_size = first->get_combined_minimum_size()[axis_index];
272 int second_min_size = second->get_combined_minimum_size()[axis_index];
273 computed_split_offset = CLAMP(wished_size, first_min_size, size - sep - second_min_size);
274
275 // Clamp the split_offset if requested.
276 if (p_clamp) {
277 split_offset -= wished_size - computed_split_offset;
278 }
279}
280
281void SplitContainer::_resort() {
282 Control *first = _get_sortable_child(0);

Callers 5

gui_inputMethod · 0.80
_notificationMethod · 0.80

Calls 6

get_sizeFunction · 0.85
CLAMPFunction · 0.85
get_v_size_flagsMethod · 0.80
get_h_size_flagsMethod · 0.80
get_stretch_ratioMethod · 0.80

Tested by

no test coverage detected