Thursday 14 June 2012

GSoC Update 2: Implementing the New UI

So, I have been working on implementing the new UI. I worked out how Gtk layouts and packing work, and added a hint and back button to the control area (to the right of the grid).

Now, the number picker (the dialog that pops up when you double click a square), was created dynamically in one method. What I did is separate out the number picker in to a new Widget (I think this is the correct term?), called, wait for it, NumberPicker. This can be used in the dialog, for the double click functionality, but is also equally suited for use in the control area to the side.

I also while doing the above task, removed the deprecated Gtk.VBox, and Gtk.Table in the code, and replacing them with Gtk.Box, and Gtk.Grid respectively. I have spotted Table being used elsewhere, so I will probably try to go round and update all of these issues at some point.

Replacing the number picker in the SudokuCellView class (the bit that manages each individual cell on the grid) was relatively easy, once I (helped by my mentor) got an understanding of how to use signals. This was because I got the code I used for the NumberPicker from there.

The control section one was slightly harder as it is completely separate from the grid. I added event signals to the SudokuCellView class and SudokuView class (that handles the entire grid), such that I can get notified when a cell gains and loses focus. I then connected the gain focus event to a function that enabled or disabled the NumberPicker depending on whether the cell was editable. Then, as the cell loses focus when a button on the NumberPicker is pressed, I had to work out a way for the selected cell in the grid, to stay selected while the user was pressing buttons on the NumberPicker. So, as the current "selected" system used the focus property, I added a selected property to the SudokuCellView class, and then added selected_x, and selected_y properties to the SudokuView class.

Focus now just changes the selected cell on the grid, losing the focus from a cell, does not make it unselected. This allowed me to connect the number_picked signal from the NumberPicker to call a method I added to the SudokuView class to change the value in a given cell, using the selected_x and selected_y properties of the SudokuView to tell which cell is selected.

The end result of this work is demoed in the following video.

Next, I think I need to talk to both my mentor, and Allan Day, regarding the exact desired implementation of the UI. What I have works, however I have not thought much about how it looks yet.

Saturday 2 June 2012

GSoC Update 1: New Sudoku UI

I began working today on writing the new UI (User Interface) for the Gnome Sudoku game, it follows the design set out here. It includes updating the applications menu to use the new style (using GMenu), and providing an interface that is more suitable to touch screen devices.

I was unable to work during the last few weeks because of University exams, now they are now finished. However I did do some work, submitting some small patches before the start of the coding period that:
There are some problems with the current code, I believe this is because of the modifications I have made to the menu, but not updated the toolbar to match. I believe the toolbar is going to be removed, so these will probably be fixed when this happens.

Depending on the feedback from my mentor, I will probably continue updating the UI, this is somewhat matching my proposal, but instead of the number picker popup, there is now a separate entry location to the top right.