mirror of https://github.com/buggins/dlangui.git
allow specifying window size on creation
This commit is contained in:
parent
888859835c
commit
9f01f14645
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids>DebugFocus</debugids>
|
<debugids>DebugFocus</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources Unicode USE_FREETYPE</versionids>
|
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_SDL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>1</createImplib>
|
<createImplib>1</createImplib>
|
||||||
|
|
|
@ -251,7 +251,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// create window
|
// create window
|
||||||
Window window = Platform.instance.createWindow("My Window", null);
|
Window window = Platform.instance.createWindow("My Window", null, WindowFlag.Resizable, 700, 500);
|
||||||
|
|
||||||
static if (true) {
|
static if (true) {
|
||||||
VerticalLayout contentLayout = new VerticalLayout();
|
VerticalLayout contentLayout = new VerticalLayout();
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ class Platform {
|
||||||
*
|
*
|
||||||
* Window w/o Resizable nor Fullscreen will be created with size based on measurement of its content widget
|
* Window w/o Resizable nor Fullscreen will be created with size based on measurement of its content widget
|
||||||
*/
|
*/
|
||||||
abstract Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable);
|
abstract Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0);
|
||||||
/**
|
/**
|
||||||
* close window
|
* close window
|
||||||
*
|
*
|
||||||
|
|
|
@ -60,10 +60,12 @@ class SDLWindow : Window {
|
||||||
SDLPlatform _platform;
|
SDLPlatform _platform;
|
||||||
SDL_Window * _win;
|
SDL_Window * _win;
|
||||||
SDL_Renderer* _renderer;
|
SDL_Renderer* _renderer;
|
||||||
this(SDLPlatform platform, dstring caption, Window parent, uint flags) {
|
this(SDLPlatform platform, dstring caption, Window parent, uint flags, uint width = 0, uint height = 0) {
|
||||||
_platform = platform;
|
_platform = platform;
|
||||||
_caption = caption;
|
_caption = caption;
|
||||||
debug Log.d("Creating SDL window");
|
debug Log.d("Creating SDL window");
|
||||||
|
_dx = width;
|
||||||
|
_dy = height;
|
||||||
create(flags);
|
create(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +102,10 @@ class SDLWindow : Window {
|
||||||
|
|
||||||
protected uint _flags;
|
protected uint _flags;
|
||||||
bool create(uint flags) {
|
bool create(uint flags) {
|
||||||
|
if (!_dx)
|
||||||
|
_dx = 600;
|
||||||
|
if (!_dy)
|
||||||
|
_dy = 400;
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
uint windowFlags = SDL_WINDOW_HIDDEN;
|
uint windowFlags = SDL_WINDOW_HIDDEN;
|
||||||
if (flags & WindowFlag.Resizable)
|
if (flags & WindowFlag.Resizable)
|
||||||
|
@ -116,7 +122,7 @@ class SDLWindow : Window {
|
||||||
_glSupport = new GLSupport();
|
_glSupport = new GLSupport();
|
||||||
}
|
}
|
||||||
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
800, 600,
|
_dx, _dy,
|
||||||
windowFlags);
|
windowFlags);
|
||||||
version(USE_OPENGL) {
|
version(USE_OPENGL) {
|
||||||
if (!_win) {
|
if (!_win) {
|
||||||
|
@ -126,7 +132,7 @@ class SDLWindow : Window {
|
||||||
// recreate w/o OpenGL
|
// recreate w/o OpenGL
|
||||||
windowFlags &= ~SDL_WINDOW_OPENGL;
|
windowFlags &= ~SDL_WINDOW_OPENGL;
|
||||||
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
800, 600,
|
_dx, _dy,
|
||||||
windowFlags);
|
windowFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,9 +857,9 @@ class SDLPlatform : Platform {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable) {
|
override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0) {
|
||||||
setDefaultLanguageAndThemeIfNecessary();
|
setDefaultLanguageAndThemeIfNecessary();
|
||||||
SDLWindow res = new SDLWindow(this, windowCaption, parent, flags);
|
SDLWindow res = new SDLWindow(this, windowCaption, parent, flags, width, height);
|
||||||
_windowMap[res.windowId] = res;
|
_windowMap[res.windowId] = res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,9 +167,15 @@ class Win32Window : Window {
|
||||||
Win32ColorDrawBuf _drawbuf;
|
Win32ColorDrawBuf _drawbuf;
|
||||||
bool useOpengl;
|
bool useOpengl;
|
||||||
uint _flags;
|
uint _flags;
|
||||||
this(Win32Platform platform, dstring windowCaption, Window parent, uint flags) {
|
this(Win32Platform platform, dstring windowCaption, Window parent, uint flags, uint width = 0, uint height = 0) {
|
||||||
Win32Window w32parent = cast(Win32Window)parent;
|
Win32Window w32parent = cast(Win32Window)parent;
|
||||||
HWND parenthwnd = w32parent ? w32parent._hwnd : null;
|
HWND parenthwnd = w32parent ? w32parent._hwnd : null;
|
||||||
|
_dx = width;
|
||||||
|
_dy = height;
|
||||||
|
if (!_dx)
|
||||||
|
_dx = 600;
|
||||||
|
if (!_dy)
|
||||||
|
_dy = 400;
|
||||||
_platform = platform;
|
_platform = platform;
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
_gl = new GLSupport();
|
_gl = new GLSupport();
|
||||||
|
@ -188,8 +194,8 @@ class Win32Window : Window {
|
||||||
ws, // window style
|
ws, // window style
|
||||||
CW_USEDEFAULT, // initial x position
|
CW_USEDEFAULT, // initial x position
|
||||||
CW_USEDEFAULT, // initial y position
|
CW_USEDEFAULT, // initial y position
|
||||||
CW_USEDEFAULT, // initial x size
|
_dx, // initial x size
|
||||||
CW_USEDEFAULT, // initial y size
|
_dy, // initial y size
|
||||||
parenthwnd, // parent window handle
|
parenthwnd, // parent window handle
|
||||||
null, // window menu handle
|
null, // window menu handle
|
||||||
_hInstance, // program instance handle
|
_hInstance, // program instance handle
|
||||||
|
@ -762,9 +768,9 @@ class Win32Platform : Platform {
|
||||||
return _windowMap[cast(ulong)hwnd];
|
return _windowMap[cast(ulong)hwnd];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable) {
|
override Window createWindow(dstring windowCaption, Window parent, uint flags = WindowFlag.Resizable, uint width = 0, uint height = 0) {
|
||||||
setDefaultLanguageAndThemeIfNecessary();
|
setDefaultLanguageAndThemeIfNecessary();
|
||||||
return new Win32Window(this, windowCaption, parent, flags);
|
return new Win32Window(this, windowCaption, parent, flags, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// calls request layout for all windows
|
/// calls request layout for all windows
|
||||||
|
|
|
@ -200,7 +200,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
// TODO: move to styles
|
// TODO: move to styles
|
||||||
protected uint _selectionColorFocused = 0xB060A0FF;
|
protected uint _selectionColorFocused = 0xB060A0FF;
|
||||||
protected uint _selectionColorNormal = 0xD060A0FF;
|
protected uint _selectionColorNormal = 0xD060A0FF;
|
||||||
protected uint _leftPaneBackgroundColor = 0xE0E0E0;
|
protected uint _leftPaneBackgroundColor = 0xF4F4F4;
|
||||||
protected uint _leftPaneBackgroundColor2 = 0xFFFFFF;
|
protected uint _leftPaneBackgroundColor2 = 0xFFFFFF;
|
||||||
protected uint _leftPaneBackgroundColor3 = 0xC0C0C0;
|
protected uint _leftPaneBackgroundColor3 = 0xC0C0C0;
|
||||||
protected uint _leftPaneLineNumberColor = 0x4060D0;
|
protected uint _leftPaneLineNumberColor = 0x4060D0;
|
||||||
|
@ -246,11 +246,11 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawLeftPaneFolding(DrawBuf buf, Rect rc, int line) {
|
protected void drawLeftPaneFolding(DrawBuf buf, Rect rc, int line) {
|
||||||
buf.fillRect(rc, 0xF0F0F0);
|
buf.fillRect(rc, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawLeftPaneIcons(DrawBuf buf, Rect rc, int line) {
|
protected void drawLeftPaneIcons(DrawBuf buf, Rect rc, int line) {
|
||||||
buf.fillRect(rc, 0xC0C0C0);
|
buf.fillRect(rc, 0xE0E0E0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawLeftPaneModificationMarks(DrawBuf buf, Rect rc, int line) {
|
protected void drawLeftPaneModificationMarks(DrawBuf buf, Rect rc, int line) {
|
||||||
|
@ -281,24 +281,24 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
protected void drawLeftPane(DrawBuf buf, Rect rc, int line) {
|
protected void drawLeftPane(DrawBuf buf, Rect rc, int line) {
|
||||||
// override for custom drawn left pane
|
// override for custom drawn left pane
|
||||||
buf.fillRect(rc, _leftPaneBackgroundColor);
|
buf.fillRect(rc, _leftPaneBackgroundColor);
|
||||||
buf.fillRect(Rect(rc.right - 2, rc.top, rc.right - 1, rc.bottom), _leftPaneBackgroundColor2);
|
//buf.fillRect(Rect(rc.right - 2, rc.top, rc.right - 1, rc.bottom), _leftPaneBackgroundColor2);
|
||||||
buf.fillRect(Rect(rc.right - 1, rc.top, rc.right - 0, rc.bottom), _leftPaneBackgroundColor3);
|
//buf.fillRect(Rect(rc.right - 1, rc.top, rc.right - 0, rc.bottom), _leftPaneBackgroundColor3);
|
||||||
rc.right -= 3;
|
rc.right -= 3;
|
||||||
if (_foldingWidth) {
|
if (_foldingWidth) {
|
||||||
Rect rc2 = rc;
|
Rect rc2 = rc;
|
||||||
rc.right = rc2.left = rc2.right - _foldingWidth;
|
rc.right = rc2.left = rc2.right - _foldingWidth;
|
||||||
drawLeftPaneFolding(buf, rc2, line);
|
drawLeftPaneFolding(buf, rc2, line);
|
||||||
}
|
}
|
||||||
if (_lineNumbersWidth) {
|
|
||||||
Rect rc2 = rc;
|
|
||||||
rc.right = rc2.left = rc2.right - _lineNumbersWidth;
|
|
||||||
drawLeftPaneLineNumbers(buf, rc2, line);
|
|
||||||
}
|
|
||||||
if (_modificationMarksWidth) {
|
if (_modificationMarksWidth) {
|
||||||
Rect rc2 = rc;
|
Rect rc2 = rc;
|
||||||
rc.right = rc2.left = rc2.right - _modificationMarksWidth;
|
rc.right = rc2.left = rc2.right - _modificationMarksWidth;
|
||||||
drawLeftPaneModificationMarks(buf, rc2, line);
|
drawLeftPaneModificationMarks(buf, rc2, line);
|
||||||
}
|
}
|
||||||
|
if (_lineNumbersWidth) {
|
||||||
|
Rect rc2 = rc;
|
||||||
|
rc.right = rc2.left = rc2.right - _lineNumbersWidth;
|
||||||
|
drawLeftPaneLineNumbers(buf, rc2, line);
|
||||||
|
}
|
||||||
if (_iconsWidth) {
|
if (_iconsWidth) {
|
||||||
Rect rc2 = rc;
|
Rect rc2 = rc;
|
||||||
rc.right = rc2.left = rc2.right - _iconsWidth;
|
rc.right = rc2.left = rc2.right - _iconsWidth;
|
||||||
|
@ -440,14 +440,6 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
if (!_popupMenu.onBeforeOpeningSubmenu(_popupMenu))
|
if (!_popupMenu.onBeforeOpeningSubmenu(_popupMenu))
|
||||||
return;
|
return;
|
||||||
_popupMenu.updateActionState(this);
|
_popupMenu.updateActionState(this);
|
||||||
//for (int i = 0; i < _popupMenu.subitemCount; i++) {
|
|
||||||
// MenuItem item = _popupMenu.subitem(i);
|
|
||||||
// if (item.action && isActionEnabled(item.action)) {
|
|
||||||
// item.enabled = true;
|
|
||||||
// } else {
|
|
||||||
// item.enabled = false;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
PopupMenu popupMenu = new PopupMenu(_popupMenu);
|
PopupMenu popupMenu = new PopupMenu(_popupMenu);
|
||||||
popupMenu.onMenuItemActionListener = this;
|
popupMenu.onMenuItemActionListener = this;
|
||||||
PopupWidget popup = window.showPopup(popupMenu, this, PopupAlign.Point | PopupAlign.Right, x, y);
|
PopupWidget popup = window.showPopup(popupMenu, this, PopupAlign.Point | PopupAlign.Right, x, y);
|
||||||
|
|
Loading…
Reference in New Issue