Jump to content

mekans

Members
  • Posts

    16
  • Joined

  • Last visited

Posts posted by mekans

  1. Hi there,

    I've got custom widget, and i would like to find how to scroll down the data in it.

    Let's get for example the topic you already helped me with, if i get huge amount of the data in this table, how would i scroll down this custom widget?

    I've discovered MouseWheel(const int delta, const int x, const int y), and i know the slider exists, but i got problem with my custom widget.

    Thanks for any help

     

  2. I Guess it's a real problem with UAK in terms of some widgets, Ultra Engine should be tested on Linux distros X11/Wayland on most popular window managers like i3 bspwm and on GNOME/KDE/XFCE and others.
    If i find problems like that, i am going to report that in the future.

    for now i created poor version of custom menu

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    //Declare new style constants
    enum CustomMenuStyle
    {
        CUSTOM_MENU_DEFAULT = 0
    };
    
    //Declare new widget class
    class CustomMenuWidget : public Widget
    {
        //Custom members
        bool hover;
        shared_ptr<Panel> contextMenu;
        shared_ptr<Widget> editButton;
        shared_ptr<Widget> removeButton;
    
    protected:
    
        virtual bool Initialize(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style)
        {
            bool isInit = Widget::Initialize(text, x, y, width, height, parent, 0);
            contextMenu = CreatePanel(x, y+25, 100, 40, gui->root);
            contextMenu->Hide();
            editButton = CreateButton("Edit", 0, 0, 100, 20, contextMenu, BUTTON_TOOLBAR);//just for an example, no function
            removeButton = CreateButton("Remove", 0, 20, 100, 20, contextMenu, BUTTON_TOOLBAR);
            ListenEvent(EVENT_WIDGETACTION, editButton, EditbuttonCallback, Self()->As<CustomMenuWidget>());
            ListenEvent(EVENT_WIDGETACTION, removeButton, RemoveButtonCallback, Self()->As<CustomMenuWidget>());
    
            return isInit;
        }
        static bool EditbuttonCallback(const Event& ev, shared_ptr<Object> extra)
        {
            auto listView = extra->As<CustomMenuWidget>();
            listView->contextMenu->Hide();
            Print("edit button run");
            return true;
        }
    
        static bool RemoveButtonCallback(const Event& ev, shared_ptr<Object> extra)
        {
            auto listView = extra->As<CustomMenuWidget>();
            listView->contextMenu->Hide();
            Print("remove button run");
            return true;
        }
        //Called when the mouse moves if this widget has the focus
        virtual void MouseMove(const int x, const int y) {}
    
        //Called when the mouse cursor enters the widget bounds
        virtual void MouseEnter(const int x, const int y)
        {
            hover = true;
            Redraw();
        }
    
        //Called when the mouse cursor leaves the widget bounds
        virtual void MouseLeave(const int x, const int y)
        {
            hover = false;
            Redraw();
        }
    
    
        //Called when the mouse button is pressed
        virtual void MouseDown(const MouseButton button, const int x, const int y)
        {
    
            if (button == MOUSE_LEFT)
            {
                if(contextMenu->hidestate) {
                    contextMenu->Show();
    
                }
                else {
                    contextMenu->Hide();
    
                }
            }
        }
    
        //Called when the mouse button is released
        virtual void MouseUp(const MouseButton button, const int x, const int y) {}
    
        //Called when another widget becomes selected
        virtual void LoseFocus() {}
    
        //Called when mouse double-click occurs
        virtual void DoubleClick(const MouseButton button, const int x, const int y) {}
    
        //Called when mouse triple-click occurs
        virtual void TripleClick(const MouseButton button, const int x, const int y) {}
    
        //Called when widget is selected
        virtual void GainFocus() {}
    
        //Called when key is pressed
        virtual void KeyDown(const UltraEngine::KeyCode key) {}
    
        //Called when key is released
        virtual void KeyUp(const UltraEngine::KeyCode key) {}
    
        //Called for each keydown event
        virtual void KeyChar(const int keychar) {}
    
        //Called when mouse wheel turns and mouse is hovered over this widget
        virtual void MouseWheel(const int delta, const int x, const int y) {}
    
        //Called each time the widget is redrawn
        virtual void Draw(const int x, const int y, const int width, const int height)
        {
            blocks.clear();
            Vec4 color = Vec4(0.255f, 0.10f, 0.10f, 1);
            if (hover) color = Vec4(0.255f, 0.255f, 0.255f, 1);
    
            //Background rectangle
            AddBlock(iVec2(0), this->size, color);
    
            //Foreground text
            AddBlock(text, iVec2(0), this->size, Vec4(1), TEXT_CENTER | TEXT_MIDDLE);
        }
    public:
    
        //Constructor
        CustomMenuWidget() : hover(false)
        {}
    
        friend shared_ptr<Widget> CreateCustomMenuWidget(const WString&, const int, const int, const int, const int, shared_ptr<Widget>, const CustomMenuStyle);
    };
    
    //Create function
    shared_ptr<Widget> CreateCustomMenuWidget(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const CustomMenuStyle style)
    {
        auto widget = std::make_shared<CustomMenuWidget>();
        widget->Initialize(text, x, y, width, height, parent, style);
        return widget;
    }

     

    Thank you @Josh and @Dreikblack for supporting me before, i know my posts were annoying but i finally understand how widgets are created.

    2023-07-02_13-23-48.png

    • Like 2
  3. I am wondering, mby it's fault of the libraries i set in the cmake

     

    set(FLAGS -I/usr/include/freetype2 -I/usr/include/fontconfig -D_ULTRA_APPKIT -I${ULTRAENGINEPATH}/Include)
    set(LFLAGS -no-pie -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -ldl)

     

    i've installed newest versions of the packages:  libxft-dev libxrender-dev libxcursor-dev libxmu-dev, going to check if i can include something more from UAK packages, and if i can i ll send the results of that

  4. It's CLion by jetbrains
    in terms of the application - going to check on ubuntu - gnome (KDE debian works like visualisation on the image).
    I don't have got access to ultra engine but if in ultra engine it will work properly i ll consider buying that

  5. i adjusted this solution in some way, but i need now table like listview in c#. It should be columns, headers and rows that could be selected. in a picture we can see that Cell0,0 1.0 and 2.0 are separate cells with data - i need them as a full row that are related to one object and displaying this object data.

    Tbh i tried to build a custom widget with rows and other stuff but it's too hard for me

  6. Hi there,
    How to create table in ultra app kit? I mean table with headers, columns and also selection highlight and hover highlight? From "/learn" i think that i need to create it from CustomWidget, but for newbie like me it's hard. Anyone help?

×
×
  • Create New...