Categories
Coding Experience Fun Technical

Implementing Mac Styled PopupMenu’s, First PR After GSoC Accepted!

Introduction

This is a blog and demonstration for my first pull request that got accepted after getting selected into this program! I plan to create a blog entry for each of the features/major changes and keep my audience updated!

Anyways, so the first task was to complete something called Mac popup menus, if you don’t know what it is, then It is nothing but a popup menu (i.e., those whom you click, and they give a bunch of options)! Now this was not completely my work but was of someone else.. I was only tasked to complete their work..!

Menus - Material Design
A typical popup menu

The Menu..

The first thing I did after getting this task was to read the codebase, understand how the menu works and try to understand how the existing code operated! To be frank and honest, this actually took me quite a time, plus university examinations were already taking lots of time!\

Anyways, I kept on reading codes, making changes, getting popup menu to be implemented however..

THE CODE WAS VERY BAD

Ahh.. sorry for shouting, lost my composure there for a second :)! Anyways, by code was very bad I don’t mean the code written at ScummVM (this organization), no it is a piece of art, but I mean the code written by the person before me (the unfinished code).

The more I kept on understanding it, hacking it, etc, The more changes I had to do, at some point of finishing their work, I had to change everything from scratch and implement major functionalities myself.

That day I understood, what happens if you write workaround code in big production software, you make life difficult for the people taking your work, sigh.

Anyways, so getting to the main topic.. I was tasked to implement an unfinished popupmenu, for many of you still not getting feel of what this “MAC STYLED POPUPMENU” (of vintage ages) looks like, here the photo taken from Basilisk II (Mac 7.0 Simulation)

Original Mac Popup Menu, as taken from basilisk II

Looking at the state of the popup menu and current implementation, there were many big and small details that needed to be implemented like:

  1. Alignment issues, the rendered menu was some pixels off it is supposed to be, and in some cases, it was very very far away! (We welcome you, Desktop Mode)
  2. BAD CODE, Improper variable introduction (A variable was there just for bad workaround of bypassing some loops, calling some particular functions.. etc)
  3. Many features not implemented (Like smart menu which remembers your last choice), checkboxes, remember last item, etc!
  4. Some more small bugs that were found on the way, needed to be resolved for proper functioning!

Over time, with proper and lengthy discussions and regular updates to mentor, these bugs were addressed and we reached to a point where popup menu in ScummVM were working (demo gif below):

The final result after implementing the popup menu!

Overall this was quite fun to work with, I got a good understanding of how Mac styled windows (not only popup menu) are created and used throughout the project! Director (the engine I work on) was first built for Mac systems, and thus I believe this knowledge of fundamentals would be very useful for long-term contributions!

Plus it was quite fun to find English-ordered alphabet items on the menu (I bet you didn’t notice) ><! (ie the menu items are Apple, Banana, Cherry, Duck… etc, ordered by first alphabet)

Anyways, with this my first pull request after getting accepted was finished, It was successfully merged (After many review rounds and corrections), here is the link to the pull request – #5005!

It doesn’t end here

My frequency of writing blogs do not match with the speed of my contributions! and thus by the time I started writing this, and by the time I reach to this section.. another two tasks were given, I completed them, and the prs are merged! Giving links, they were #5056 and #5059!

These were technical bugfixes/implementations, things that do not have intuitive GUI that I can show (and you understand)! But hey.. Let’s have an easter egg before I end this, and that is:

The Jumping Windows! #5059

A part of the task given to me, (that I solved in pr #5059), was to implement window location set/get functions, in layman terms basically each Mac window (that’s what they call it XD) has this field called rect which can be used to set/change their location!

Now this function to set the window location was unimplemented, and thus there was this thing where it you are supposed to click on “Change” and it will alternatively teleport(err. move) the window between two positions! Initially before implementing, it was not working but after implementing this function, things successfully worked and the window was happily jumping here and there like a happy kid it is supposed to be.

And if you didn’t realize it, this section was meant to be a troll, (but still, jumping windows were good XDDD), anyways thanks for reading!

The End

Thanks for reading so far, I really appreciate each of you still here with me! Also apologies for bad writing style/punctuation/grammar mistakes, etc! I hope this was a fun read and look forward to the next part!

Leave a Reply

Your email address will not be published. Required fields are marked *