DPI Drawing Issues Solved
I've updated the beta branch (Lua on Windows only) with a new build that solves the DPI scaling issues I previously described. Widget creation still works the same, using the same coordinate system regardless of GUI scale. Widget scripts must use global coordinates in the drawing commands, which means calling Widget:GetPosition(true) and Widget:GetSize(true). Here's the very simple panel script, which simply draws a solid block on the screen to frame child widgets within:
function Script:Draw(x,y,width,height) local gui = self.widget:GetGUI() local pos = self.widget:GetPosition(true) local sz = self.widget:GetSize(true) gui:SetColor(0.25,0.25,0.25,1) gui:DrawRect(pos.x,pos.y,sz.width,sz.height) end
I've included this script and a simple button to help get you started.
Raster images can be drawn and scaled in a manner that makes them resolution-independent. The idea of loading SVG vector images at any resolution has been floated, and I think it's a good one, though I have no experience with this format. I think it would work similarly to how we treat fonts right now, a vector format that can be loaded into a raster image at any resolution. So this is something I am interested in exploring.
This would give you three tools to perform drawing in the Widget scripts: Leadwerks drawing commands, raster images, and vector images that would be resolution-independent.
I've also added the ability to add Widget items. These would be like entries in a list view or a tabbed panel:
virtual int AddItem(const std::string& text);//lua
virtual std::string GetItemText(const int index);//lua
virtual int CountItems();//lua
virtual void ClearItems();//lua
- 4
3 Comments
Recommended Comments