Jump to content
  • entries
    945
  • comments
    5,899
  • views
    929,954

DPI Drawing Issues Solved


Josh

2,108 views

 Share

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.

 

blogentry-1-0-78300000-1468341892.png

 

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

  • Upvote 4
 Share

3 Comments


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...