{"id":38,"date":"2016-06-26T11:44:17","date_gmt":"2016-06-26T11:44:17","guid":{"rendered":"https:\/\/blogs.scummvm.org\/tkachov\/?p=38"},"modified":"2022-05-24T11:45:51","modified_gmt":"2022-05-24T11:45:51","slug":"gsoc-the-container","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/tkachov\/2016\/06\/26\/gsoc-the-container\/","title":{"rendered":"GSoC: The Container"},"content":{"rendered":"<p>First of\u00a0all, I\u00a0finally passed my\u00a0exams! I\u2019ve got a\u00a0few things to\u00a0do, but in\u00a0July I\u2019d be\u00a0completely free to\u00a0work on\u00a0my\u00a0project. That\u2019s why\u00a0I wasn\u2019t too active this week and wouldn\u2019t be\u00a0on\u00a0the next one.<\/p>\n<p>So, this week\u00a0I was working on\u00a0non-cloud-related thingie: a\u00a0new GUI widget, which would contain other widgets of\u00a0unlimited total height\u00a0\u2014 the Container. Well, it\u2019s actually a\u00a0ScrollContainerWidget, and the main thing it\u00a0has is\u00a0a\u00a0scrollbar. As\u00a0I\u00a0said in\u00a0the previous post, one of\u00a0my\u00a0dialogs\u00a0\u2014 the storage wizard\u00a0\u2014 is\u00a0too lengthy to\u00a0be\u00a0displayed in\u00a0that area where ScummVM shows its dialogs. We\u00a0decided that\u00a0I should implement the Container, so\u00a0we\u00a0can put dialog contents in\u00a0it, and in\u00a0these cases when there is\u00a0no\u00a0room to\u00a0display all of\u00a0them, the scrollbar would automatically appear and no\u00a0overlap will happen.<\/p>\n<p>The first thing\u00a0I changed was label\u00a0\u2014 it\u00a0already has a\u00a0clipping rectangle, so\u00a0I only had to\u00a0pass the right values. Then the fun (to\u00a0be\u00a0read as\u00a0difficult) part started. Widgets doesn\u2019t have any clipping rectangle, which means you can\u2019t just make the button draw only part of\u00a0it. And, well, each widget has its own method, so\u00a0it\u00a0means I\u2019ve got to\u00a0change all of\u00a0these in\u00a0order to\u00a0make them support clipping.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.scummvm.org\/tkachov\/wp-content\/uploads\/sites\/60\/2022\/05\/wip.png\" \/><\/p>\n<p>I\u00a0started with buttons and PopUpWidget, because those are used in\u00a0the Cloud tab of\u00a0the Options dialog. Their drawWidget() method calls the corresponding drawButton()\/drawPopUpWidget() method of\u00a0ThemeEngine. ThemeEngine uses queueDD() and queueDDText(). Some DrawData objects are created in\u00a0there, then their draw steps are called. If\u00a0I\u00a0recall correctly, draw steps are methods of\u00a0VectorRenderer, which has VectorRendererSpec backends with implementations of\u00a0these. So, I\u2019ve got to\u00a0pass that clipping area information from Widget though ThemeEngine and DrawData objects right to\u00a0VectorRendererSpec and use it\u00a0there.<\/p>\n<p>Each of\u00a0those draw step implementations has some additional functions in\u00a0VectorRendererSpec. And these functions have some complicated logic and lots of\u00a0macros usage. And none of\u00a0these happen to\u00a0think that clipping would ever be\u00a0needed.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.scummvm.org\/tkachov\/wp-content\/uploads\/sites\/60\/2022\/05\/clipping.png\" \/><\/p>\n<p>So, buttons are using drawRoundedSquare() draw step method. To\u00a0minimize the possibitility of\u00a0breaking something, I\u00a0decided to\u00a0leave these methods and add new ones\u00a0\u2014 drawRoundedSquareClip() in\u00a0this case. It\u00a0checks that clipping is\u00a0actually needed (i.e. button area is\u00a0not completely in\u00a0the clipping area), and if\u00a0not, uses the original one. If\u00a0clipping is\u00a0needed, then other Clip-versions are used. So, drawRoundedSquareAlgClip(), drawBorderRoundedSquareAlgClip(), drawInteriorRoundedSquareAlgClip(), gradientFillClip(), blendFillClip(), colorFillClip() and a\u00a0lot of\u00a0macros with names like BE_DRAWCIRCLE_XCOLOR_BOTTOM_CLIP() arrived.<\/p>\n<p>All this\u00a0\u2014 for rounded squares. And there are also triangles, circles and other draw steps, which\u00a0I didn\u2019t touch yet. But still, Container already works with buttons, PopUpWidget and labels, and\u00a0I guess in\u00a0some cases it\u00a0would be\u00a0enough to\u00a0add new draw&lt;WidgetName&gt;() and use all these methods, which already do\u00a0clipping, so\u00a0it\u00a0should be\u00a0getting easier as\u00a0I\u00a0go further. The plan is\u00a0to\u00a0make all other widgets support clipping, so\u00a0Container could be\u00a0used with any of\u00a0them. Apart from that\u00a0\u2014 it\u00a0seems to\u00a0work fine.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.scummvm.org\/tkachov\/wp-content\/uploads\/sites\/60\/2022\/05\/final.png\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First of\u00a0all, I\u00a0finally passed my\u00a0exams! I\u2019ve got a\u00a0few things to\u00a0do, but in\u00a0July I\u2019d be\u00a0completely free to\u00a0work on\u00a0my\u00a0project. That\u2019s why\u00a0I wasn\u2019t too active this week and wouldn\u2019t be\u00a0on\u00a0the next one. So, this week\u00a0I was working on\u00a0non-cloud-related thingie: a\u00a0new GUI widget, which would contain other widgets of\u00a0unlimited total height\u00a0\u2014 the Container. Well, it\u2019s actually a\u00a0ScrollContainerWidget, and the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/posts\/38\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/tkachov\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}