GSoC Update: PlayAnswer widget (wip)

Tanmay
3 min readJun 30, 2023

After dedicating first two weeks of work to libipuz, it was time to shift our focus to the UI part of the Application.

Discussion

To create the PlayAnswer widget, we had two choices: either inherit from the PlayGrid or design a container that includes a PlayGrid as its child. Ultimately, we decided to go with inheriting from the PlayGrid.

Design doc

To commence the journey(coughs), I wrote a design document that aims to provide a hilariously clear and concise overview of the PlayAnswer widget.
You can check that out here!

Inheriting from PlayGrid

In the existing code, the PlayGrid was defined using G_DERIVE_FINAL_TYPE, which essentially marked it as a final class that couldn’t be inherited. However, our goal was to inherit the functionality of the PlayGrid in the PlayAnswer widget.

To achieve this, we had to make the PlayGrid class derivable by removing the G_DERIVE_FINAL_TYPE declaration and making it G_DECLARE_DERIVABLE_TYPE. This allowed us to extend and inherit from the PlayGrid class. Additionally, we created a private structure within the PlayGrid class to encapsulate private members and data.

Writing PlayAnswer

So next up was writing the PlayAnswer widget. To accomplish this, Initially I wrote a simple code that would dynamically generate an answer grid for each clue.
(Including all screenshots here just to showcase my progress on this :-)

As you can see, the appearance of the answer grid leaves much to be desired.

To enhance the visuals of the PlayClueRow widget(which contains the PlayAnswer), I created a separate .ui file. It represents the declaration of the widget’s layout and structure.
Also, I moved the initialization of num_label and clue_label from the play_clue_row_init() function to the .ui file itself.
I used a horizontal box to contain num_label and clue_label to align horizontally and then set the orientation of Layout Manager to vertical, aligning the horizontal box and PlayAnser widget in top-to-bottom fashion.
Perfect.

Also, we are now copying the style and the label of the cells too.

To ensure that whenever values are entered on the main grid they get immediately reflected upon the corresponding cells of the PlayAnswer grid, I wrote a play_answer_update_state function which gets called every time there is an action performed on the puzzle.
Furthermore, I introduced padding between the clue and answer grid and adjusted the zoom level of the answer grid to align it seamlessly with the main grid.

Related Merge Requests:

  • Make Private Structure for PlayGrid !108
  • Add PlayAnswer widget !110

The work on the PlayAnswer widget is still in progress. Stay tuned for the next report. See you then!

Thanks for reading!

--

--