Jump to content

Dreikblack

Members
  • Posts

    323
  • Joined

  • Last visited

Posts posted by Dreikblack

  1. 15 minutes ago, TheHellTower said:

    Yeah I see but I tried the redraw it didn't work on my side to automatically do it and I want to avoid creating multiple elements just to get a different style, I personally think the style should stay accessible but modify the style system to automatically redraw.

    Just redraw() did not worked for me either. "textfield->SetText(textfield->GetText());" with redraw made a field to change text style.

    Other style, TEXTFIELD_READONLY, works with no calling a redraw or changes of text.

     

    19 minutes ago, TheHellTower said:

    I personally think the style should stay accessible but modify the style system to automatically redraw

    Style is just an int basically. In Draw() method Widget checks which one is applied and changes accordingly to it.

    You can see how some of widgets works here - https://github.com/Leadwerks/UltraEngine/tree/main/Source/Classes/GUI

  2. Also you can draw basically anything with Pixmap and WritePixel method https://www.ultraengine.com/learn/Pixmap_WritePixel?lang=cpp

    For example this is how i draw a circle for my custom widget in Ultra App Kit:

    void drawCircle(shared_ptr<Pixmap> pixmap, const int centerX, const int centerY, const int radius, unsigned int color) {
    	int x = 0;
    	int y = radius;
    	int delta = 1 - 2 * radius;
    	int error = 0;
    	while (y >= 0) {
    		drawPixel(pixmap, centerX + x, centerY + y, color);
    		drawPixel(pixmap, centerX + x, centerY - y, color);
    		drawPixel(pixmap, centerX - x, centerY + y, color);
    		drawPixel(pixmap, centerX - x, centerY - y, color);
    		error = 2 * (delta + y) - 1;
    		if (delta < 0 && error <= 0) {
    			++x;
    			delta += 2 * x + 1;
    			continue;
    		}
    		error = 2 * (delta - x) - 1;
    		if (delta > 0 && error > 0) {
    			--y;
    			delta += 1 - 2 * y;
    			continue;
    		}
    		++x;
    		delta += 2 * (x - y);
    		--y;
    	}
    }

     

    • Like 2
  3. 2 hours ago, SpiderPig said:

    The child seems to be blocking a lot of the events to its parent. 

    If i understand correctly your case and how mouse/keys events works a callbacks triggers only for upper UI element under mouse cursor. In UAK i solved it for my custom widgets by calling parent event methods

    void InnerContainer::MouseEnter(const int x, const int y) {
        GetParent()->MouseEnter(x, y);
    }

     

  4. 1 hour ago, Josh said:

    Well, the first step was to add an annual pricing option, because no one will want to manually pay a bill each month, and cypto does not have any way of making automatic monthly payments.

    Thanks! Not sure if i prefer annual subscription due a bit more than 8$ per month in compare with monthly one tho 😅(i guess current annual pricing meant for 10$/month that will be later at some point).

    Sorry for bothering that much. When i found out Ultra Engine is close to launch, i started working on game prototype in UAK and was not sure should i focus on it like proper 2D game (turn based, so should be possible to make with just GUI) or spend less time on things that will be barely useful in proper 3D game engine.

    • Like 1
  5. On 12/24/2022 at 3:40 PM, Josh said:

    I think any wallet that lets you send to an address will work, but let me look into it more.

    I also need to make sure its legal for me to sell in you region. I think all these companies are "voluntarily" enforcing their own sanctions. I don't think it's my place to make up fake laws, I will just follow what the actual legal requirement is.

    Any updates about my case?

  6. Cell.h:

    #pragma once
    #include "UltraEngine.h"
    #include "Table.h"
    
    using namespace UltraEngine;
    
    class Cell : public TextField
    {
    protected:
    	Cell();
    public:
    	static std::shared_ptr<Cell> create(const int x, const int y, const int width, const int height, shared_ptr<Table> table, bool isHeader = false);
    	void MouseEnter(const int x, const int y);
    	void MouseLeave(const int x, const int y);
    	Vec4 highlightColor = Vec4(0.3f, 0.3f, 0.3f, 1.0f);
    	Vec4 backgroundColor = Vec4(0.15f, 0.15f, 0.15f, 1.0f);
    };

    Cell.cpp:

    #include "UltraEngine.h"
    #include "Cell.h"
    
    Cell::Cell()
    {
    }
    
    std::shared_ptr<Cell> Cell::create(const int x, const int y, const int width, const int height, shared_ptr<Table> table, bool isHeader)
    {
    	struct Struct : public Cell {
    	};
    	auto instance = std::make_shared<Struct>();
    	instance->As<Widget>()->Initialize("", x, y, width, height, table, TEXTFIELD_DEFAULT);
    	if (isHeader) {
    		instance->backgroundColor = Vec4(0.2f, 0.2f, 0.2f, 1.0f);
    		instance->highlightColor = Vec4(0.35f, 0.35f, 0.35f, 1.0f);
    		instance->SetColor(instance->backgroundColor, WIDGETCOLOR_SUNKEN);
    	}
    	return instance;
    }
    
    void Cell::MouseEnter(const int x, const int y)
    {
    	TextField::MouseEnter(x, y);
    	SetColor(highlightColor, WIDGETCOLOR_SUNKEN);
    }
    
    void Cell::MouseLeave(const int x, const int y)
    {
    	TextField::MouseEnter(x, y);
    	SetColor(backgroundColor, WIDGETCOLOR_SUNKEN);
    }

    Table.h

    #pragma once
    #include "UltraEngine.h"
    
    class Cell;
    
    using namespace UltraEngine;
    
    class Table : public Panel
    {
    protected:
    	Table();
    
    public:
    	int rowCount = 0;
    	int columnCount = 0;
    	vector<std::shared_ptr<Cell>> headers;
    	static std::shared_ptr<Table> create(const int x, const int y, const int width, const int height, int columnCount, int rowCount, shared_ptr<Widget> parent);
    	vector<vector<std::shared_ptr<Cell>>> cells;
    };

    Table.cpp

    #include "UltraEngine.h"
    #include "Table.h"
    #include "Cell.h"
    
    using namespace UltraEngine;
    
    Table::Table()
    {
    }
    
    std::shared_ptr<Table> Table::create(const int x, const int y, const int width, const int height, int columnCount, int rowCount, shared_ptr<Widget> parent)
    {
    	struct Struct : public Table {
    	};
    	auto instance = std::make_shared<Struct>();
    	instance->Initialize("", x, y, width, height, parent, UltraEngine::PanelStyle::PANEL_DEFAULT);
    	instance->SetColor(0, 0, 0, 0);
    	instance->columnCount = columnCount;
    	instance->rowCount = rowCount;
    	int cellWidth = Floor (float(width) / float(columnCount));
    	int cellHeight = Floor(float(height) / float(rowCount + 1));
    
    	instance->cells.resize(columnCount);
    	instance->headers.resize(columnCount);
    
    	for (int i = 0; i < columnCount; i++) {
    		instance->cells[i].resize(rowCount);
    		instance->headers[i] = Cell::create(cellWidth * i, 0, cellWidth, cellHeight, instance, true);
    		instance->headers[i]->SetText(WString("Header ") + WString(i));
    	}
    	for (int i = 0; i < columnCount; i++) {
    		for (int j = 0; j < rowCount; j++) {
    			instance->cells[i][j] = (Cell::create(cellWidth * i, cellHeight * (j+1) , cellWidth, cellHeight, instance));
    			instance->cells[i][j]->SetText(WString("Cell ") + WString(i) + WString(',') + WString(j));
    		}
    	}
    	return instance;
    }

    main.cpp

    #include "UltraEngine.h"
    #include "UI/Table.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CENTER);
        auto ui = CreateInterface(window);
    
        Table::create(0, 0, 500, 500, 3, 7, ui->root);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            const Event ev = WaitEvent();
            switch (ev.id)
            {     
                case EVENT_QUIT:
                case EVENT_WINDOWCLOSE:
                    return 0;
                    break;
                default: break;
            }
        }
        return 0;
    }

     

    Table.png

    • Like 2
    • Thanks 1
×
×
  • Create New...