Commit Graph

71 Commits

Author SHA1 Message Date
Cosimo Cecchi
f2685ddf5e colorswatch: don't apply padding twice
Instead of taking the border and manually removing it from the
allocation, render our background over all the border allocation box, as
that's more correct and does not take padding into account twice.
2016-01-08 14:58:25 -08:00
Matthias Clasen
5b3001b6d5 colorswatch: Fix the overlay
I misunderstood what the overlay is good for: We need to allocate
it the full size of the widget. since we are using it to render
a background gradient *over* the application-rendered color.

At the same time, save some 100 lines of code by using an icon
helper as gadget, instead of handling the icon manually.
2016-01-07 19:20:55 -05:00
Matthias Clasen
1b3bb244b6 color swatch: Fix up rendering
gtk_render_content_path is expecting the full box dimensions,
not just the content area. So, add the border before calling it.

Note it is still possible to have some separation between the
color and the border, by setting padding.
2016-01-07 18:38:31 -05:00
Matthias Clasen
8ecba89991 color swatch: Remove a stray frame
When using a gadget, the border is free, no need to call
gtk_render_frame ourselves.
2016-01-07 14:08:26 -05:00
Matthias Clasen
c376e82702 colorswatch: Convert to gadgets
Use gadgets for the widget and the overlay.
2015-12-15 08:41:16 -05:00
Benjamin Otte
3513e5e87b Chain up in state_flags_changed
When introducing handlers for state_flags_changed in the node
transitions, chaining up was forgotten.
2015-12-02 04:36:31 +01:00
Timm Bäder
c28be30ac1 colorswatch: Don't pass _GENERIC_FALLBACK to API that doesn't support it 2015-11-09 17:13:19 +01:00
Matthias Clasen
dfedda3dee color editor: Redo the non-activatable color swatch
Use a .activatable style class on the color swatch and tie the
hover effect to it. The color editor simply removes this class
now to get an inert color swatch.

This is more flexible and lets us avoid referring to the
GtkColorEditor type in the theme.
2015-10-30 22:19:07 -04:00
Matthias Clasen
5ec9b330b3 swatch fixup 2015-10-30 21:43:50 -04:00
Matthias Clasen
e5d3c8dbae color swatch: Convert to CSS nodes
Convert GtkColorSwatch to use the two elements colorswatch and
image.
2015-10-30 21:29:46 -04:00
Matthias Clasen
d3475f7a72 color chooser: Render icons sharp at scale 2
We need to load the icons at the right scale, and render them
to a surface with the right scale too.

https://bugzilla.gnome.org/show_bug.cgi?id=756195
2015-10-07 23:19:32 -04:00
Matthias Clasen
66f0bdee0a Intern all signal names beforehand
This avoids pointless allocations
2015-09-12 12:50:39 -04:00
Matthias Clasen
e34ab3561f color chooser: Use a popover for the context menu
It works just as well here as it does in the file chooser, and
this lets us unify the right-click and long-press behavior a bit.
We used to switch directly to the editor on long-press, now we
can show the popover, just as we do on right-click.
2015-08-04 22:59:58 -04:00
Matthias Clasen
98a3fac6ab Add a way to avoid menu on color swatches 2015-06-13 21:56:41 -04:00
Matthias Clasen
e1ff15549b GtkColorSwatch: Avoid style context underflow
The last change accidentally removed the later restore, and
left the earlier, so we ended up with a restore-save sequence.
Thankfully, GtkStyleContext warns about this.
2014-10-12 18:15:23 -04:00
Benjamin Otte
0a31609201 colorswatch: Remove unneeded save/restore
for both style context and cairo context.
2014-10-12 04:16:44 +02:00
Benjamin Otte
e82093fc14 colorswatch: Use a better name for the overlay
Name it .overlay and not .image
2014-10-08 13:20:03 +02:00
Benjamin Otte
6b0d389bfd colorswatch: Draw the image overlay over the whole widget 2014-10-08 13:17:55 +02:00
Benjamin Otte
c39bd623f6 colorswatch: Render background properly
We want to render a background *and* the current color (if there is
one).

This also adds a custom function gtk_render_add_content_path() which
adds the path of the current content area to a cairo_t.
2014-10-08 05:20:30 +02:00
Benjamin Otte
7295c8f12b colorswatch: Remove an unused variable 2014-10-08 05:20:30 +02:00
Benjamin Otte
100623e455 colorswatch: Render focus with gtk_render_focus() 2014-10-08 05:20:30 +02:00
Benjamin Otte
be19ee29c2 colorswatch: Simplify drawing code
This adds a CSS box (complete with padding and border) for the icon. The
box is even drawn when no icon is present. Use the ".image" as the style
class here instead of -active-color-badge.

Use this box to draw the circle around the selection icon in Adwaita.
2014-10-08 05:20:30 +02:00
Benjamin Otte
91467a45fc stylecontext: Deprecate functions
- gtk_style_context_get_background_color()
- gtk_style_context_get_border_color()

Those functions shouldn't be used anymore, because they don't represent
anything from the CSS styling we support. The background color often
isn't used due to background images and there are actually 4 different
border colors (1 for each side) - if there isn't also a border image in
use.
2014-10-03 06:18:06 +02:00
Benjamin Otte
b5a8b7ef3b widget: Make _gtk_set_simple_clip() take an optional content clip 2014-08-21 00:54:07 +02:00
Benjamin Otte
5e8d3d533f themingbackground: Remove initializer that takes a GtkThemingEngine
With the unification to use style contexts everywhere, make that
initializer the only one to use.

Also rename it appropriately.
2014-08-16 19:39:44 +02:00
Carlos Garnacho
1c23ab5a7e colorswatch: Update to new GtkGestureSingle/GtkEventController defaults
GtkGestureSingle::button is set to 0 on the multipress gesture, as several
buttons are managed by that gesture. Also avoid some extra lines of code
setting what nowadays are default values.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:49:40 +02:00
Matthias Clasen
a9201b8379 GtkProgressBar: Add style classes for edges
Add left/right/top/bottom style classes according to which edge(s)
of the progressbar the progress is adjacent to. Only for a fraction
of 1.0 will we set more than one edge.
2014-07-19 00:40:09 -04:00
Matthias Clasen
b68a28fbb0 GtkColorSwatch: Respect an explicitly set size
This will let us use a suitably sized color swatch in the color
button.
2014-07-09 20:44:06 -04:00
Benjamin Otte
fba90d4c65 colorswatch: handle clip for box-shadow 2014-06-16 18:43:49 +02:00
Carlos Garnacho
907e9f1946 gtk: Update GtkGesture users to the GtkPropagationPhase semantics change
Mainly doing s/TARGET/BUBBLE/ on the fully ported widgets, but GtkTreeView
where the double click handler has moved to GTK_PHASE_TARGET so it runs
parallelly to the still existing event handlers.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
a4a122c8e8 colorswatch: Set gestures in GTK_PHASE_TARGET
That's the right phase for gestures replacing entirely event handlers.
2014-05-23 19:54:33 +02:00
Matthias Clasen
6a290bdecb GtkColorSwatch: Use gesture for button events too 2014-05-23 19:54:30 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
bd722499dc colorswatch: Replace GtkPressAndHold
GtkGestureLongPress and GtkGestureMultiPress are both used
to replace it.
2014-05-23 19:54:26 +02:00
Matthias Clasen
624ec0fb7d Add a style class for context menus
Attached widgets inherit from the style of the widget they are
attached to. This can sometimes have unintended consequences,
like a context menu in the main view of gedit inheriting the font
that is configured for documents, or the context menu of the preview
in the font chooser coming up with humongous font size.

To fix this problem, we introduce a context menu style class
and use it for all menus that are used like that. The theme
can then set a font for this style class.

https://bugzilla.gnome.org/show_bug.cgi?id=697127
2013-08-18 13:46:48 -04:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Matthias Clasen
98801b07b4 GtkColorChooser: Fix selection of colors
Prevent the new window dragging code from interfering with
selection of colors on button release, by handling button
presses we care about instead of letting them bubble up to
the window.
Partial fix for
https://bugzilla.gnome.org/show_bug.cgi?id=695493
2013-03-20 22:21:16 -04:00
Jasper St. Pierre
367364a8e1 Fix deprecations for GtkIconInfo 2013-02-15 19:48:56 -05:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Matthias Clasen
38963870eb Rename gtkcolorswatchaccessible.h
Call it gtkcolorswatchaccessibleprivate.h. This matches what we're
doing for non-public widget headers in gtk/.
2012-12-27 12:11:12 -05:00
Cosimo Cecchi
214809ece2 colorswatch: don't use the clip box directly
We can render our checkboard pattern on the padding box instead. This is
in preparation for GtkThemingBackground supporting multiple layers.
2012-05-15 13:24:40 -04:00
Matthias Clasen
912ad3b698 Break out press-and-hold code as its own object
https://bugzilla.gnome.org/show_bug.cgi?id=671057
2012-03-04 00:29:04 -05:00
Matthias Clasen
b43d00fa2a colorswatch: Support touch events
Support long press for customizing, and short press for
selecting/activating. This is simpler than the generic
press-and-hold support in the multitouch branch; we don't
display any feedback, and the timeout is currently hardcoded
to 1 second.
2012-03-03 01:48:55 -05:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Cosimo Cecchi
03fdaca187 color-swatch: set/unset prelight state flag on enter/leave events
Allows themes to set a different style on prelight.
2012-02-21 18:17:26 +01:00
Cosimo Cecchi
9160a68c7f color-swatch: make this a no-window widget
Instead of having an input/output GdkWindow, make the widget no-window,
and use a separate input-only window for events, and paint on the parent
window directly.
2012-02-20 13:49:04 +01:00
Cosimo Cecchi
8dd4a0adf1 color-swatch: don't render our active badge if background-image is set
If the color active swatch has been set a background image from the
theme, use it as an asset, and do not draw our custom thing.
2012-02-18 09:55:45 +01:00
Cosimo Cecchi
dcec8dfdde color-swatch: render a background if the swatch doesn't have a color
We still want to call into the background rendering code, to draw the
default background.
2012-02-18 09:55:45 +01:00
Cosimo Cecchi
8e85702dca color-swatch: derive directly from GtkWidget
Instead of GtkDrawingArea, since that calls in realize
gtk_style_context_set_background(). We don't want that to happen, given
that we do all the painting ourselves in _draw().
2012-02-18 09:55:45 +01:00