feat(color): New label based Model Selector (#1374)
* Model Labels Selector * Portrait Layout * Receiver ID Check * Fix Labels .yml format * Companion Initial Commit commit 967ddf3979b4954402fe62c858faba4b7a416bba Author: dlktdr <cblackburn320@gmail.com> Date: Mon Aug 29 01:49:15 2022 -0700 Fix Labels .yml format commit 534221cad9e01146c47a9ac1080a655e04f1f6c8 Author: dlktdr <cblackburn320@gmail.com> Date: Mon Aug 29 01:20:57 2022 -0700 Receiver ID Check commit f32c0939d44e9ae60bc0705a9176354c23fec198 Author: dlktdr <cblackburn320@gmail.com> Date: Sun Aug 28 23:13:25 2022 -0700 Portrait Layout commit 961181217c7841ff3f21299ac6aa419b810f80e9 Author: dlktdr <cblackburn320@gmail.com> Date: Sat Dec 11 16:56:13 2021 -0800 Model Labels Selector commitdc99dd40d2Author: David PHAM-VAN <1387855+DavBfr@users.noreply.github.com> Date: Fri Aug 26 03:04:34 2022 -0300 feat: Allow Lua widget to override built-in widget with same name (#2208) * Allow CPP Widgets Override with LUA * Reset a widget option it the type differs commit4b747caff9Author: eshifri <46511024+eshifri@users.noreply.github.com> Date: Thu Aug 25 19:47:53 2022 -0700 fix: Write model name into models.yml when duplicating model (#2224) * Update model name in the models.yml file (#2214) * Fix the length of the name. commite97f23a305Author: eshifri <46511024+eshifri@users.noreply.github.com> Date: Wed Aug 24 21:19:52 2022 -0700 fix(cpn): Fix full path to model notes for Simulator (#2223) * Correct Highlighted Column * labels .yml indentation * Update da.h New defines translated to Danish * Update dataconstants.h Omit warnings due to difference of LEN_MODEL_FILENAME and LEN_MODEL_NAME in modellist.cpp * Update modelslist.cpp Wonder if this are the right file in PR #1374 (?), seems a lot are changed to the better in #1374 * Update dataconstants.h Restore #define for LEN_MODEL_FILENAME to 16 * Rebase, Correct Issues Delete now deletes instead of select New model stores correct information Duplicate save all information in cell Rework items to use cell over button Reword function variables * CMPN: Add context menu Fix output not functional. Removed Yaml::null at some point :) Fix some compiler warnings * CMPN: Compiler warning, replace ,->_ in list * FW: Various Changes Change view to a grid Don't allow comma in label name Add scroll indicators Save sort order Co-authored-by: HThuren <99370924+HThuren@users.noreply.github.com>
This commit is contained in:
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "yaml_modelslist.h"
|
||||
#include "yaml_parser.h"
|
||||
|
||||
#include "storage/modelslist.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using std::list;
|
||||
|
||||
struct modelslist_iter
|
||||
{
|
||||
enum Level {
|
||||
Root=0,
|
||||
Category=1,
|
||||
Model=2
|
||||
};
|
||||
|
||||
ModelsList* root;
|
||||
const char* currentModel;
|
||||
unsigned currentModel_len;
|
||||
uint8_t level;
|
||||
char current_attr[16]; // set after find_node()
|
||||
};
|
||||
|
||||
static modelslist_iter __modelslist_iter_inst;
|
||||
|
||||
void* get_modelslist_iter(const char* currentModel, unsigned currentModel_len)
|
||||
{
|
||||
__modelslist_iter_inst.root = &modelslist;
|
||||
__modelslist_iter_inst.currentModel = currentModel;
|
||||
__modelslist_iter_inst.currentModel_len = currentModel_len;
|
||||
__modelslist_iter_inst.level = 0;
|
||||
|
||||
return &__modelslist_iter_inst;
|
||||
}
|
||||
|
||||
static bool to_parent(void* ctx)
|
||||
{
|
||||
modelslist_iter* mi = (modelslist_iter*)ctx;
|
||||
if (mi->level == modelslist_iter::Root) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mi->level--;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool to_child(void* ctx)
|
||||
{
|
||||
modelslist_iter* mi = (modelslist_iter*)ctx;
|
||||
if (mi->level == modelslist_iter::Model) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mi->level++;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool to_next_elmt(void* ctx)
|
||||
{
|
||||
modelslist_iter* mi = (modelslist_iter*)ctx;
|
||||
if (mi->level == modelslist_iter::Root) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool find_node(void* ctx, char* buf, uint8_t len)
|
||||
{
|
||||
modelslist_iter* mi = (modelslist_iter*)ctx;
|
||||
|
||||
if (len > sizeof(modelslist_iter::current_attr)-1)
|
||||
len = sizeof(modelslist_iter::current_attr)-1;
|
||||
|
||||
memcpy(mi->current_attr, buf, len);
|
||||
mi->current_attr[len] = '\0';
|
||||
|
||||
list<ModelsCategory *>& cats = mi->root->getCategories();
|
||||
if (mi->level == modelslist_iter::Category) {
|
||||
ModelsCategory* cat = new ModelsCategory(buf,len);
|
||||
cats.push_back(cat);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_attr(void* ctx, char* buf, uint8_t len)
|
||||
{
|
||||
modelslist_iter* mi = (modelslist_iter*)ctx;
|
||||
auto ml = mi->root;
|
||||
list<ModelsCategory*>& cats = ml->getCategories();
|
||||
|
||||
switch (mi->level) {
|
||||
case modelslist_iter::Model:
|
||||
if (!strcmp(mi->current_attr, "filename")) {
|
||||
if (!cats.empty()) {
|
||||
ModelCell* model = new ModelCell(buf, len);
|
||||
auto cat = cats.back();
|
||||
cat->push_back(model);
|
||||
ml->incModelsCount();
|
||||
|
||||
if (!strncmp(model->modelFilename, mi->currentModel,
|
||||
mi->currentModel_len)) {
|
||||
ml->setCurrentCategory(cat);
|
||||
ml->setCurrentModel(model);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(mi->current_attr, "name")) {
|
||||
if (!cats.empty()) {
|
||||
auto cat = cats.back();
|
||||
if (!cat->empty()) {
|
||||
auto model = cat->back();
|
||||
model->setModelName(buf, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const YamlParserCalls modelslistCalls = {
|
||||
to_parent,
|
||||
to_child,
|
||||
to_next_elmt,
|
||||
find_node,
|
||||
set_attr
|
||||
};
|
||||
|
||||
const YamlParserCalls* get_modelslist_parser_calls()
|
||||
{
|
||||
return &modelslistCalls;
|
||||
}
|
||||
Reference in New Issue
Block a user