2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-02-03 20:10:23 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-02-03 20:10:23 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-02-03 20:10:23 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2002-02-03 20:10:23 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GIMP_STATUSBAR_H__
|
|
|
|
#define __GIMP_STATUSBAR_H__
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2008-05-24 04:38:52 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
/* maximal length of the format string for the cursor-coordinates */
|
|
|
|
#define CURSOR_FORMAT_LENGTH 32
|
|
|
|
|
|
|
|
|
|
|
|
#define GIMP_TYPE_STATUSBAR (gimp_statusbar_get_type ())
|
|
|
|
#define GIMP_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STATUSBAR, GimpStatusbar))
|
|
|
|
#define GIMP_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STATUSBAR, GimpStatusbarClass))
|
|
|
|
#define GIMP_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STATUSBAR))
|
|
|
|
#define GIMP_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STATUSBAR))
|
|
|
|
#define GIMP_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STATUSBAR, GimpStatusbarClass))
|
|
|
|
|
|
|
|
typedef struct _GimpStatusbarClass GimpStatusbarClass;
|
|
|
|
|
|
|
|
struct _GimpStatusbar
|
|
|
|
{
|
2018-05-14 02:36:22 +08:00
|
|
|
GtkFrame parent_instance;
|
2004-06-19 21:31:58 +08:00
|
|
|
|
2022-08-08 12:05:53 +08:00
|
|
|
Gimp *gimp;
|
2008-08-16 00:32:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
2022-08-08 12:05:53 +08:00
|
|
|
GimpImage *image;
|
2006-09-01 20:15:14 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
GSList *messages;
|
|
|
|
GHashTable *context_ids;
|
|
|
|
guint seq_context_id;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
macos: Fix 7690 (slow drawing)
Gets drawing in the canvas speed on retina displays up to the speed
of FullHD displays on macOS, making 2.99 usable on macOS.
Generic change:
Changes the cursor_label to delay the drawing phase to the idle
queue, from immediate draw on all platforms.
Before the fix in 32049afd (using a deprecated function in Gtk3)
any draws on this label forced a full canvas redraw. This is due
to a quirk in how GtkLabel functions.
The redraw occurred because GtkLabels resize themselves and everything
around them by sending a resize message any time they receive new
text. These resizes then trigger the full canvas resize which triggers
a full canvas redraw that cannot be optimized by either Gtk or Big Sur.
MacOS changes:
Only redraws the cursor position label and each of the horizontal and
vertical rules (cursor tracking widgets) 3 times a second max for a
total of 9 redraws a second (ideally out of 60, though I don't believe
under any circumstances that GIMP achieves a 60fps).
Each of the cursor tracking widgets gets its own timeslice, and so
will not redraw when the other cursor tracking widgets are drawing.
This is required because Big Sur is merging all draw rects into
one large rect, dramatically slowing down draws.
This timeslicing ensures that draw rects are maintained at the smallest
possible size. So the typical redraw is a small rect around the
brush. However, 9 times a second, the rect will include one of the
3 cursor tracking widgets (rulers and cursor label).
Additionally, the code tries to minimize resizing the width of the
cursor label by checking if the widget is too small for the text,
then setting the char_width to a greater size so that resizes won't
be that common.
This improves the appearance of the widget as it no longer
constantly jumps about in size on each cursor move.
Here is a discussion of the issue:
https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/572#note_1389445
Reviewer's (Jehan) notes:
* The whole issue about GtkLabel resizing is no more after 32049afd. It
is normal for a widget to request a resize when needed. We just don't
want the statusbar to resize and triggering canvas redraws.
* Changing cursor position text into an idle function generally makes
sense.
Also it reverts commit 6de9ea70223 which had a bug I hadn't realized
when I accepted it: when we test for time, we don't know yet if it
will be the last position change, hence we could "refuse" the last
update. Therefore displayed cursor position would end up outdated
on macOS. This new implementation doesn't have the problem (the last
idle update always happens after the last move).
* The change about giving 1/3 timeslices to side canvas components
(rulers and statusbar) is a complete hack to work around the fact that
macOs doesn't report properly each damaged rectangle. Instead it
returns a huge bounding box. The workaround here is to expose these
area separately.
We have not been able to find a proper solution yet. This is the only
reason why I accept this code, for macOS only, to at least have
something usable there.
See discussions in MRs gimp!572 and gimp-macos-build!86. With these 2
MRs, Lukas reported GIMP 2.99 to perform even better than GIMP 2.10 on
Monterey, though it could not be tested on Big Sur unfortunately.
* Lastly the set_width_chars() thing is also an ugly hack which I will
try later to revisit (see !581). I only accepted it (with mandatory
macOS-only macro) to have an acceptable state for release after seeing
a screencast where the label size indeed "jumps around" on macOS.
2022-02-19 09:25:51 +08:00
|
|
|
guint statusbar_pos_redraw_idle_id;
|
|
|
|
gchar *cursor_string_todraw;
|
|
|
|
gchar *cursor_string_last;
|
2022-02-07 21:44:46 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
GdkPixbuf *icon;
|
2014-05-31 01:38:17 +08:00
|
|
|
GHashTable *icon_hash;
|
2019-01-03 00:49:53 +08:00
|
|
|
gint icon_space_width;
|
2008-04-14 18:10:02 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
guint temp_context_id;
|
|
|
|
guint temp_timeout_id;
|
|
|
|
GimpMessageSeverity temp_severity;
|
2006-09-23 00:44:47 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
|
2008-08-21 00:22:09 +08:00
|
|
|
gchar cursor_format_str_f[CURSOR_FORMAT_LENGTH];
|
2008-08-16 00:32:09 +08:00
|
|
|
gchar length_format_str[CURSOR_FORMAT_LENGTH];
|
2022-03-09 20:16:01 +08:00
|
|
|
GimpCursorPrecision cursor_precision;
|
|
|
|
gint cursor_w_digits;
|
|
|
|
gint cursor_h_digits;
|
|
|
|
|
2004-11-10 09:17:40 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
GtkWidget *cursor_label;
|
|
|
|
GtkWidget *unit_combo;
|
|
|
|
GtkWidget *scale_combo;
|
2018-06-04 21:13:23 +08:00
|
|
|
GtkWidget *rotate_widget;
|
2017-11-15 10:37:20 +08:00
|
|
|
GtkWidget *rotate_label;
|
2017-11-16 02:56:33 +08:00
|
|
|
GtkWidget *horizontal_flip_icon;
|
|
|
|
GtkWidget *vertical_flip_icon;
|
2010-04-20 15:56:59 +08:00
|
|
|
GtkWidget *label; /* same as GtkStatusbar->label */
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2008-08-16 00:32:09 +08:00
|
|
|
GtkWidget *progressbar;
|
|
|
|
GtkWidget *cancel_button;
|
|
|
|
gboolean progress_active;
|
|
|
|
gboolean progress_shown;
|
|
|
|
gdouble progress_value;
|
2018-04-07 23:46:58 +08:00
|
|
|
guint64 progress_last_update_time;
|
2020-06-18 18:05:47 +08:00
|
|
|
|
2022-08-02 07:22:05 +08:00
|
|
|
GtkWidget *soft_proof_button;
|
2022-08-08 12:05:53 +08:00
|
|
|
GtkWidget *soft_proof_container;
|
|
|
|
GtkWidget *soft_proof_popover;
|
|
|
|
GtkWidget *proof_colors_toggle;
|
|
|
|
GtkWidget *profile_label;
|
|
|
|
GtkWidget *profile_combo;
|
|
|
|
GtkWidget *rendering_intent_combo;
|
|
|
|
GtkWidget *bpc_toggle;
|
|
|
|
GtkWidget *optimize_combo;
|
|
|
|
GtkWidget *out_of_gamut_toggle;
|
2022-08-02 07:22:05 +08:00
|
|
|
|
2020-06-18 18:05:47 +08:00
|
|
|
GSList *size_widgets;
|
2002-02-03 20:10:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpStatusbarClass
|
|
|
|
{
|
2018-05-14 02:36:22 +08:00
|
|
|
GtkFrameClass parent_class;
|
2004-06-19 21:31:58 +08:00
|
|
|
};
|
2002-06-27 06:16:59 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2009-09-26 01:35:03 +08:00
|
|
|
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
|
|
|
|
GtkWidget * gimp_statusbar_new (void);
|
|
|
|
|
|
|
|
void gimp_statusbar_set_shell (GimpStatusbar *statusbar,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
|
|
|
gboolean gimp_statusbar_get_visible (GimpStatusbar *statusbar);
|
|
|
|
void gimp_statusbar_set_visible (GimpStatusbar *statusbar,
|
|
|
|
gboolean visible);
|
|
|
|
void gimp_statusbar_empty (GimpStatusbar *statusbar);
|
|
|
|
void gimp_statusbar_fill (GimpStatusbar *statusbar);
|
|
|
|
|
|
|
|
void gimp_statusbar_override_window_title (GimpStatusbar *statusbar);
|
|
|
|
void gimp_statusbar_restore_window_title (GimpStatusbar *statusbar);
|
|
|
|
|
|
|
|
void gimp_statusbar_push (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
...) G_GNUC_PRINTF (4, 5);
|
2009-09-26 01:35:03 +08:00
|
|
|
void gimp_statusbar_push_valist (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
va_list args) G_GNUC_PRINTF (4, 0);
|
2009-09-26 01:35:03 +08:00
|
|
|
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
GimpCursorPrecision precision,
|
|
|
|
const gchar *title,
|
|
|
|
gdouble x,
|
|
|
|
const gchar *separator,
|
|
|
|
gdouble y,
|
|
|
|
const gchar *help);
|
|
|
|
void gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *title,
|
|
|
|
GimpOrientationType axis,
|
|
|
|
gdouble value,
|
|
|
|
const gchar *help);
|
|
|
|
void gimp_statusbar_replace (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
...) G_GNUC_PRINTF (4, 5);
|
2009-09-26 01:35:03 +08:00
|
|
|
void gimp_statusbar_replace_valist (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
va_list args) G_GNUC_PRINTF (4, 0);
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar * gimp_statusbar_peek (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context);
|
|
|
|
void gimp_statusbar_pop (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context);
|
|
|
|
|
|
|
|
void gimp_statusbar_push_temp (GimpStatusbar *statusbar,
|
|
|
|
GimpMessageSeverity severity,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
...) G_GNUC_PRINTF (4, 5);
|
2009-09-26 01:35:03 +08:00
|
|
|
void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar,
|
|
|
|
GimpMessageSeverity severity,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *icon_name,
|
2009-09-26 01:35:03 +08:00
|
|
|
const gchar *format,
|
2013-11-29 07:33:05 +08:00
|
|
|
va_list args) G_GNUC_PRINTF (4, 0);
|
2009-09-26 01:35:03 +08:00
|
|
|
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
|
|
|
|
|
|
|
|
void gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
|
|
|
GimpCursorPrecision precision,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y);
|
|
|
|
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);
|
2004-07-15 00:37:13 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GIMP_STATUSBAR_H__ */
|