Commit Graph

450 Commits

Author SHA1 Message Date
38287ba9f4 app: GimpTextTool: use the highlight color for the selected text 2011-03-20 23:59:19 +01:00
4f62bdf436 app: paint the text cursor in the highlight color
so it can be distinguished from the text box rectangle more easily.
2011-03-19 10:11:47 +01:00
f13abfa3f0 app: change image parameter in gimp_text_layout_new() to xres,yres
Because GimpTextLayout doesn't depend on any image, it only needs a
resolution.
2011-03-18 02:31:20 +01:00
503a9cebce app: implement GObject::constructed() instead of ::constructor() 2011-01-13 10:06:07 +01:00
36de5a2ab1 Bug 630376 - Crash with text layer / text tools stay on canvas when text info is discarded
Halt the tool when the text layer's text disappears.
2010-11-28 15:28:28 +01:00
8e0dd56feb app: fix crashes by not trying to navigate on a NULL layout
Add boolean return value to gimp_text_tool_ensure_layout() and check
it where needed. Also fix the new VISUAL_POSITIONS navigation code yet
again.
2010-10-14 11:01:16 +02:00
852196eb3d app: fix insert and overwrite cursors for RTL text
by using the right function to figure the location of both kinds of
cursors. Also fix crash in my last cursor movement commit: check for
error values returned by pango_layout_move_cursor_visually() and don't
try to move the cursor beyond the buffer boundaries.
2010-10-14 02:45:32 +02:00
b693269060 app: simplify creating of stroke and fill groups a lot
- add gimp_draw_tool_push_group()/pop_group() which manage a stack
  of groups; all items automatically get added to the stack's top group
- use push_group()/pop_group() all over the place, which saves a lot
  of code in most cases
- return GimpCanvasGroup not GimpCanvasItem pointers from
  gimp_draw_tool_add_stroke_group() and fill_group()

Unrelated:

- add GipmCanvasGroup parameter to gimp_rectangle_tool_draw()
- put rect select's round corners into the stroke group to
  avoid ugly overdrawing (the mis-alignment of arcs becomes
  very visible now however, will fix that soon)
2010-10-04 14:03:37 +02:00
33ab94517f app: add gimp_draw_tool_add_stroke_group() and add_fill_group()
and use it in all tools which have groups.
2010-10-01 14:24:46 +02:00
201bfe3e25 app: add a "shell" property to GimpCanvasItem
and pass it to all constructors. The GimpDisplayShell is needed
because items are going to become more powerful soon.
2010-10-01 14:13:45 +02:00
e869e83f56 app: add the text tool's selection rectangles to a filling group
Doesn't look any better but is a step in the right direction.
2010-09-27 23:04:18 +02:00
b3af235e79 app: rename all gimp_draw_tool_draw_foo() functions
to gimp_draw_tool_add_foo() because that's what they do now.
2010-09-25 19:02:22 +02:00
313f8bee1e app: remove "gboolean use_cairo" from the draw tool again
It's always TRUE now.
2010-09-24 21:14:49 +02:00
9154814b94 app: enable cairo drawing for the text tool
This looks absolutely unacceptable if there is a selection, will
fix that later with a special text selection item or a special
style.
2010-09-24 20:35:59 +02:00
4d0c750327 app: get rid of "gboolean use_offsets" in the draw tool
and always pass image coordinates. Transform the coords manually in
the very few places which passed TRUE.
2010-09-23 19:23:27 +02:00
178aa9c6dc app/tools: fix alternative button order 2010-09-07 20:39:45 +02:00
f9e68fe0ee Fix undo when going back from a modified text layer to an editable one
My earlier change to using gimp_drawable_push_undo() here was a very
bad idea. Go back to using gimp_image_undo_push_drawable_mod(), but
make use of its new tile-copying feature so the problem that made me
do the earlier change is fixed too. See comments in the changed code.
2010-03-18 10:32:52 +01:00
98a2b0210f app: fix crash introduced by layout offset refactoring
Need to call gimp_text_tool_ensure_layou() in gimp_text_tool_draw()
explicitely now, because we don't redundantly call the
get_cursor_rect() function any more when there is a selection.
2010-03-07 17:34:49 +01:00
a5409e2872 app: allow to pick text layers with the text tool
When the button_press is not in the currently edited text layer, and
not on any rectangle handle, try to pick a text layer.
2010-03-07 12:41:15 +01:00
cda52f946c app: minor code cleanup (add local variable to improve readability) 2010-03-07 01:19:32 +01:00
2e5de8f6ab app: pass the cursor's PangoRectangle to gimp_draw_tool_draw_text_cursor()
and let the drawing function decide everything instead of doing some
cursor extents fiddling in the text tool.
2010-03-07 01:15:04 +01:00
b9405d046a app: fix some corner cases in gimp_text_tool_button_release()
- request "click" releases instead of trying to detect them ourselves,
  but keep a minimum reasonable text layer size anyway (reduce it from
  20 to 3 pixels though).
- ignore RELEASE_CANCEL when selecting, we can't undo that yet.
- properly handle RELEASE_CANCEL when creating new lext layers (don't
  leave a dead overlay style editor around).
2010-03-07 00:53:32 +01:00
a077d618ea app: no need any more to block drawing before non-text changes to the proxy 2010-03-07 00:21:51 +01:00
44f6d074a3 app: call gimp_text_tool_block_drawing() in proxy_notify()
so we also correctly handle non-text and non-markup changes (e.g. via
tool options). This is not exactly the right place to call
block_drawing(), but all places which change change the actual content
(and thus un-sync buffer and layout cursor posotions) already block
drawing before the actual buffer change happens.
2010-03-07 00:15:32 +01:00
2934095816 app: use gimp_text_layout_get_offsets()
instead of duplicating GimpTextLayout's positioning logic in two
different incomplete ways. Also gets rid of the unrelated offset
return values of gimp_text_tool_editor_get_cursor_rect().
2010-03-07 00:11:05 +01:00
e9f85b3afc app: block text buffer signals around copying to the clipboard
so the copying doesn't produce an undo step. Same fix as applied
earlier in button_press().
2010-03-05 10:53:09 +01:00
076948b4b7 app: don't leave drawing blocked in the error case 2010-03-05 10:50:50 +01:00
5284c9c836 app: fix text tool drawing for good this time (hopefully)
Earlier I claimed that drawing would work now because we make sure
that buffer and layout are always in sync. This was nonsense. In fact,
we constantly ran into the sutiation where the buffer was modified,
and we were drawing with the previous layout. It's unclear why this
didn't cause drawing artifacts, but it did cause e.g. the cursor
temporarily jumping to the next position while editing in the middle
of text (especially visible at line ends).

Several underlying problems existed: first, we now modify the buffer
from outside the text tool (from GimpTextStyleEditor) where we can't
pause the tool; second, proxy changes are handled asymetrically
(property changes are queued and processed all together in an idle
function) so we can't pause/resume drawing across the entire operation
because it has many beginnings and only one end.

Therefore:

- add gimp_text_tool_block_drawing()/unblock_drawing(), where block()
  can be called as many times as needed, and a single unblock()
  enables drawing again. block() also clears the layout, because it
  served its purpose (it was just used to pause drawing, and we know
  the buffer will change, so kill it).
- connect to GtkTextBuffer::begin-user-action and call block() from
  the callback, so we undraw stuff and kill the cached layout before
  any buffer change happens.
- call unblock() at the end of gimp_text_tool_apply() because then
  the text and the buffer are in sync again, the tool is undrawn and
  we can safely create the layout again to draw our stuff.
- also call block()/unblock() from some other places, like when a
  new text layer is created.
- get rid of *all* calls to draw_tool_pause()/resume() around buffer
  modifications, they are not needed any longer.
- add calls to begin/end_user_action() where they were missing.
2010-03-04 23:47:23 +01:00
e54a05f78f app: get rid of gimp_text_tool_idle_apply()
and make gimp_text_tool_apply() itself the idle function. Might seem
like a bad idea, but is needed by an upcoming drawing refactoring.
2010-03-04 23:10:23 +01:00
080f1a6ce4 app: fix editing text layers which don't contain markup
In gimp_text_tool_connect(), set either text *or* markup on the
buffer, or the latter will always override the former (now that text
and markup are mutually exclusive in GimpText).
2010-03-03 01:15:27 +01:00
9a9d7489d1 app: make undo compression in the text tool work again
- in GimpText, make "text" and "markup" mutually exclusive, so that
  whenever one is set to non-NULL, the other is cleared automatically.
- add gimp_text_buffer_has_markup() which returns TRUE if any char
  in the buffer is tagged.
- in the text tool, only set "markup" on the text proxy if there is
  actually markup in the buffer, and set "text" otherwise.

This way we don't push "text" *and* "markup" undos on each keystroke,
and undo compression works the way it did before.
2010-03-02 21:54:24 +01:00
9c4864e789 app: optimize away redundant and expensive text layer re-rendering
- Add signal GimpText::changed() and emit it from
  GObject::dispatch_properties_changed() after all notifications have
  been emitted, so "changed" is emitted only once for any number of
  properties set within a g_object_freeze/thaw_notify() pair.
- Connect GimpTextLayer to "changed" instead of "notify" so we aviod
  lots of expensive re-rendering when multiple properties are set
  at once.
- Connect GimpTextTool to "notify" *and* "changed", and move some
  common code to the "changed" callback (e.g. we don't need to
  re-frame the item for each set property).
2010-03-02 17:44:31 +01:00
6d4f2c3431 Bug 565001 - Text-Tool crashes when edit a 2.4.2 version xcf
Need to convert to text->box_unit, not text->unit.
2010-03-02 15:24:17 +01:00
1fb61b8515 app: make sure mouse-selecting doesn't push an undo step
GtkTextBuffer emits "end-user-action" after something has been copied
to the clipboard. Work around that bug.
2010-03-02 13:04:37 +01:00
f8ac0c61ab app: make manual kerning / character spacing work
Add gimp_text_buffer_get_iter_at_index() which does the reverse thing
than the already existing function gimp_text_buffer_get_iter_index().
Use the new function when cursor-navigation lines. Add "gboolean
layout_index" to both functions, which if TRUE indicates that the
passed in/out index is an index into the PangoLayout's content rather
than the text buffer's. When dealing with layout indices, take into
account the additional characters we insert into the serialized markup
(and thus the layout) for each character that is tagged with spacing.
2010-03-01 16:27:34 +01:00
11b1300b6f app: Introduce gimp_dialog_factory_get_singleton()
Instead of including dialogs/dialogs.h everywhere, introduce
gimp_dialog_factory_get_singleton(). The dialog factory singleton is
still initialized by dialogs.c though.

Right now the assumption is that we never will have another dialog
factory instance around. There were so many problems before when we
had four of them, so let's just keep one of them around.
2010-02-28 23:23:24 +01:00
947e28596f app: Remove gimp_dialog_factory_from_name()
We only have one dialog factory now, and
gimp_dialog_factory_from_name() doesn't provide compile-time type
safety, so use global_dialog_factory directly instead.
2010-02-28 20:02:45 +01:00
9af58d8c43 app: remove redundant call to gimp_text_buffer_set_text() 2010-02-28 17:19:36 +01:00
65216b939d app: group text buffer changes by user actions
Use gtk_text_buffer_begin_user_action() and end_user_action() to group
all text buffer operations triggered by a single editing operation.
Connect to the buffer's "end-user-action" signal instead of to
"changed", "apply-tag" and "remove-tag" separately, so we only update
the text proxy once per user editing.
2010-02-28 17:15:06 +01:00
8399eefc95 app: make sure the text style box is repositioned on *each* rectangle change 2010-02-28 13:49:51 +01:00
9766f65132 app: almost fix changing layers
Still leaves artifacts, but it's much better than before.
2010-02-26 21:22:10 +01:00
ebfbc5a030 app: make sure the style editor moves with the text layer 2010-02-26 02:10:03 +01:00
c0358d8122 app: restore text box moving functionality, it got lost a few commits back 2010-02-26 01:57:51 +01:00
9cff2365b1 app: enable editing text styles
- create a GimpTextStyleEditor on the canvas when editing text.
- sync "text" and "markup" between proxy and text, not only "text.
- connect to chages to text marks on the buffer.
2010-02-26 01:36:31 +01:00
dbe54e3f05 app: rename GimpTextTool::text_buffer to just ::buffer 2010-02-25 17:49:33 +01:00
0b4bdc5613 app: add GimpTextBuffer, a GtkTextBuffer subclass
Pull all text buffer utility functions as methods and use
GimpTextBuffer all over the place instead of GtkTextBuffer.
Some actually usefuly features coming soon...
2010-02-25 17:41:10 +01:00
97db8b9b42 app: add function gimp_text_tool_editor_get_iter_index()
which returns the byte index at a GtkTextIter, and use it all over the
place.
2010-02-24 00:18:50 +01:00
14158b982a app: clean up comments 2010-02-24 00:03:15 +01:00
a17ede4ce0 app: fix crash caused by bogus value of text_tool->selecting
Set "selecting" to TRUE only when we are definitely in selecting mode
(when there is actually a text layer to click on). This commit also
makes the setting of the "selecting" state much simpler and obvious.
2010-02-23 23:46:09 +01:00
f9bee0d42f app: fix XOR cursor drawing artifacts
Switch to a completely new PangoLayout managing stategy: The drawing
code relies on text_tool->layout being a view on text_tool->text_buffer,
if they get out of sync, drawing is b0rk.

Therefore, split the update_layout() function into clear_layout()
(which kill the layout) and ensure_layout() (which creates the layout
if it doesn't exist).

Whenever the buffer gets modified, pause the draw tool before the
modification so the old cursor/selection undraw, then clear the
layout. Resuming the draw tool will automatically re-create the layout
for the buffer's new contents.

Also switch off any clipping for cursor and selection, so we can at
least see that our input has some effect, even if we don't actually
see the edited text because it's out-of-layer.
2010-02-23 23:22:03 +01:00