Editing Using Fremantle widgets
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
- | This document should help developers to port the user interface from | + | THIS IS STILL WORK IN PROGRESS. TOMORROW I´LL ADD SCREENSHOTS. THAT SHOULD MAKE MANY ASPECTS CLEARER! |
- | + | ||
- | + | ||
- | + | This document should help developers to port the user interface from Diablo to Fremantle. The official hildon documentation and the HIG are still quiet thin. Therefore the document mirrors what was discussed on the mailing lists, forum and bug reports. It is based completely on the Fremantle Beta SDK which is the most recent SDK at the moment. | |
Please feel totally free to add/update/change/remix this document. Many aspects are currently not discussed here but will hopefully be added by you! | Please feel totally free to add/update/change/remix this document. Many aspects are currently not discussed here but will hopefully be added by you! | ||
- | Note: The casts of all code examples | + | Note: The casts of all code examples haven been removed for better readability. |
- | |||
+ | = Toggle Buttons Vs. Radio Buttons = | ||
The use of radio buttons in Fremantle is discouraged because they don't fit the visual style quite well. Instead you should use toggle buttons. | The use of radio buttons in Fremantle is discouraged because they don't fit the visual style quite well. Instead you should use toggle buttons. | ||
Line 15: | Line 15: | ||
Example: | Example: | ||
- | < | + | <pre> |
GtkWidget *b1 = gtk_radio_button_new_with_label("One"); | GtkWidget *b1 = gtk_radio_button_new_with_label("One"); | ||
GtkWidget *b2 = gtk_radio_button_new_with_label_from_widget(b1, "Two"); | GtkWidget *b2 = gtk_radio_button_new_with_label_from_widget(b1, "Two"); | ||
gtk_toggle_button_set_mode(b1, FALSE); | gtk_toggle_button_set_mode(b1, FALSE); | ||
gtk_toggle_button_set_mode(b2, FALSE); | gtk_toggle_button_set_mode(b2, FALSE); | ||
- | </ | + | </pre> |
+ | |||
[[Image:Fle_tut_radio_buttons.jpg|frame|Above you see how radio buttons are displayed in Fremantle. There is a bug in this screenshot, normally of course only one of the four options would be selected.]] | [[Image:Fle_tut_radio_buttons.jpg|frame|Above you see how radio buttons are displayed in Fremantle. There is a bug in this screenshot, normally of course only one of the four options would be selected.]] | ||
Line 26: | Line 27: | ||
[[image:Fle_tut_toggle_buttons.jpg|frame|Here you can see four radio buttons which are displayed as toggle buttons using the <code>gtk_toggle_button_set_mode()</code> function mentioned above.]] | [[image:Fle_tut_toggle_buttons.jpg|frame|Here you can see four radio buttons which are displayed as toggle buttons using the <code>gtk_toggle_button_set_mode()</code> function mentioned above.]] | ||
- | + | = Window Menu = | |
- | + | In Fremantle it is not encouraged to use <code>GtkMenu</code> as window menu anymore. Instead you should use the <code>HildonAppMenu</code>. This new menu is really different from the old one so it´s worth taking a closer look. Here are the main features of the HildonAppMenu. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | In Fremantle it is not encouraged to use <code>GtkMenu</code> as window menu anymore. Instead you should use the <code>HildonAppMenu</code>. This new menu is really different from the old one so it´s worth taking a closer look. Here are the main features of the | + | |
* It has big / finger friendly menu items. | * It has big / finger friendly menu items. | ||
* It holds a maximum of ten menu items. | * It holds a maximum of ten menu items. | ||
Line 60: | Line 36: | ||
* In portrait mode the menu items are automatically displayed in one row. | * In portrait mode the menu items are automatically displayed in one row. | ||
* There are no separators, so you cannot group your menu items. | * There are no separators, so you cannot group your menu items. | ||
- | * The menu items are | + | * The menu items are GtkButtons and not GtkMenuItems. |
- | The | + | The HildonAppMenu is meant to be displayed when the user clicks the title bar of the window, but it is possible to have several other HildonAppMenus in your application and activate them for example on button press. |
- | As you can see the | + | As you can see the HildonAppMenu differs quite a lot from the old GtkMenu. The main difference is surely that you cannot have more then 10 menu items |
+ | inside the new menu. The Hildon HIG gives an overview on how to deal with that. | ||
- | [[Image:Fle_tut_app_menu_with_filters.jpg|frame|A | + | [[Image:Fle_tut_app_menu_with_filters.jpg|frame|A HildonAppMenu with two filters at the top and four buttons]] |
== Using HildonAppMenu with GtkActions == | == Using HildonAppMenu with GtkActions == | ||
- | + | As said earlier, the menu items are no GtkMenuItems anymore but instead they are normal GtkButtons. So you´re using GtkActions in your code, you´ll probably miss a replacement for <code>gtk_action_create_menu_item()</code>. There is no direct replacement, instead you just have to use standard gtk functions to connect the button as a proxy to the action. Here is an example: | |
- | As said earlier, the menu items are | + | <pre> |
- | < | + | |
GtkButton *menu_item = gtk_button_new(); | GtkButton *menu_item = gtk_button_new(); | ||
gtk_action_connect_proxy(action, menu_item); | gtk_action_connect_proxy(action, menu_item); | ||
- | </ | + | </pre> |
- | This is also possible with <code>GtkToggleAction</code> and <code>GtkRadioAction</code>. But remember that your | + | This is also possible with <code>GtkToggleAction</code> and <code>GtkRadioAction</code>. But remember that your GtkRadioButtons should look like GtkToggleButtons as mentioned above. So a complete example for a HildonAppMenu that should display three GtkRadioActions would look like this: |
- | < | + | <pre> |
GSList *group = NULL; | GSList *group = NULL; | ||
GtkAction *a1, *a2, *a3; | GtkAction *a1, *a2, *a3; | ||
Line 115: | Line 91: | ||
hildon_app_menu_append(menu, b2); | hildon_app_menu_append(menu, b2); | ||
hildon_app_menu_append(menu, b3); | hildon_app_menu_append(menu, b3); | ||
- | </ | + | </pre> |
- | + | ||
- | + | ||
+ | = Finger Friendly GtkTreeView = | ||
To get a finger friendly <code>GtkTreeView</code> it´s not enough to call <code>hildon_gtk_tree_view_new()</code> instead of <code>gtk_tree_view_new()</code> but you also have to put the tree view inside a <code>HildonPannableArea</code> to get finger friendly sizes. If you have your tree view inside a <code>GtkScrolledWindow</code> it will be displayed with stylus-style (like in Diablo). | To get a finger friendly <code>GtkTreeView</code> it´s not enough to call <code>hildon_gtk_tree_view_new()</code> instead of <code>gtk_tree_view_new()</code> but you also have to put the tree view inside a <code>HildonPannableArea</code> to get finger friendly sizes. If you have your tree view inside a <code>GtkScrolledWindow</code> it will be displayed with stylus-style (like in Diablo). | ||
- | Also if you´re displaying icons in your tree view you probably should use the | + | Also if you´re displaying icons in your tree view you probably should use the 40x40 pixel version for Fremantle if you used the 26x26 pixel version in Diablo. |
- | + | ||
- | + | ||
+ | == Normal Vs. Edit Mode == | ||
There are now two different modes for the tree view. Those modes affect how the rows in a tree view react to finger taps. | There are now two different modes for the tree view. Those modes affect how the rows in a tree view react to finger taps. | ||
Line 131: | Line 105: | ||
If the user should be able to select or edit rows then you should use <code>HILDON_UI_MODE_EDIT</code>. | If the user should be able to select or edit rows then you should use <code>HILDON_UI_MODE_EDIT</code>. | ||
- | + | == Using Filters For Sorting == | |
- | + | ||
Most of you probably are using the tree view with a header row that displays column labels. Often this header row can also be used to sort the columns ascending or descending. If you're designing a finger friendly UI you will usually have a very limited number of visible columns - probably only one or two. In this case the column content is often self explanatory and the header row is only there for sorting. If that's the case for your UI, you might want to remove the header column completely and replace it with so called filters on the HildonAppMenu. | Most of you probably are using the tree view with a header row that displays column labels. Often this header row can also be used to sort the columns ascending or descending. If you're designing a finger friendly UI you will usually have a very limited number of visible columns - probably only one or two. In this case the column content is often self explanatory and the header row is only there for sorting. If that's the case for your UI, you might want to remove the header column completely and replace it with so called filters on the HildonAppMenu. | ||
According to the HIG filters are meant to change how data is presented, but it should not affect the amount of data that is displayed. Sorting a tree view would be a possible use case. To do this, just have a look at the example: | According to the HIG filters are meant to change how data is presented, but it should not affect the amount of data that is displayed. Sorting a tree view would be a possible use case. To do this, just have a look at the example: | ||
- | < | + | <pre> |
/* Remove the header row */ | /* Remove the header row */ | ||
gtk_tree_view_set_headers_visible(view, FALSE); | gtk_tree_view_set_headers_visible(view, FALSE); | ||
Line 152: | Line 125: | ||
hildon_app_menu_add_filter(menu, b1); | hildon_app_menu_add_filter(menu, b1); | ||
hildon_app_menu_add_filter(menu, b2); | hildon_app_menu_add_filter(menu, b2); | ||
- | </ | + | </pre> |
That is all for showing them on the window menu. Now only a callback is needed which gets activated whenever the user selects a filter. An example implementation might look like that: | That is all for showing them on the window menu. Now only a callback is needed which gets activated whenever the user selects a filter. An example implementation might look like that: | ||
- | < | + | <pre> |
void on_sort_filter_clicked(GtkToggleButton *button, GtkTreeSortable *sortable) | void on_sort_filter_clicked(GtkToggleButton *button, GtkTreeSortable *sortable) | ||
{ | { | ||
Line 162: | Line 135: | ||
} | } | ||
} | } | ||
- | </ | + | </pre> |
You can add as many filters as you like, but they will be displayed all in one row and there is no possibility to add another filter row. This means you have to select carefully what to put there and also have a look at the length of the strings. | You can add as many filters as you like, but they will be displayed all in one row and there is no possibility to add another filter row. This means you have to select carefully what to put there and also have a look at the length of the strings. | ||
Line 173: | Line 146: | ||
* Sort by title (which sorts by title ascending - A before B) | * Sort by title (which sorts by title ascending - A before B) | ||
* Sort by date (which sorts by date descending - newest on top) | * Sort by date (which sorts by date descending - newest on top) | ||
- | + | Limiting options here is even more important if you're planning to use the portrait mode, because there you'll have even less space in that row. | |
[[Image:Fle_tut_tree_view.jpg|frame|A tree view without the title row. Sorting is now done with filters]] | [[Image:Fle_tut_tree_view.jpg|frame|A tree view without the title row. Sorting is now done with filters]] | ||
Line 180: | Line 153: | ||
[[Image:Fle_tut_tree_view_filter.jpg|frame|When clicking the title bar two filters are shown which let the user sort the tree view]] | [[Image:Fle_tut_tree_view_filter.jpg|frame|When clicking the title bar two filters are shown which let the user sort the tree view]] | ||
- | + | = Context Menus = | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
To display finger friendly context menues there is a hildon helper function called <code>hildon_gtk_menu_new()</code>. Just call this instead of <code>gtk_menu_new()</code> and you´re done. | To display finger friendly context menues there is a hildon helper function called <code>hildon_gtk_menu_new()</code>. Just call this instead of <code>gtk_menu_new()</code> and you´re done. | ||
Example: | Example: | ||
- | < | + | <pre> |
GtkWidget *menu = hildon_gtk_menu_new(); | GtkWidget *menu = hildon_gtk_menu_new(); | ||
Line 199: | Line 168: | ||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, | ||
gtk_get_current_event_time()); | gtk_get_current_event_time()); | ||
- | </ | + | </pre> |
- | ''Note that in the Beta SDK there is a bug. If you´re using <code> | + | ''Note that in the Beta SDK there is a bug. If you´re using <code>GtkImageMenuItems</code> instead of <code>GtkMenuItems</code> the menu will have stylus-style. This bug is already fixed and a work around is available here: https://bugs.maemo.org/show_bug.cgi?id=4654 .'' |
[[Image:Fle_tut_context_menu.jpg|frame|Finger friendly context menu which is showing four stock items]] | [[Image:Fle_tut_context_menu.jpg|frame|Finger friendly context menu which is showing four stock items]] | ||
- | + | = Panning = | |
- | + | ||
Almost all of you will know the problems with scrollbars in Diablo. You can have small scrollbars which are not finger friendly or you can have large scrollbars which are using a lot of screen space and look ugly. | Almost all of you will know the problems with scrollbars in Diablo. You can have small scrollbars which are not finger friendly or you can have large scrollbars which are using a lot of screen space and look ugly. | ||
Line 211: | Line 179: | ||
<code>HildonPannableArea</code> can be used as a replacement for <code>GtkScrolledWindow</code> but there are things you have to keep in mind when doing so. | <code>HildonPannableArea</code> can be used as a replacement for <code>GtkScrolledWindow</code> but there are things you have to keep in mind when doing so. | ||
- | + | == GtkTextView Inside HildonPannableArea == | |
- | + | Panning does not work with a <code>GtkTextView</code>. Instead you can use a <HildonTextView> which is a drop in replacement. The advantage is, that then panning is possible. The disadvantage is that selecting text is not possible anymore. The discussion about this is here: https://bugs.maemo.org/show_bug.cgi?id=4619 | |
- | Panning does not work with a <code>GtkTextView</code>. Instead you can use a < | + | |
- | + | ||
- | + | ||
- | When using <code>GtkHtml</code> inside a <code>HildonPannableArea</code> the panning is not smooth. The problem seems to be that | + | == GtkHtml Inside HildonPannableArea == |
+ | When using <code>GtkHtml</code> inside a <code>HildonPannableArea</code> the panning is not smooth. The problem seems to be that GtkHtml provides some build in support for panning and that it conflicts with the panning offered by Hildon. See this bug report here: https://bugs.maemo.org/show_bug.cgi?id=4631 | ||
- | |||
+ | = Portrait Mode = | ||
If your application should work in portrait mode you probably have to change the UI quite a bit. There are a couple of problems you'll might have: | If your application should work in portrait mode you probably have to change the UI quite a bit. There are a couple of problems you'll might have: | ||
* The toolbar is not wide enough to hold all items anymore. | * The toolbar is not wide enough to hold all items anymore. | ||
* The columns of your tree view get too small. | * The columns of your tree view get too small. | ||
- | * You cannot enter text because there´s no onscreen keyboard. | + | * You cannot enter text because there´s no onscreen keyboard. |
* Dialogs are not shown correctly (see https://bugs.maemo.org/show_bug.cgi?id=4618 ). | * Dialogs are not shown correctly (see https://bugs.maemo.org/show_bug.cgi?id=4618 ). | ||
* Probably more... | * Probably more... | ||
Line 230: | Line 196: | ||
This means you have to listen to changes in the orientation and hide/show/change widgets to make the UI functional in portrait mode. | This means you have to listen to changes in the orientation and hide/show/change widgets to make the UI functional in portrait mode. | ||
- | + | == Listening To Orientation Changes == | |
- | + | There is no Fremantle specific API for that (yet?), but you can do for example the following: | |
- | + | <pre> | |
- | + | ||
- | + | ||
- | + | ||
- | < | + | |
gboolean is_portrait() | gboolean is_portrait() | ||
{ | { | ||
Line 259: | Line 221: | ||
} | } | ||
} | } | ||
- | </ | + | </pre> |
- | + | ||
Then inside your UI code you should listen to the <code>size-changed</code> signal of <code>GdkScreen</code>. For example: | Then inside your UI code you should listen to the <code>size-changed</code> signal of <code>GdkScreen</code>. For example: | ||
- | < | + | <pre> |
g_signal_connect(screen, "size-changed", on_orientation_changed, widget); | g_signal_connect(screen, "size-changed", on_orientation_changed, widget); | ||
- | </ | + | </pre> |
- | + | ||
- | + | ||
+ | == Testing Orientation Changes In Scratchbox == | ||
For testing your code you can execute the following commands outside scratchbox: | For testing your code you can execute the following commands outside scratchbox: | ||
<pre> | <pre> | ||
Line 274: | Line 234: | ||
</pre> | </pre> | ||
- | == | + | == Marking Your App As Portrait Capable == |
- | + | If your application should automatically rotate when the device is rotated you have to explicitly mark your application as portrait capable. This is not yet implemented in the current beta SDK, but there will be one enum and a function as shown below: | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | This | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
<pre> | <pre> | ||
- | + | typedef enum { | |
- | < | + | HILDON_PORTRAIT_MODE_REQUEST = 1 << 0, |
+ | HILDON_PORTRAIT_MODE_SUPPORT = 1 << 1 | ||
+ | } HildonPortraitFlags; | ||
- | + | hildon_gtk_window_set_portrait_flags(GtkWindow *window, HildonPortraitFlags flags); | |
- | + | ||
- | + | ||
</pre> | </pre> | ||
+ | The support flag tells Hildon that it is allowed to rotate your application. The request flag directly puts your application into portrait mode. It´s important to note that all visible windows must support portrait mode, otherwise the screen is not rotated. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
+ | = References = | ||
In no particular order | In no particular order | ||
* http://maemo.org/api_refs/5.0/beta/tutorial/html | * http://maemo.org/api_refs/5.0/beta/tutorial/html | ||
* http://maemo.org/api_refs/5.0/beta/hig/html | * http://maemo.org/api_refs/5.0/beta/hig/html | ||
+ | |||
* http://lists.maemo.org/pipermail//maemo-developers/2009-May/019368.html | * http://lists.maemo.org/pipermail//maemo-developers/2009-May/019368.html | ||
* http://lists.maemo.org/pipermail//maemo-developers/2009-May/019144.html | * http://lists.maemo.org/pipermail//maemo-developers/2009-May/019144.html | ||
* http://lists.maemo.org/pipermail//maemo-developers/2009-June/019426.html | * http://lists.maemo.org/pipermail//maemo-developers/2009-June/019426.html | ||
* http://lists.maemo.org/pipermail//maemo-developers/2009-June/019579.html | * http://lists.maemo.org/pipermail//maemo-developers/2009-June/019579.html | ||
- | + | ||
* https://bugs.maemo.org/show_bug.cgi?id=4617 | * https://bugs.maemo.org/show_bug.cgi?id=4617 | ||
* https://bugs.maemo.org/show_bug.cgi?id=4618 | * https://bugs.maemo.org/show_bug.cgi?id=4618 | ||
Line 513: | Line 264: | ||
* https://bugs.maemo.org/show_bug.cgi?id=4637 | * https://bugs.maemo.org/show_bug.cgi?id=4637 | ||
* https://bugs.maemo.org/show_bug.cgi?id=4648 | * https://bugs.maemo.org/show_bug.cgi?id=4648 | ||
- | |||
- | |||
- |
Learn more about Contributing to the wiki.