Bug 261101 - Badly rendered combobox in Handbrake
Summary: Badly rendered combobox in Handbrake
Status: CLOSED FIXED
Alias: None
Product: Oxygen
Classification: Plasma
Component: gtk2-engine (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-23 21:31 UTC by Craig Drummond
Modified: 2011-07-29 23:36 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of HandBrake (73.32 KB, image/png)
2010-12-23 21:31 UTC, Craig Drummond
Details
"flat" GtkComboBox (19.09 KB, image/png)
2010-12-24 17:41 UTC, Hugo Pereira Da Costa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Drummond 2010-12-23 21:31:22 UTC
Created attachment 55193 [details]
Screenshot of HandBrake

Version:           unspecified (using KDE 4.4.6) 
OS:                Linux

The title selector combo in HandBrake's Gtk2 GUI is not rendered correctly. Looks as if only the part with the arrow is actually drawn.

Reproducible: Always

Steps to Reproduce:
Start the application!
Comment 1 Hugo Pereira Da Costa 2010-12-24 13:40:20 UTC
Can reproduce. Will have a look. Likely some custom painting that conflicts with ours. mmmm
Comment 2 Hugo Pereira Da Costa 2010-12-24 15:32:31 UTC
Looking into the code.

This is because this particular combobox, unlike others has its property "has-frame" set to false.

We can either
1/ use a special rendering for such comboboxes (basically: also render the arrow as flat, with highlight on hover
2/ force the has-frame property to true.

Ruslan ? Cedric ? Opinion ? 
"From the book", one should use 1/ 

Besides, I'm not sure 2/ is actually doable, though I will give it a shot.
Comment 3 Ruslan Kabatsayev 2010-12-24 16:20:28 UTC
> 1/ use a special rendering for such comboboxes (basically: also render the
arrow as flat, with highlight on hover

I like this idea. In fact, we could make highlight and pressed state look like no-relief/toolbar button highlight&press, i.e. slit and hole, instead of usual slab.
Comment 4 Hugo Pereira Da Costa 2010-12-24 17:23:45 UTC
@Ruslan
I like the idea too, (and in fact, Qt has a similar feature), but that wont be possible (I think). Basically, setting "has-frame" to false on the GtkComboBox results in the GtkFrame (that we use for painting about the GtkCellView) is not created at all. Since we can't paint anything ourselves in the GtkCellView, this means that there can be no feeback at all on the text part of the combobox.

This leaves the arrow. We can either render it as you suggest (like in a toolbar), but I believe it might look strange (since it would also glow on hover), or like a "scrollbar-like" type of arrows: no frame, glow on hover. 

I would rather vote for the second, but am open for discussion. What do you think ?
Comment 5 Ruslan Kabatsayev 2010-12-24 17:35:03 UTC
Hmm... that's bad that we can't draw the text part... but i would then suggest drawing the arrow button as a no-relief button. Other way, we could force has-frame property, but still draw the combobox as is intended by the app creator, i.e. as i suggested before.
Comment 6 Hugo Pereira Da Costa 2010-12-24 17:39:34 UTC
I tried to force the has-frame, using g_object_set_property(...) but without success so far. Meaning: the property is set but nothing happens: apparently this only works if has-frame is set before the widget is realized.

Truth is: everything flat (which I tested locally), does not look really good.
I wonder why the app set that flag in the first place; which QtCurve does not honour anyway, without problem, since appears-as-list is not used by GtkComboBox.

I'll send screenshot.
Comment 7 Hugo Pereira Da Costa 2010-12-24 17:41:33 UTC
Created attachment 55211 [details]
"flat" GtkComboBox

The "no title" and arrow correspond to the flat combobox.
Comment 8 Ruslan Kabatsayev 2010-12-24 18:13:08 UTC
Anyway, drawing it flat seems to be the only really correct solution.
The fact that this doesn't look too good should be directed upstream (if most themes don't honor this flag, why set it?).
Comment 9 Hugo Pereira Da Costa 2010-12-24 18:20:03 UTC
Agreed. Will do as you suggest. Use flat-like button.
Comment 10 Hugo Pereira Da Costa 2010-12-24 18:32:23 UTC
commit 08ab484991419835d7a8b489f52c1f1eb227b930
branch 1.0
Author: Hugo Pereira Da Costa <hugo@oxygen-icons.org>
Date:   Fri Dec 24 16:03:55 2010 +0100

    Added gtk_combobox_has_frame utility function.
    CCBUG: 261101

diff --git a/src/oxygengtkutils.cpp b/src/oxygengtkutils.cpp
index a49f653..a59003d 100644
--- a/src/oxygengtkutils.cpp
+++ b/src/oxygengtkutils.cpp
@@ -372,6 +372,17 @@ namespace Oxygen
     }
 
     //________________________________________________________
+    bool Gtk::gtk_combobox_has_frame( GtkWidget* widget )
+    {
+
+        GValue val = { 0, };
+        g_value_init(&val, G_TYPE_BOOLEAN);
+        g_object_get_property( G_OBJECT( widget ), "has-frame", &val );
+        return (bool) g_value_get_boolean( &val );
+
+    }
+
+    //________________________________________________________
     bool Gtk::gtk_combobox_is_tree_view( GtkWidget* widget )
     {
         // check types
diff --git a/src/oxygengtkutils.h b/src/oxygengtkutils.h
index 7f2ae81..ea04bb7 100644
--- a/src/oxygengtkutils.h
+++ b/src/oxygengtkutils.h
@@ -148,6 +148,9 @@ namespace Oxygen
         //!@name combobox utilities
         //@{
 
+        //! returns true if combobox has frame
+        bool gtk_combobox_has_frame( GtkWidget* );
+
         //! true if widget is the treeview of a combobox
         bool gtk_combobox_is_tree_view( GtkWidget* );
Comment 11 Hugo Pereira Da Costa 2010-12-24 18:32:23 UTC
commit b071eec8f25014fafacdcabffb02a2305ff78507
branch 1.0
Author: Hugo Pereira Da Costa <hugo@oxygen-icons.org>
Date:   Fri Dec 24 18:12:45 2010 +0100

    Render arrow of flat (has_frame == false) combobox as toolbutton.
    CCBUG: 261101

diff --git a/src/oxygenstylewrapper.cpp b/src/oxygenstylewrapper.cpp
index 57e2584..917c944 100644
--- a/src/oxygenstylewrapper.cpp
+++ b/src/oxygenstylewrapper.cpp
@@ -619,11 +619,22 @@ namespace Oxygen
                 Style::instance().animations().comboBoxEngine().initializeCellLayout( parent );
                 Style::instance().animations().comboBoxEngine().setButton( parent, widget );
                 Style::instance().animations().comboBoxEngine().setButtonFocus( parent, options & Focus );
-                if( Style::instance().animations().comboBoxEngine().hovered( parent ) ) options |= Hover;
 
-                TileSet::Tiles tiles( TileSet::Ring );
-                tiles &= ~TileSet::Left;
-                Style::instance().renderButtonSlab( window, clipRect, x-7, y, w+7, h, options, tiles );
+                if( Gtk::gtk_combobox_has_frame( parent ) )
+                {
+                    if( Style::instance().animations().comboBoxEngine().hovered( parent ) ) options |= Hover;
+
+                    TileSet::Tiles tiles( TileSet::Ring );
+                    tiles &= ~TileSet::Left;
+                    Style::instance().renderButtonSlab( window, clipRect, x-7, y, w+7, h, options, tiles );
+
+                } else {
+
+                    options |= Flat;
+                    if( Style::instance().animations().comboBoxEngine().hovered( parent ) ) options |= Hover;
+                    Style::instance().renderButtonSlab( window, clipRect, x-1, y, w, h, options );
+
+                }
 
             #if GTK_CHECK_VERSION(2, 20, 0)
             } else if( GTK_IS_TOOL_ITEM_GROUP( widget ) ) {
@@ -1585,6 +1596,7 @@ namespace Oxygen
         // Arrows which are active are painted as hovered
         if( state == GTK_STATE_ACTIVE ) options |= Hover;
 
+        GtkWidget* parent( 0L );
         if( d.isTearOffMenuItem() )
         {
             if( widget && gtk_widget_get_state( widget ) != GTK_STATE_PRELIGHT && GTK_IS_MENU( gtk_widget_get_parent( widget ) ) && GTK_MENU( gtk_widget_get_parent( widget ) )->torn_off )
@@ -1634,7 +1646,7 @@ namespace Oxygen
 
             if( state != GTK_STATE_INSENSITIVE ) options &= ~Contrast;
 
-        } else if( Gtk::gtk_parent_combobox( widget ) ) {
+        } else if( ( parent = Gtk::gtk_parent_combobox( widget ) ) ) {
 
             options &= ~( Focus|Hover );
             y+= 1;
Comment 12 Hugo Pereira Da Costa 2010-12-24 18:36:14 UTC
Closing.
Decided to render the arrow as a toolbutton.
Not much more we can do. Use of a flat combobox is IMO not justified here, but that should be fixed by the application

in HandBrake/gtk/src/ghb.ui:
750d749
<                                     <property name="has_frame">False</property>