mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +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();
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (selectMode == MODE_MOVE_MODEL)
|
||||
selectMode = MODE_SELECT_MODEL;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
switch (selectMode) {
|
||||
case MODE_MOVE_MODEL:
|
||||
|
@ -215,34 +220,40 @@ bool menuModelSelect(evt_t event)
|
|||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_PGUP):
|
||||
if (categoriesVerticalPosition == 0)
|
||||
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
||||
else
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
if (categoriesVerticalPosition == 0)
|
||||
categoriesVerticalPosition = modelslist.categories.size() - 1;
|
||||
else
|
||||
categoriesVerticalPosition -= 1;
|
||||
setCurrentCategory(categoriesVerticalPosition);
|
||||
}
|
||||
else if (selectMode == MODE_MOVE_MODEL && categoriesVerticalPosition > 0) {
|
||||
ModelsCategory * previous_category = currentCategory;
|
||||
ModelCell * model = currentModel;
|
||||
categoriesVerticalPosition -= 1;
|
||||
setCurrentCategory(categoriesVerticalPosition);
|
||||
putEvent(EVT_REFRESH);
|
||||
setCurrentCategory(categoriesVerticalPosition);
|
||||
modelslist.moveModel(model, previous_category, currentCategory);
|
||||
setCurrentModel(currentCategory->size()-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_PGDN):
|
||||
categoriesVerticalPosition += 1;
|
||||
if (categoriesVerticalPosition >= modelslist.categories.size())
|
||||
categoriesVerticalPosition = 0;
|
||||
setCurrentCategory(categoriesVerticalPosition);
|
||||
putEvent(EVT_REFRESH);
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
categoriesVerticalPosition += 1;
|
||||
if (categoriesVerticalPosition >= modelslist.categories.size())
|
||||
categoriesVerticalPosition = 0;
|
||||
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;
|
||||
|
||||
|
||||
/*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);
|
||||
}
|
||||
}*/
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
if (selectMode == MODE_SELECT_MODEL) {
|
||||
killEvents(event);
|
||||
|
|
|
@ -239,46 +239,53 @@ class ModelsList
|
|||
}
|
||||
}
|
||||
|
||||
ModelsCategory * createCategory()
|
||||
{
|
||||
ModelsCategory * result = new ModelsCategory("Category");
|
||||
categories.push_back(result);
|
||||
save();
|
||||
return result;
|
||||
}
|
||||
ModelsCategory * createCategory()
|
||||
{
|
||||
ModelsCategory * result = new ModelsCategory("Category");
|
||||
categories.push_back(result);
|
||||
save();
|
||||
return result;
|
||||
}
|
||||
|
||||
ModelCell * addModel(ModelsCategory * category, const char * name)
|
||||
{
|
||||
ModelCell * result = category->addModel(name);
|
||||
modelsCount++;
|
||||
save();
|
||||
return result;
|
||||
}
|
||||
ModelCell * addModel(ModelsCategory * category, const char * name)
|
||||
{
|
||||
ModelCell * result = category->addModel(name);
|
||||
modelsCount++;
|
||||
save();
|
||||
return result;
|
||||
}
|
||||
|
||||
void removeCategory(ModelsCategory * category)
|
||||
{
|
||||
modelsCount -= category->size();
|
||||
delete category;
|
||||
categories.remove(category);
|
||||
}
|
||||
void removeCategory(ModelsCategory * category)
|
||||
{
|
||||
modelsCount -= category->size();
|
||||
delete category;
|
||||
categories.remove(category);
|
||||
}
|
||||
|
||||
void removeModel(ModelsCategory * category, ModelCell * model)
|
||||
{
|
||||
category->removeModel(model);
|
||||
modelsCount--;
|
||||
save();
|
||||
}
|
||||
void removeModel(ModelsCategory * category, ModelCell * model)
|
||||
{
|
||||
category->removeModel(model);
|
||||
modelsCount--;
|
||||
save();
|
||||
}
|
||||
|
||||
void moveModel(ModelsCategory * category, ModelCell * model, int8_t step)
|
||||
{
|
||||
category->moveModel(model, step);
|
||||
save();
|
||||
}
|
||||
void moveModel(ModelsCategory * category, ModelCell * model, int8_t step)
|
||||
{
|
||||
category->moveModel(model, step);
|
||||
save();
|
||||
}
|
||||
|
||||
std::list<ModelsCategory *> categories;
|
||||
ModelsCategory * currentCategory;
|
||||
ModelCell * currentModel;
|
||||
unsigned int modelsCount;
|
||||
void moveModel(ModelCell * model, ModelsCategory * previous_category, ModelsCategory * new_category)
|
||||
{
|
||||
previous_category->remove(model);
|
||||
new_category->push_back(model);
|
||||
save();
|
||||
}
|
||||
|
||||
std::list<ModelsCategory *> categories;
|
||||
ModelsCategory * currentCategory;
|
||||
ModelCell * currentModel;
|
||||
unsigned int modelsCount;
|
||||
|
||||
protected:
|
||||
FIL file;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue