Re: GtkTreeView Refactoring Considerations [was Re: Private types inside GTK+]



On Sun, Oct 31, 2010 at 3:17 PM, Tristan Van Berkom
<tristanvb openismus com> wrote:
> Whew, ok I implemented GtkCellArea->render for GtkCellAreaBox for the
> most part, however I'm still missing the GtkCellRendererState flags ;-)
>
> So for this part I was thinking it might make more sense to create
> a new GtkCellAreaStateFlags type with just per-row states (and add that
> as an argument to GtkCellArea->render() and also GtkCellArea->event())

Most of the states in GtkCellRendererState are actually per-row states
already (selected, focused, etc.) and are toggled by GtkTreeView and
GtkTreeViewColumn when rendering the cells.  Though one state,
"sorted", is obviously per-column.  Did you mean to have a new
GtkCellAreaStateFlags that will have flags per *cell area* and thus
per *column*?

> and then somehow tidy up the code that in GtkTreeViewColumn is
> currently:
>
>  _gtk_tree_view_column_count_special_cells (tree_column)

This function is part of implementing the key navigation behavior.  A
"special" cell is one that is editable or activatable.  The rule is
that if there's a single special cell in a column, a focus rectangle
is drawn spanning all cells in that column.  If there is more than one
than the focus rectangle will be drawn around single cells.  This
works fine in many cases, but can of course be awkward in a few
situations, so perhaps we want to make this configurable in the
future.  The same likely holds for a situation where you have a check
box cell renderer and text cell renderer next to each other in a
column:

   [x] [my label in a text renderer]

Akin to a GtkCheckButton, you would want the check to toggle when the
text renderer is clicked.  And it would be natural if the focus
rectangle spans the check box and the text renderer. But in other
situations, with different cell renderers, you do not want this.  This
is also something to think about and improve for the future.

I think the GtkCellArea will also allow us to get rid of
_gtk_tree_view_column_get_cell_at_pos(), which I have never really
liked for some reason.


> For focus handling and such I guess it will probably make sense to add:
>
>  GtkCellArea->set/get_focus_cell()

That could work if there is the possibility to set focus around all
cells in the GtkCellArea as well and to disable focus for a given row
(if there are no "special" cells in a row, then a focus rectangle is
drawn around the entire row).

> Which is currently missing... then I suppose from ->event() if the row
> for which an event is handled itself has focus, it will make sense to
> activate the focused cell.

I would follow the way GtkTreeViewColumn is currently handling this
for now.  Because when clicking on a check box renderer on a row that
does not have focus (and focus in tree view only really plays when you
are using key navigation), the click should likely activate the check
box renderer anyway.



regards,

-kris.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]