Skip to content

Commit

Permalink
Fix reordering color swatches in color picker is not saved
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjtxietian committed May 10, 2024
1 parent c4279fe commit 6f584dd
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,55 @@ void ColorPicker::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
if (preset_from_id == hover_now || hover_now == -1) {
return;
}

{
List<Color>::Element *from = presets.front();
List<Color>::Element *to = presets.front();
{
int c = 0;
while (c < preset_from_id - 1) {
from = from->next();
c++;
}
}
{
int c = 0;
while (c < hover_now - 1) {
to = to->next();
c++;
}
}
if (hover_now == presets.size()) {
presets.move_to_back(from);
} else {
presets.move_before(from, to->next());
}
}

{
List<Color>::Element *from = preset_cache.front();
List<Color>::Element *to = preset_cache.front();
{
int c = 0;
while (c < preset_from_id - 1) {
from = from->next();
c++;
}
}
{
int c = 0;
while (c < hover_now - 1) {
to = to->next();
c++;
}
}
if (hover_now == presets.size()) {
preset_cache.move_to_back(from);
} else {
preset_cache.move_before(from, to->next());
}
}

preset_container->move_child(preset_container->get_child(preset_from_id), hover_now);
}
}
Expand Down

0 comments on commit 6f584dd

Please sign in to comment.