Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a8a7512

Browse files
committed
[[ WidgetPopup ]] Add isOpaque boolean property to MCPlatformWindow and MCStack
1 parent 64e6312 commit a8a7512

File tree

8 files changed

+36
-7
lines changed

8 files changed

+36
-7
lines changed

engine/src/desktop-stack.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void MCStack::realize(void)
191191

192192
if (m_window_shape != nil)
193193
MCPlatformSetWindowProperty(t_window, kMCPlatformWindowPropertyMask, kMCPlatformPropertyTypeWindowMask, (MCPlatformWindowMaskRef *)&m_window_shape -> handle);
194+
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyIsOpaque, isopaque());
194195
MCPlatformSetWindowProperty(t_window, kMCPlatformWindowPropertyStyle, kMCPlatformPropertyTypeWindowStyle, &t_window_style);
195196
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyHasTitleWidget, t_has_titlebox);
196197
MCPlatformSetWindowBoolProperty(t_window, kMCPlatformWindowPropertyHasCloseWidget, t_has_closebox);

engine/src/mac-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ class MCMacPlatformSurface: public MCPlatformSurface
445445
MCGRaster m_raster;
446446

447447
bool m_cg_context_first_lock;
448+
449+
bool m_opaque;
448450
};
449451

450452
////////////////////////////////////////////////////////////////////////////////

engine/src/mac-surface.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
6565
m_window = p_window;
6666
m_window -> Retain();
6767

68+
// IM-2015-02-23: [[ WidgetPopup ]] Find out if this surface is for an opaque window
69+
MCPlatformGetWindowProperty(p_window, kMCPlatformWindowPropertyIsOpaque, kMCPlatformPropertyTypeBool, &m_opaque);
70+
6871
// Borrow the CGContext and MCRegion for now.
6972
m_cg_context = p_cg_context;
7073
m_cg_context_first_lock = true;
@@ -150,7 +153,8 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
150153
m_raster . width = t_bounds . size . width * t_scale;
151154
m_raster . height = t_bounds . size . height * t_scale;
152155
m_raster . stride = m_raster . width * sizeof(uint32_t);
153-
m_raster . format = kMCGRasterFormat_xRGB;
156+
// IM-2015-02-23: [[ WidgetPopup ]] Specify ARGB format for non-opaque surfaces
157+
m_raster . format = m_opaque ? kMCGRasterFormat_xRGB : kMCGRasterFormat_ARGB;
154158
m_raster . pixels = t_bits;
155159
}
156160

@@ -163,7 +167,7 @@ CGRect MCMacFlipCGRect(const CGRect &p_rect, uint32_t p_surface_height)
163167
r_raster . width = t_actual_area . size . width * t_scale;
164168
r_raster . height = t_actual_area . size . height * t_scale;
165169
r_raster . stride = m_raster . stride;
166-
r_raster . format = kMCGRasterFormat_xRGB;
170+
r_raster . format = m_raster . format;
167171
r_raster . pixels = (uint8_t*)m_raster . pixels + (int32_t)((t_actual_area . origin . y - t_bounds . origin.y) * t_scale * m_raster . stride + (t_actual_area . origin . x - t_bounds . origin . x) * t_scale * sizeof(uint32_t));
168172

169173
r_locked_area = t_actual_area;

engine/src/mac-window.mm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ - (void)setFrameSize: (NSSize)size
18471847
[m_panel_handle setFloatingPanel: [NSApp isActive]];
18481848
else
18491849
[m_window_handle setLevel: t_window_level];
1850-
[m_window_handle setOpaque: m_mask == nil];
1850+
[m_window_handle setOpaque: m_is_opaque && m_mask == nil];
18511851
[m_window_handle setHasShadow: m_has_shadow];
18521852
if (!m_has_zoom_widget)
18531853
[[m_window_handle standardWindowButton: NSWindowZoomButton] setEnabled: NO];
@@ -1883,12 +1883,12 @@ - (void)setFrameSize: (NSSize)size
18831883
if (m_changes . has_shadow_changed)
18841884
[m_window_handle setHasShadow: m_has_shadow];
18851885

1886-
if (m_changes . mask_changed)
1886+
if (m_changes . mask_changed || m_changes . is_opaque_changed)
18871887
{
18881888
// MW-2014-07-29: [ Bug 12997 ]] Make sure we invalidate the whole window when
18891889
// the mask changes.
18901890
[[m_window_handle contentView] setNeedsDisplay: YES];
1891-
[m_window_handle setOpaque: m_mask == nil];
1891+
[m_window_handle setOpaque: m_is_opaque && m_mask == nil];
18921892
if (m_has_shadow)
18931893
m_shadow_changed = true;
18941894
}
@@ -2051,7 +2051,11 @@ bool MCMacDoUpdateRegionCallback(void *p_context, const MCRectangle &p_rect)
20512051
{
20522052
// If the shadow has changed (due to the mask changing) we must disable
20532053
// screen updates otherwise we get a flicker.
2054-
if (m_shadow_changed && m_has_shadow)
2054+
// IM-2015-02-23: [[ WidgetPopup ]] Assume shadow changes when redrawing a non-opaque widget
2055+
bool t_shadow_changed;
2056+
t_shadow_changed = (m_shadow_changed || !m_is_opaque) && m_has_shadow;
2057+
2058+
if (t_shadow_changed)
20552059
NSDisableScreenUpdates();
20562060

20572061
// Mark the bounding box of the dirty region for needing display.
@@ -2064,7 +2068,7 @@ bool MCMacDoUpdateRegionCallback(void *p_context, const MCRectangle &p_rect)
20642068
[m_view displayIfNeeded];
20652069

20662070
// Re-enable screen updates if needed.
2067-
if (m_shadow_changed && m_has_shadow)
2071+
if (t_shadow_changed)
20682072
{
20692073
// MW-2014-06-11: [[ Bug 12495 ]] Turn the shadow off and on to force recaching.
20702074
[m_window_handle setHasShadow: NO];

engine/src/platform-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class MCPlatformWindow
177177
bool has_zoom_widget_changed : 1;
178178
bool has_size_widget_changed : 1;
179179
bool has_shadow_changed : 1;
180+
bool is_opaque_changed : 1;
180181
bool has_modified_mark_changed : 1;
181182
bool use_live_resizing_changed : 1;
182183

@@ -202,6 +203,7 @@ class MCPlatformWindow
202203
bool m_has_zoom_widget : 1;
203204
bool m_has_size_widget : 1;
204205
bool m_has_shadow : 1;
206+
bool m_is_opaque : 1;
205207
bool m_has_modified_mark : 1;
206208
bool m_use_live_resizing : 1;
207209
bool m_hides_on_suspend : 1;

engine/src/platform-window.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ MCPlatformWindow::MCPlatformWindow(void)
6363
m_is_focused = false;
6464
m_is_iconified = false;
6565
m_is_realized = false;
66+
67+
m_is_opaque = true;
6668
}
6769

6870
MCPlatformWindow::~MCPlatformWindow(void)
@@ -300,6 +302,11 @@ void MCPlatformWindow::SetProperty(MCPlatformWindowProperty p_property, MCPlatfo
300302
MCPlatformWindowMaskRetain(m_mask);
301303
m_changes . mask_changed = true;
302304
break;
305+
case kMCPlatformWindowPropertyIsOpaque:
306+
assert(p_type == kMCPlatformPropertyTypeBool);
307+
m_is_opaque = *(bool *)p_value;
308+
m_changes . is_opaque_changed = true;
309+
break;
303310
case kMCPlatformWindowPropertyContentRect:
304311
assert(p_type == kMCPlatformPropertyTypeRectangle);
305312
m_content = *(MCRectangle *)p_value;
@@ -404,6 +411,10 @@ void MCPlatformWindow::GetProperty(MCPlatformWindowProperty p_property, MCPlatfo
404411
case kMCPlatformWindowPropertyMask:
405412
assert(p_type == kMCPlatformPropertyTypeWindowMask);
406413
break;
414+
case kMCPlatformWindowPropertyIsOpaque:
415+
assert(p_type == kMCPlatformPropertyTypeBool);
416+
*(bool *)r_value = m_is_opaque;
417+
break;
407418
case kMCPlatformWindowPropertyFrameRect:
408419
assert(p_type == kMCPlatformPropertyTypeRectangle);
409420
DoMapContentRectToFrameRect(m_content, *(MCRectangle *)r_value);

engine/src/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ enum MCPlatformWindowProperty
771771
kMCPlatformWindowPropertyMask,
772772
kMCPlatformWindowPropertyFrameRect,
773773
kMCPlatformWindowPropertyContentRect,
774+
kMCPlatformWindowPropertyIsOpaque,
774775

775776
kMCPlatformWindowPropertyHasTitleWidget,
776777
kMCPlatformWindowPropertyHasCloseWidget,

engine/src/stack.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ class MCStack : public MCObject
329329
virtual bool lockshape(MCObjectShape& r_shape);
330330
virtual void unlockshape(MCObjectShape& shape);
331331

332+
// IM-2015-02-23: [[ WidgetPopup ]] Return true if the contents of this stack are competely opaque.
333+
// By default, stacks are opaque.
334+
virtual bool isopaque(void) { return true; }
335+
332336
// MW-2011-08-17: [[ Redraw ]] Render the stack into the given context 'dirty' is the
333337
// hull of the clipping region.
334338
virtual void render(MCContext *dc, const MCRectangle& dirty);

0 commit comments

Comments
 (0)