@@ -56,6 +56,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
5656#include " vclip.h"
5757#include " redraw.h"
5858#include " widget.h"
59+ #include " graphics_util.h"
5960
6061#include " globals.h"
6162#include " mctheme.h"
@@ -665,8 +666,10 @@ Boolean MCCard::mfocus(int2 x, int2 y)
665666
666667 MCRedrawUnlockScreen ();
667668
668- // MW-2011-08-19: [[ Layers ]] Ensure the selection rect is updated.
669- layer_selectedrectchanged (oldrect, selrect);
669+ /* The set of selected controls has changed so dirty the old
670+ * rect, and the new. */
671+ dirtyselection (oldrect);
672+ dirtyselection (selrect);
670673 }
671674 message_with_args (MCM_mouse_move, x, y);
672675 return true ;
@@ -918,8 +921,10 @@ Boolean MCCard::mup(uint2 which, bool p_release)
918921 if (state & CS_SIZE )
919922 {
920923 state &= ~CS_SIZE ;
921- // MW-2011-08-18: // MW-2011-08-19: [[ Layers ]] Ensure the selection rect is updated.
922- layer_dirtyrect (selrect);
924+
925+ /* The selection marquee has finished, so update the selection
926+ * layer. */
927+ dirtyselection (selrect);
923928
924929 // MM-2012-11-05: [[ Object selection started/ended message ]]
925930 if (m_selecting_objects)
@@ -3028,78 +3033,51 @@ void MCCard::drawbackground(MCContext *p_context, const MCRectangle &p_dirty)
30283033 p_context->fillrect (p_dirty);
30293034}
30303035
3031- // IM-2013-09-13: [[ RefactorGraphics ]] Factor out card selection rect drawing to separate method
3032- void MCCard::drawselectionrect (MCContext *p_context)
3033- {
3034- drawmarquee (p_context, selrect);
3035- }
3036-
3037- void MCCard::drawselectedchildren (MCDC *dc)
3036+ /* The card's drawselection method first renders the selections of all children
3037+ * and then renders the marquee. */
3038+ void MCCard::drawselection (MCContext *p_context, const MCRectangle& p_dirty)
30383039{
30393040 MCObjptr *tptr = objptrs;
30403041 if (tptr == nil)
30413042 return ;
3043+
30423044 do
30433045 {
30443046 MCControl *t_control = tptr->getref ();
3045- if (t_control != nullptr )
3047+ if (t_control != nullptr &&
3048+ t_control->getopened () != 0 &&
3049+ (t_control->getflag (F_VISIBLE ) || showinvisible ()))
30463050 {
3047- if (tptr -> getref () -> getstate (CS_SELECTED ))
3048- tptr->getref ()->drawselected (dc);
3049-
3050- if (tptr -> getrefasgroup () != nil)
3051- tptr -> getrefasgroup () -> drawselectedchildren (dc);
3051+ t_control->drawselection (p_context, p_dirty);
30523052 }
30533053
30543054 tptr = tptr->next ();
30553055 }
30563056 while (tptr != objptrs);
3057+
3058+ if (getstate (CS_SIZE ))
3059+ {
3060+ drawmarquee (p_context, selrect);
3061+ }
30573062}
30583063
30593064void MCCard::dirtyselection (const MCRectangle &p_rect)
30603065{
3061- // redraw marquee rect
3062- // selrect with 0 width or height will still draw a 1px line, so increase rect size to account for this.
3063- layer_dirtyrect (MCU_reduce_rect (p_rect, -1 ));
3064-
3065- // redraw selection handles
3066- MCRectangle t_handles[8 ];
3067- MCControl::sizerects (p_rect, t_handles);
3068-
3069- for (uint32_t i = 0 ; i < 8 ; i++)
3070- layer_dirtyrect (t_handles[i]);
3071- }
3072-
3073- bool MCCard::updatechildselectedrect (MCRectangle& x_rect)
3074- {
3075- bool t_updated;
3076- t_updated = false ;
3066+ MCRectangle t_rect = MCU_reduce_rect (p_rect, -(1 + MCsizewidth / 2 ));
30773067
3078- MCObjptr *t_objptr = objptrs;
3079- if (t_objptr == nil)
3080- return t_updated;
3081- do
3068+ MCTileCacheRef t_tilecache = getstack ()->view_gettilecache ();
3069+ if (t_tilecache != nullptr )
30823070 {
3083- MCControl *t_control;
3084- t_control = t_objptr -> getref ();
3071+ MCGAffineTransform t_transform =
3072+ getstack ()-> getdevicetransform ();
30853073
3086- if (t_control -> getstate (CS_SELECTED ))
3087- {
3088- x_rect = MCU_union_rect (t_control -> geteffectiverect (), x_rect);
3089- t_updated = true ;
3090- }
3074+ MCRectangle32 t_device_rect =
3075+ MCRectangle32GetTransformedBounds (t_rect, t_transform);
30913076
3092- if (t_control -> gettype () == CT_GROUP )
3093- {
3094- MCGroup *t_group = static_cast <MCGroup *>(t_control);
3095- t_updated = t_updated | t_group -> updatechildselectedrect (x_rect);
3096- }
3097-
3098- t_objptr = t_objptr->next ();
3077+ MCTileCacheUpdateScenery (t_tilecache, m_fg_layer_id, t_device_rect);
30993078 }
3100- while (t_objptr != objptrs);
31013079
3102- return t_updated ;
3080+ layer_dirtyrect (t_rect) ;
31033081}
31043082
31053083void MCCard::draw (MCDC *dc, const MCRectangle& dirty, bool p_isolated)
@@ -3127,18 +3105,14 @@ void MCCard::draw(MCDC *dc, const MCRectangle& dirty, bool p_isolated)
31273105 }
31283106 while (tptr != objptrs);
31293107 }
3130-
3131- // Draw the selection outline and handles on top of everything
3132- drawselectedchildren (dc);
3133-
3108+
31343109 dc -> setopacity (255 );
31353110 dc -> setfunction (GXcopy);
31363111
31373112 if (t_draw_cardborder)
31383113 drawcardborder (dc, dirty);
31393114
3140- if (getstate (CS_SIZE ))
3141- drawselectionrect (dc);
3115+ drawselection (dc, dirty);
31423116}
31433117
31443118// /////////////////////////////////////////////////////////////////////////////
0 commit comments