Skip to content

Commit

Permalink
1.5.80 release
Browse files Browse the repository at this point in the history
* Imagine: Support drawing unlimited amount of TableView separators by batching in groups of 32
  • Loading branch information
Robert Broglia committed Apr 12, 2024
1 parent f46dcda commit 9f4e373
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
2 changes: 1 addition & 1 deletion EmuFramework/metadata/conf.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata_version = 1.5.79
metadata_version = 1.5.80
metadata_supportedMIMETypes = application/zip
metadata_supportedFileExtensions = rar 7z
android_metadata_versionCodeExtra = 16
Expand Down
2 changes: 1 addition & 1 deletion imagine/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ prefix ?= $(IMAGINE_SDK_PLATFORM_PATH)
imaginePkgconfigTemplate := $(IMAGINE_PATH)/pkgconfig/imagine.pc
pkgName := $(libName)
pkgDescription := Game/Multimedia Engine
pkgVersion := 1.5.79
pkgVersion := 1.5.80
LDLIBS := -l$(libName) $(LDLIBS)
ifdef libNameExt
pkgCFlags := -DIMAGINE_CONFIG_H=$(configFilename)
Expand Down
2 changes: 1 addition & 1 deletion imagine/include/imagine/config/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with Imagine. If not, see <http://www.gnu.org/licenses/> */

#define IMAGINE_VERSION_BASE "1.5.79"
#define IMAGINE_VERSION_BASE "1.5.80"

#ifdef NDEBUG
#define IMAGINE_VERSION IMAGINE_VERSION_BASE
Expand Down
2 changes: 1 addition & 1 deletion imagine/include/imagine/gui/TableView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public:
void setItemsDelegate(ItemsDelegate items_ = [](const TableView &){ return 0; }) { items = items_; }

protected:
static constexpr size_t maxSeparators = 30;
static constexpr size_t maxSeparators = 32;
ItemsDelegate items{};
ItemDelegate item{};
SelectElementDelegate selectElementDel{};
Expand Down
66 changes: 37 additions & 29 deletions imagine/src/gui/TableView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License
along with Imagine. If not, see <http://www.gnu.org/licenses/> */

#define LOGTAG "TableView"

#include <imagine/gui/TableView.hh>
#include <imagine/gui/ViewManager.hh>
#include <imagine/gui/MenuItem.hh>
Expand All @@ -31,6 +29,8 @@
namespace IG
{

constexpr SystemLogger log{"TableView"};

size_t TableView::cells() const
{
return items(*this);
Expand Down Expand Up @@ -77,30 +77,41 @@ void TableView::draw(Gfx::RendererCommands &__restrict__ cmds)
cmds.setClipTest(true);
auto y = viewRect().yPos(LT2DO);
auto x = viewRect().xPos(LT2DO);
int startYCell = std::min(scrollOffset() / yCellSize, (int)cells_);
size_t endYCell = std::clamp(startYCell + visibleCells, 0, (int)cells_);
ssize_t startYCell = std::min(ssize_t(scrollOffset() / yCellSize), cells_);
ssize_t endYCell = std::clamp(startYCell + visibleCells, 0z, cells_);
if(startYCell < 0)
{
// skip non-existent cells
y += -startYCell * yCellSize;
startYCell = 0;
}
//logMsg("draw cells [%d,%d)", startYCell, (int)endYCell);
//log.debug("draw cells:[{},{})", startYCell, endYCell);
y -= scrollOffset() % yCellSize;

// draw separators
int yStart = y;
cmds.basicEffect().disableTexture(cmds);
int selectedCellY = INT_MAX;
if(cells_ > 1)
{
cmds.basicEffect().setModelView(cmds, Gfx::Mat4::ident());
cmds.set(BlendMode::OFF);
cmds.setColor(ColorName::WHITE);
cmds.setVertexArray(separatorQuads);
cmds.setVertexBuffer(separatorQuads);
StaticArrayList<IColQuad, maxSeparators> vRect;
const auto headingColor = PackedColor::format.build(.4, .4, .4, 1.);
const auto regularColor = PackedColor::format.build(.2, .2, .2, 1.);
auto regularYSize = std::max(1, window().heightMMInPixels(.2));
auto headingYSize = std::max(2, window().heightMMInPixels(.4));
for(size_t i = startYCell; i < endYCell; i++)
auto drawSeparators = [](Gfx::RendererCommands &__restrict__ cmds, const auto &vRect)
{
cmds.vertexBufferData(0, vRect.data(), vRect.size() * sizeof(IColQuad));
cmds.drawQuads(0, vRect.size());
};
for(ssize_t i = startYCell; i < endYCell; i++)
{
if((int)i == selected)
if(i == selected)
{
selectedCellY = y;
}
Expand All @@ -117,18 +128,15 @@ void TableView::draw(Gfx::RendererCommands &__restrict__ cmds)
vRect.emplace_back(IColQuad::InitParams{.bounds = rect, .color = color});
}
y += yCellSize;
if(vRect.size() == vRect.capacity()) [[unlikely]]
break;
if(vRect.size() == vRect.capacity())
{
drawSeparators(cmds, vRect);
vRect.clear();
}
}
if(vRect.size())
{
cmds.basicEffect().setModelView(cmds, Gfx::Mat4::ident());
cmds.set(BlendMode::OFF);
cmds.setColor(ColorName::WHITE);
cmds.setVertexArray(separatorQuads);
cmds.setVertexBuffer(separatorQuads);
cmds.vertexBufferData(0, vRect.data(), vRect.size() * sizeof(IColQuad));
cmds.drawQuads(0, vRect.size());
drawSeparators(cmds, vRect);
}
}

Expand All @@ -150,7 +158,7 @@ void TableView::draw(Gfx::RendererCommands &__restrict__ cmds)
// draw elements
y = yStart;
auto xIndent = manager().tableXIndentPx;
for(size_t i = startYCell; i < endYCell; i++)
for(ssize_t i = startYCell; i < endYCell; i++)
{
auto rect = IG::makeWindowRectRel({x, y}, {viewRect().xSize(), yCellSize});
drawElement(cmds, i, item(*this, i), rect, xIndent);
Expand All @@ -164,7 +172,7 @@ void TableView::place()
auto cells_ = items(*this);
for(auto i : iotaCount(cells_))
{
//logMsg("compile item %d", i);
//log.debug("compile item:{}", i);
item(*this, i).compile();
}
if(cells_)
Expand Down Expand Up @@ -329,15 +337,15 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
{
if(!hasFocus)
{
logMsg("gained focus from key input");
log.info("gained focus from key input");
hasFocus = true;
if(selected != -1)
{
postDraw();
return true;
}
}
//logMsg("move up %d", selected);
//log.debug("move up:{}", selected);
if(selected == -1)
selected = prevSelectableElement(cells_ - 1, cells_);
else
Expand All @@ -358,7 +366,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
}
}
}
logMsg("up, selected %d", selected);
log.info("up, selected:{}", selected);
postDraw();
movedSelected = true;
return true;
Expand Down Expand Up @@ -395,7 +403,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
}
}
}
logMsg("down, selected %d", selected);
log.info("down, selected:{}", selected);
postDraw();
movedSelected = true;
return true;
Expand All @@ -404,7 +412,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
{
if(selected != -1)
{
logDMsg("entry %d pushed", selected);
//log.debug("entry:{} pushed", selected);
selectedIsActivated = true;
onSelectElement(e, selected, item(*this, selected));
}
Expand All @@ -416,7 +424,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
selected = cells_ - 1;
else
selected = std::clamp(selected - visibleCells, 0, (int)cells_ - 1);
logMsg("selected %d", selected);
log.info("selected:{}", selected);
postDraw();
movedSelected = true;
return true;
Expand All @@ -427,7 +435,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
selected = 0;
else
selected = std::clamp(selected + visibleCells, 0, (int)cells_ - 1);
logMsg("selected %d", selected);
log.info("selected:{}", selected);
postDraw();
movedSelected = true;
return true;
Expand All @@ -440,7 +448,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
return false;
if(!pointIsInView(motionEv.pos()) || !(motionEv.key() & Input::Pointer::LBUTTON))
{
//logMsg("cursor not in table");
//log.info("cursor not in table");
return false;
}
int i = ((motionEv.pos().y + scrollOffset()) - viewRect().y) / yCellSize;
Expand All @@ -452,7 +460,7 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
auto &it = item(*this, i);
if(motionEv.pushed())
{
//logMsg("input pushed on cell %d", i);
//log.info("input pushed on cell:{}", i);
hasFocus = true;
if(i >= 0 && i < cells_ && elementIsSelectable(it))
{
Expand All @@ -462,14 +470,14 @@ bool TableView::handleTableInput(const Input::Event &e, bool &movedSelected)
}
else if(motionEv.isOff()) // TODO, need to check that Input::PUSHED was sent on entry
{
//logMsg("input released on cell %d", i);
//log.info("input released on cell:{}", i);
if(i >= 0 && i < cells_ && selected == i && elementIsSelectable(it))
{
postDraw();
selected = -1;
if(!motionEv.canceled())
{
logDMsg("entry %d pushed", i);
//log.debug("entry:{} pushed", i);
selectedIsActivated = true;
onSelectElement(e, i, it);
}
Expand Down

0 comments on commit 9f4e373

Please sign in to comment.