Skip to content

Commit

Permalink
FileSelectTree End, child view ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuria-Shikibe committed Jun 3, 2024
1 parent 8f6771f commit 66ba1cf
Show file tree
Hide file tree
Showing 67 changed files with 612 additions and 326 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ CTestTestfile.cmake
/properties/resource/data/
/properties/resource/cache/
/properties/resource/logs/
/properties/cache/
8 changes: 4 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ void setupUITest(){

label.setText(label.getBundleEntry("sync-camera"));
}).setHeight(60);
button.setCall([](auto&, bool){
button.setCall([]{
Game::core->cameraLock = !Game::core->cameraLock;
});
button.setActivatedChecker([]{
button.setActivatedChecker([](auto&){
return Game::core->cameraLock;
});
}).wrapY().endLine().setPad({.bottom = 10.0f});
Expand All @@ -398,10 +398,10 @@ void setupUITest(){

label.setText(label.getBundleEntry("draw-debug"));
}).setHeight(60);
button.setCall([](auto&, bool){
button.setCall([]{
drawDebug = !drawDebug;
});
button.setActivatedChecker([]{
button.setActivatedChecker([](auto&){
return drawDebug;
});
}).wrapY().endLine();
Expand Down
Binary file not shown.
Binary file removed properties/cache/font-load/font-load.bin
Binary file not shown.
Binary file removed properties/cache/font-load/font-load0.png
Binary file not shown.
Binary file not shown.
Binary file removed properties/cache/font/Consolas/consolab-Bold-48.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed properties/cache/tex-atlas/base.bin
Binary file not shown.
Binary file removed properties/cache/tex-atlas/base0.png
Binary file not shown.
Binary file removed properties/cache/tex-atlas/light.bin
Binary file not shown.
Binary file removed properties/cache/tex-atlas/light0.png
Binary file not shown.
Binary file removed properties/cache/tex-atlas/normal.bin
Binary file not shown.
Binary file removed properties/cache/tex-atlas/normal0.png
Binary file not shown.
Binary file removed properties/cache/tex-atlas/ui.bin
Binary file not shown.
Binary file removed properties/cache/tex-atlas/ui0.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion properties/resource/assets/svg/icons/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions properties/resource/assets/svg/icons/sort-amount-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/SideTemp.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void setupUITest_Old(){
t.defaultCellLayout.setMargin({.left = 2.0f, .right = 2.f});
for(int i = 0; i < 8; ++i){
t.add<UI::Button>([i](UI::Button& button){
button.setCall([i](UI::Button& b, bool){
button.setCall([i](UI::Button& b){
b.buildTooltip();
});

Expand Down
4 changes: 2 additions & 2 deletions src/arc-impl/Assets_Dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void Assets::loadDir(){
patch(bundle);


cache = mainTree.findDir("cache");
cache = mainTree.findDir("resource").subFile("cache");
patch(cache);

texCache = cache.subFile("tex-atlas");
Expand All @@ -37,7 +37,7 @@ void Assets::loadDir(){
game = assets.subFile("game");
patch(game);

data = mainTree.findDir("data");
data = mainTree.findDir("resource").subFile("data");
patch(data);

settings = data.subFile("settings");
Expand Down
2 changes: 1 addition & 1 deletion src/arc-impl/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void Core::initFileSystem() {
#if defined(_DEBUG) && defined(ASSETS_DIR)
rootFileTree = OS::FileTree(ASSETS_DIR);
#else
const auto dir = Core::platform->getProcessFileDir().subFile("resource");
const auto dir = Core::platform->getProcessFileDir();

std::cout << "Targeted Resource Root:" << dir.absolutePath() << std::endl;

Expand Down
8 changes: 3 additions & 5 deletions src/arc-impl/ui/Actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module UI.Action.Actions;

import UI.Group;

void UI::Actions::RemoveAction::begin(Elem* elem){
if(elem->getParent()){
elem->getParent()->postRemove(elem);
}
}
// void UI::Actions::RemoveAction::begin(Elem* elem){
// elem->callRemove();
// }
1 change: 1 addition & 0 deletions src/arc-impl/ui/Dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void UI::Dialog::resizeContent(){

content.setSize(root->width - margin.getWidth(), root->height - margin.getHeight());
content.changed(ChangeSignal::notifyAll);
content.postChanged();

content.setSrc(margin.bot_lft());
}
Expand Down
7 changes: 4 additions & 3 deletions src/arc-impl/ui/Drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ void UI::UIStyle::drawElem(const UI::Elem* elem) const {
elem->tempColor = elem->color;
elem->tempColor.a *= elem->maskOpacity;

float alphaScl = elem->selfMaskOpacity * elem->maskOpacity;
if(elem->isDisabled())elem->tempColor.mul(0.8f);

float alphaScl = elem->selfMaskOpacity * elem->maskOpacity * (elem->isDisabled() ? 0.85f : 1.f);

Overlay::mixColor(elem->tempColor);
const Rect rect = elem->getBound().setSrc(elem->getAbsSrc());
base.draw(elem, alphaScl, rect);
edge.draw(elem, alphaScl, rect);

if(elem->isCursorInbound())inbound.draw(elem, alphaScl, rect);
if(elem->isCursorInbound() && !elem->isDisabled())inbound.draw(elem, alphaScl, rect);
if(elem->isActivated()){

activated.draw(elem, alphaScl, rect);
}
if(elem->isPressed())pressed.draw(elem, alphaScl, rect);
Expand Down
8 changes: 4 additions & 4 deletions src/arc-impl/ui/Elem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ void UI::Elem::drawStyle() const {
drawer->drawStyle(this);
}

UI::Group* UI::Elem::getParent() const {
UI::Elem* UI::Elem::getParent() const {
return parent;
}

void UI::Elem::setDrawer(WidgetDrawer* drawer){
void UI::Elem::setDrawer(ElemDrawer* drawer){
this->drawer = drawer;

if(drawer) {
Expand All @@ -82,8 +82,8 @@ void UI::Elem::setEmptyDrawer(){
setDrawer(&UI::emptyDrawer);
}

UI::Group* UI::Elem::setParent(Group* const parent) {
Group* former = parent;
UI::Elem* UI::Elem::setParent(Elem* const parent) {
Elem* former = parent;
this->parent = parent;
setRoot(parent->root);

Expand Down
2 changes: 1 addition & 1 deletion src/arc-impl/ui/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GL;
void UI::Group::drawChildren() const{
const bool isScissorActivated = GL::getScissorCount();
for(const auto& elem : children) {
if(!isScissorActivated || (parent && elem->getBound().setSrc(elem->getAbsSrc()).overlap(parent->getBound().setSrc(parent->getAbsSrc())))){
if(!isScissorActivated || !parent || elem->getBound().setSrc(elem->getAbsSrc()).overlap(parent->getBound().setSrc(parent->getAbsSrc()))){
elem->draw();
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/arc-impl/ui/ImageRegion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module UI.ImageRegion;

import Graphic.Draw;

void UI::ImageRegion::drawContent() const{
if(drawable){
tempColor = color;
tempColor.a *= selfMaskOpacity * maskOpacity * (isDisabled() ? 0.85f : 1.f);
if(isDisabled())tempColor.mul(0.8f);

Graphic::Draw::Overlay::color(tempColor);

const auto size = Align::embedTo(scaling, drawable->getDefSize(), getValidSize());
const auto offset = Align::getOffsetOf(imageAlign, size, getValidBound());

drawable->draw(Geom::OrthoRectFloat{size.x, size.y}.setSrc(offset + absoluteSrc));
}
}
2 changes: 1 addition & 1 deletion src/arc-impl/ui/InputArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UI.Root;
import UI.Palette;

bool UI::InputArea::isTextFocused() const{
return root->textInputListener == this;
return root && root->textInputListener == this;
}

void UI::InputArea::setTextFocused(){
Expand Down
29 changes: 25 additions & 4 deletions src/arc-impl/ui/ScrollPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ void UI::ScrollBarDrawer::operator()(const ScrollPane* pane) const{
}
}

void UI::ScrollPane::modifyItem(){
item->setParent(this);
changed(ChangeSignal::notifyAll);
item->setRoot(root);
notifyLayoutChanged();
}

void UI::ScrollPane::update(const Core::Tick delta){
if(Elem::isInbound(root->cursorPos) && (enableHorizonScroll() || enableVerticalScroll())){
Elem::setFocusedScroll(true);
Expand All @@ -39,7 +46,14 @@ void UI::ScrollPane::update(const Core::Tick delta){
scrollVelocity.lerp(scrollTargetVelocity,
usingAccel ? (pressed ? 1.0f : Math::clamp(accel * delta.count())) : 1.0f);

Group::update(delta);
if(prepareRemove){
item.reset();
prepareRemove = false;
}

if(item)item->update(delta);

Elem::update(delta);

if(scrollTempOffset != scrollOffset){
//TODO what...?
Expand Down Expand Up @@ -102,7 +116,7 @@ UI::CursorType UI::ScrollPane::getCursorType() const noexcept{
}

void UI::ScrollPane::applyDefDrawer() noexcept{
Group::applyDefDrawer();
Elem::applyDefDrawer();
scrollBarDrawer = &UI::defScrollBarDrawer;
}

Expand All @@ -111,6 +125,7 @@ void UI::ScrollPane::drawBase() const{
}

void UI::ScrollPane::drawContent() const{
if(!item)return;
if(enableHorizonScroll() || enableVerticalScroll()){
Graphic::Draw::Overlay::getBatch().flush();

Expand All @@ -128,7 +143,7 @@ void UI::ScrollPane::drawContent() const{
GL::scissorShrinkBegin();
GL::setScissor(clip);

drawChildren();
item->draw();
Graphic::Draw::Overlay::getBatch().flush();

GL::forceSetScissor(lastRect);
Expand All @@ -137,6 +152,12 @@ void UI::ScrollPane::drawContent() const{

scrollBarDrawer->operator()(this);
} else{
drawChildren();
item->draw();
}
}

void UI::ScrollPane::setRoot(Root* root) noexcept{
Elem::setRoot(root);

if(hasChildren())item->setRoot(root);
}
58 changes: 16 additions & 42 deletions src/arc-impl/ui/Table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ void UI::Table::layoutRelative() {
cells.back().item->setEndRow(true);

// [y0, y1, ... yn, x1, x2, ... xn]
std::vector<float> maxSizeArr(columns() + rows());
std::basic_string<float> maxSizeArr{};
maxSizeArr.resize(columns() + rows());

//Split all into boxes
//TODO should cells have their own column or row data?
Expand Down Expand Up @@ -127,14 +128,9 @@ void UI::Table::layoutRelative() {
}
}

float currentSpacingX = 0;
float currentSpacingY = std::accumulate(maxSizeArr.begin() + 1, maxSizeArr.begin() + rows(), 0.0f);

Geom::Vec2 offset = Align::getOffsetOf(cellAlignMode, Geom::Vec2{cellSize.x, cellSize.y}, getValidBound());

//TODO cells may expand during this process
//Need another re-layout to handle this

Geom::Vec2 currentSrc{};
Geom::Vec2 currentPad{};
Geom::Vec2 maximumPad{};

Expand All @@ -150,17 +146,16 @@ void UI::Table::layoutRelative() {
cell.allocatedBound.setSize(maxSizeArr[curPosX_indexed], maxSizeArr[curPos.y]);

cell.allocatedBound.setSrc(
currentSpacingX,
currentSpacingY //Top src to Bottom src transform
currentSrc.x, currentSrc.y - cell.allocatedBound.getHeight() //Top src to Bottom src transform
);

const Geom::Vec2 thisPad{cell.pad.left, -cell.pad.top};

cell.applySizeToItem();
cell.allocatedBound.move(offset + Geom::Vec2{currentPad.x, -maximumPad.y} + thisPad);
cell.allocatedBound.move(Geom::Vec2{currentPad.x, -maximumPad.y} + thisPad);

curPos.x++;
currentSpacingX += maxSizeArr[curPosX_indexed];
currentSrc.x += maxSizeArr[curPosX_indexed];

currentPad.x += cell.getPadHori();
currentPad.maxY(cell.getPadVert());
Expand All @@ -169,9 +164,6 @@ void UI::Table::layoutRelative() {
currentMaxSize.maxY(cell.getCellHeight());

if(cell.isEndRow()) {
curPos.y++;
curPos.x = 0;

maximumPad.maxX(currentPad.x);
maximumPad.y += currentPad.y;

Expand All @@ -181,16 +173,16 @@ void UI::Table::layoutRelative() {
currentPad.setZero();
currentMaxSize.setZero();

currentSpacingX = 0;
currentSpacingY -= maxSizeArr[curPos.y];
currentSrc.x = 0;
currentSrc.y -= maxSizeArr[curPos.y];

curPos.y++;
curPos.x = 0;
}
}

if(!maximumPad.isZero(0.00005f)){
cellSize.x += maximumPad.x;
cellSize.y += maximumPad.y;

const Geom::Vec2 originalSize = bound.getSize();
if(!maximumPad.isZero()){
cellSize += maximumPad;

if(expandX && !fillParentX){
if(expandX_ifLarger){
Expand All @@ -207,29 +199,11 @@ void UI::Table::layoutRelative() {
if(!scaleRequester.y)setHeight(cellSize.y + getBorderHeight());
}
}

offset = bound.getSize() - originalSize;

if(cellAlignMode & Align::Layout::bottom){
offset.y += maximumPad.y;
} /*TODO wtf
else if(cellAlignMode & Align::Layout::center_y){
offset.y -= maximumPad.y / 2.f;
}*/

if(cellAlignMode & Align::Layout::right){
offset.x -= maximumPad.x;
} else if(cellAlignMode & Align::Layout::center_x){
offset.x -= maximumPad.x / 2.f;
}

// offset -= maximumPad;
//TODO there must be sth wrong
// offset.x = 0;
}else{
offset.setZero();
}

Geom::Vec2 offset = Align::getOffsetOf(cellAlignMode, cellSize, getValidBound());
offset.y += cellSize.y;

for(auto& cell : cells) {
if(cell.isIgnoreLayout())continue;

Expand Down
4 changes: 3 additions & 1 deletion src/arc/asset/TexturePacker.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ext.Heterogeneous;
export namespace Assets {
using PixmapModifer = std::function<void(Graphic::Pixmap& modifier)>;

//TODO redesign these class

struct TextureRegionPackData{
Geom::OrthoRectInt bound{};
GL::TextureRegion textureRegion{};
Expand Down Expand Up @@ -302,7 +304,7 @@ export namespace Assets {
packDone = false;

while(true) {
//TODO there should be a better way.
//TODO there should be a better way. no busy wait
if(target.done && !target.packDone) {
handler->operator()(ext::RuntimeException{"Failed To Pack Linked Texture Atlas: " + pageName});
}
Expand Down
Loading

0 comments on commit 66ba1cf

Please sign in to comment.