GUI: Dynamic size, draggable, dropareas

Issue #110 wontfix
Mathias Haimerl
created an issue

No description provided.

Comments (6)

  1. Mathias Haimerl reporter

    Dynamic GUI Size sample:

    function Background:OnInit()
        X,Y = gui:getSize();
        self:set("rect", 0, 0, X, Y);
    end
    
    function Background:OnResize()
        X,Y = gui:getSize();
        self:set("rect", 0, 0, X, Y);
    end
    
  2. Mathias Haimerl reporter

    Draggable/Droparea sample:

    Inventory = gui:new("WindowDraggableT", "Inventory");
    Ghost = gui:new("WindowDraggableT", "__GHOST__");
    
    function Inventory:OnInit()
        self:set("rect", 400, 100, 276, 350);
        self:SetHandleArea(0, 0, 276, 20); -- The area of the window which can be clicked for dragging
        self:SetGhosting(true, Ghost); -- Enable ghosting using the global ghost Window
        for i = 1, 4, 1 do
        	Slots[i] = gui:new("WindowDropareaT", "Slot" .. i);
        	Slots[i]:set("rect", [...] )
            Slots[i]:SetDropClass("itemslot") -- drop class
            --[[ The Drop Modes
             0 - Simple touching
             1 - More than half of the draggable over droppable
             2 - Draggable complete inside droppable
            ]]
            Slots[i]:SetDropMode(1) 
            Slots[i].OnDrop = function(self)
                self:AddChild(self:GetDroppedWin()) -- Change the dragged window's parent
            end 
            Inventory:AddChild(Slots[i])
        end
    end
    
    
    InventoryItem = gui:new("WindowDraggableT", "InvItem1");
    InventoryItem:SetRevert(true); -- revert if not dropped on a valid droparea
    InventoryItem:AddDropClass("itemslot"); -- add a valid drop class
    
    function InventoryItem:OnInit()
        Slots[2]:AddChild(InventoryItem)
    end
    
  3. Carsten Fuchs

    Hi Haimi,

    thank you very much for this patch! However, I have some comments / questions about it:

    1. Could you please explain what the patch does? There is very little information about it. 2. Do I understand correctly that the patch implements multiple features that are independent of each other? If so, would you mind "splitting" the patch into multiple patches, so that each patch implements one logically "atomic" feature? 3. Do the other attachments to this ticket belong to the patch, or are they just examples? If they belong to the patch, can you please include them in the relevant patch?

    Item 2. makea reviewing the patches much easier, which is true even if the second patch depends on the former. If the patches don't depend on each other, having one patch per feature additionally allows me to review and apply them in any order, which is especially useful because a potential problem in one patch does not stall the other.

  4. Mathias Haimerl reporter

    Hi Carsten,

    yes, there are 2 1/2 features implemented, but draggables/dropareas depend on each other. And again, both of these depend on the dynamic gui size, that is why I included them in one ticket. the 4 files are extra, beacuse the svn-diff command did not include them and I don't know how to do this. THe only examples are in the comments, so the attachments are the fix in pure :)

    The dynamic gui size is very, very little code, so I don't think it makes sense or is necessary to separate the features.

  5. Log in to comment