mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 09:45:21 +03:00
[Horus] Move models from one category to another
This commit is contained in:
parent
ce63768df3
commit
93f21bc18f
2 changed files with 75 additions and 57 deletions
|
@ -203,6 +203,11 @@ bool menuModelSelect(evt_t event)
|
||||||
initModelsList();
|
initModelsList();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
|
if (selectMode == MODE_MOVE_MODEL)
|
||||||
|
selectMode = MODE_SELECT_MODEL;
|
||||||
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_EXIT):
|
case EVT_KEY_FIRST(KEY_EXIT):
|
||||||
switch (selectMode) {
|
switch (selectMode) {
|
||||||
case MODE_MOVE_MODEL:
|
case MODE_MOVE_MODEL:
|
||||||
|
@ -215,33 +220,39 @@ bool menuModelSelect(evt_t event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_PGUP):
|
case EVT_KEY_FIRST(KEY_PGUP):
|
||||||
|
if (selectMode == MODE_SELECT_MODEL) {
|
||||||
if (categoriesVerticalPosition == 0)
|
if (categoriesVerticalPosition == 0)
|
||||||
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
||||||
else
|
else
|
||||||
categoriesVerticalPosition -= 1;
|
categoriesVerticalPosition -= 1;
|
||||||
setCurrentCategory(categoriesVerticalPosition);
|
setCurrentCategory(categoriesVerticalPosition);
|
||||||
putEvent(EVT_REFRESH);
|
}
|
||||||
|
else if (selectMode == MODE_MOVE_MODEL && categoriesVerticalPosition > 0) {
|
||||||
|
ModelsCategory * previous_category = currentCategory;
|
||||||
|
ModelCell * model = currentModel;
|
||||||
|
categoriesVerticalPosition -= 1;
|
||||||
|
setCurrentCategory(categoriesVerticalPosition);
|
||||||
|
modelslist.moveModel(model, previous_category, currentCategory);
|
||||||
|
setCurrentModel(currentCategory->size()-1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_FIRST(KEY_PGDN):
|
case EVT_KEY_FIRST(KEY_PGDN):
|
||||||
|
if (selectMode == MODE_SELECT_MODEL) {
|
||||||
categoriesVerticalPosition += 1;
|
categoriesVerticalPosition += 1;
|
||||||
if (categoriesVerticalPosition >= modelslist.categories.size())
|
if (categoriesVerticalPosition >= modelslist.categories.size())
|
||||||
categoriesVerticalPosition = 0;
|
categoriesVerticalPosition = 0;
|
||||||
setCurrentCategory(categoriesVerticalPosition);
|
setCurrentCategory(categoriesVerticalPosition);
|
||||||
putEvent(EVT_REFRESH);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
/*if (selectMode == MODE_SELECT_CATEGORY) {
|
|
||||||
menuVerticalPosition = categoriesVerticalPosition;
|
|
||||||
menuVerticalOffset = categoriesVerticalOffset;
|
|
||||||
if (navigate(event, modelslist.categories.size(), 10)) {
|
|
||||||
categoriesVerticalPosition = menuVerticalPosition;
|
|
||||||
categoriesVerticalOffset = menuVerticalOffset;
|
|
||||||
putEvent(EVT_REFRESH);
|
|
||||||
setCurrentCategory(categoriesVerticalPosition);
|
|
||||||
}
|
}
|
||||||
}*/
|
else if (selectMode == MODE_MOVE_MODEL && categoriesVerticalPosition < modelslist.categories.size()-1) {
|
||||||
|
ModelsCategory * previous_category = currentCategory;
|
||||||
|
ModelCell * model = currentModel;
|
||||||
|
categoriesVerticalPosition += 1;
|
||||||
|
setCurrentCategory(categoriesVerticalPosition);
|
||||||
|
modelslist.moveModel(model, previous_category, currentCategory);
|
||||||
|
setCurrentModel(currentCategory->size()-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EVT_KEY_LONG(KEY_ENTER):
|
case EVT_KEY_LONG(KEY_ENTER):
|
||||||
if (selectMode == MODE_SELECT_MODEL) {
|
if (selectMode == MODE_SELECT_MODEL) {
|
||||||
|
|
|
@ -275,6 +275,13 @@ class ModelsList
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void moveModel(ModelCell * model, ModelsCategory * previous_category, ModelsCategory * new_category)
|
||||||
|
{
|
||||||
|
previous_category->remove(model);
|
||||||
|
new_category->push_back(model);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
std::list<ModelsCategory *> categories;
|
std::list<ModelsCategory *> categories;
|
||||||
ModelsCategory * currentCategory;
|
ModelsCategory * currentCategory;
|
||||||
ModelCell * currentModel;
|
ModelCell * currentModel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue