Commit 1f7e375c authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Matthias Clasen

Add GtkTextHandle

This is a helper object to allow text widgets to implement
text selection on touch devices. It allows for both cursor
placement and text selection, displaying draggable handles
on/around the cursor and selection bound positions.

Currently, this is private to GTK+, and only available to
GtkEntry and GtkTextView.
parent 8c632417
......@@ -5767,6 +5767,8 @@ GTK_STYLE_CLASS_LINKED
GTK_STYLE_CLASS_ARROW
GTK_STYLE_CLASS_OSD
GTK_STYLE_CLASS_LEVEL_BAR
GTK_STYLE_CLASS_CURSOR_HANDLE
GTK_STYLE_CLASS_INVERTED_CURSOR_HANDLE
GTK_STYLE_REGION_COLUMN
GTK_STYLE_REGION_COLUMN_HEADER
GTK_STYLE_REGION_ROW
......
......@@ -394,8 +394,9 @@ gtk_appchooser_impl_c_sources = \
gtkappchooseronlinepk.c
endif
gtk_private_type_h_sources = \
gtkcsstypesprivate.h
gtk_private_type_h_sources = \
gtkcsstypesprivate.h \
gtktexthandleprivate.h
# GTK+ header files that don't get installed
......@@ -525,6 +526,7 @@ gtk_private_h_sources = \
gtktextbtree.h \
gtktextbufferserialize.h \
gtktextchildprivate.h \
gtktexthandleprivate.h \
gtktextiterprivate.h \
gtktextmarkprivate.h \
gtktextsegment.h \
......@@ -821,6 +823,7 @@ gtk_base_c_sources = \
gtktextbufferserialize.c \
gtktextchild.c \
gtktextdisplay.c \
gtktexthandle.c \
gtktextiter.c \
gtktextlayout.c \
gtktextmark.c \
......
......@@ -69,6 +69,7 @@ VOID:ENUM,FLOAT
VOID:ENUM,FLOAT,BOOLEAN
VOID:ENUM,INT
VOID:ENUM,INT,BOOLEAN
VOID:ENUM,INT,INT
VOID:ENUM,BOXED
VOID:ENUM,STRING
VOID:FLAGS
......
......@@ -29,6 +29,7 @@
#include <gdk/gdk.h>
#include "gtkcsstypesprivate.h"
#include "gtktexthandleprivate.h"
G_BEGIN_DECLS
......
......@@ -701,6 +701,22 @@ struct _GtkStyleContextClass
*/
#define GTK_STYLE_CLASS_LEVEL_BAR "level-bar"
/**
* GTK_STYLE_CLASS_CURSOR_HANDLE:
*
* A CSS class used when rendering a drag handle for
* text selection.
*/
#define GTK_STYLE_CLASS_CURSOR_HANDLE "cursor-handle"
/**
* GTK_STYLE_CLASS_INVERTED_CURSOR_HANDLE:
*
* A CSS class used when rendering a drag handle for
* text selection.
*/
#define GTK_STYLE_CLASS_INVERTED_CURSOR_HANDLE "inverted-cursor-handle"
/* Predefined set of widget regions */
/**
......
This diff is collapsed.
/* GTK - The GIMP Toolkit
* Copyright © 2012 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_TEXT_HANDLE_PRIVATE_H__
#define __GTK_TEXT_HANDLE_PRIVATE_H__
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_TEXT_HANDLE (_gtk_text_handle_get_type ())
#define GTK_TEXT_HANDLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_TEXT_HANDLE, GtkTextHandle))
#define GTK_TEXT_HANDLE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_TEXT_HANDLE, GtkTextHandleClass))
#define GTK_IS_TEXT_HANDLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_TEXT_HANDLE))
#define GTK_IS_TEXT_HANDLE_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_TEXT_HANDLE))
#define GTK_TEXT_HANDLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_TEXT_HANDLE, GtkTextHandleClass))
typedef struct _GtkTextHandle GtkTextHandle;
typedef struct _GtkTextHandleClass GtkTextHandleClass;
typedef enum
{
GTK_TEXT_HANDLE_POSITION_CURSOR,
GTK_TEXT_HANDLE_POSITION_SELECTION_START,
GTK_TEXT_HANDLE_POSITION_SELECTION_END = GTK_TEXT_HANDLE_POSITION_CURSOR
} GtkTextHandlePosition;
typedef enum
{
GTK_TEXT_HANDLE_MODE_NONE,
GTK_TEXT_HANDLE_MODE_CURSOR,
GTK_TEXT_HANDLE_MODE_SELECTION
} GtkTextHandleMode;
struct _GtkTextHandle
{
GObject parent_instance;
gpointer priv;
};
struct _GtkTextHandleClass
{
GObjectClass parent_class;
void (* handle_dragged) (GtkTextHandle *handle,
GtkTextHandlePosition pos,
gint x,
gint y);
void (* drag_finished) (GtkTextHandle *handle,
GtkTextHandlePosition pos);
};
GType _gtk_text_handle_get_type (void) G_GNUC_CONST;
GtkTextHandle * _gtk_text_handle_new (GtkWidget *parent);
void _gtk_text_handle_set_mode (GtkTextHandle *handle,
GtkTextHandleMode mode);
GtkTextHandleMode
_gtk_text_handle_get_mode (GtkTextHandle *handle);
void _gtk_text_handle_set_position (GtkTextHandle *handle,
GtkTextHandlePosition pos,
GdkRectangle *rect);
void _gtk_text_handle_set_visible (GtkTextHandle *handle,
GtkTextHandlePosition pos,
gboolean visible);
void _gtk_text_handle_set_relative_to (GtkTextHandle *handle,
GdkWindow *window);
gboolean _gtk_text_handle_get_is_dragged (GtkTextHandle *handle,
GtkTextHandlePosition pos);
G_END_DECLS
#endif /* __GTK_TEXT_HANDLE_PRIVATE_H__ */
......@@ -3292,6 +3292,19 @@ gtk_widget_class_init (GtkWidgetClass *klass)
1, G_MAXINT, 16,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("text-handle-width",
P_("Width of text selection handles"),
P_("Width of text selection handles"),
1, G_MAXINT, 16,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("text-handle-height",
P_("Height of text selection handles"),
P_("Height of text selection handles"),
1, G_MAXINT, 20,
GTK_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (GtkWidgetPrivate));
gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment