Repository navigation
Replies: 3 comments 3 replies
|
I have made a MWE, by changing the 'Hello World' example, in which I tried the suggestions: // Changes:
// * Make the window resizable.
// * Swap the button and textview rows.
// * Set the vertical expansion only to the textview row.
// Result (+ expected, - not expected):
// + Window start size is the natural size of the controls.
// + When enlarging, only the textview row does grow.
// - When shrinking, the textview becomes too small.
#define CHANGE_1
// Changes:
// * Add scrollbars to the panel.
// Result (+ expected, - not expected):
// - Window start size is NOT the natural size of the controls.
// + When enlarging, only the textview row does grow.
// + When shrinking, the textview maintains its height, scrollbars appear.
// - When shrinking, the window can be reduced to only the title bar.
// - When shrinking only the height, the vertical scrollbar appears, which makes
// the client width smaller and the right part of the controls are behind the scrollbar.
// - When shrinking both, the scrollbars appear, the button is only half visible.
#define CHANGE_2
// Changes:
// * Set the vertical size of the panel.
// Result (+ expected, - not expected):
// + Window start size is the natural size of the controls.
// + When enlarging, only the textview row does grow.
// - When shrinking, the window can be reduced to only the title bar.
// - When shrinking only the height, the vertical scrollbar appears, which makes
// the client width smaller and the right part of the controls are behind the scrollbar.
#define CHANGE_3
/* NAppGUI Hello World */
#include <nappgui.h>
typedef struct _app_t App;
struct _app_t
{
Window* window;
TextView* text;
uint32_t clicks;
};
/*---------------------------------------------------------------------------*/
static void i_OnButton(App* app, Event* e)
{
textview_printf(app->text, "Button click (%d)\n", app->clicks);
app->clicks += 1;
unref(e);
}
/*---------------------------------------------------------------------------*/
static Panel* i_panel(App* app)
{
#ifdef CHANGE_2
Panel* panel = panel_scroll(TRUE, TRUE);
#ifdef CHANGE_3
panel_size(panel, s2df(0, 150));
#endif // CHANGE_3
#else // CHANGE_2
Panel* panel = panel_create();
#endif // CHANGE_2
Layout* layout = layout_create(1, 3);
Label* label = label_create();
Button* button = button_push();
TextView* text = textview_create();
app->text = text;
label_text(label, "Hello!, I'm a label");
button_text(button, "Click Me!");
button_OnClick(button, listener(app, i_OnButton, App));
layout_label(layout, label, 0, 0);
#ifdef CHANGE_1
layout_button(layout, button, 0, 2);
layout_textview(layout, text, 0, 1);
layout_vsize(layout, 1, 100);
layout_vexpand(layout, 1);
#else // CHANGE_1
layout_button(layout, button, 0, 1);
layout_textview(layout, text, 0, 2);
layout_vsize(layout, 2, 100);
#endif // CHANGE_1
layout_hsize(layout, 0, 250);
layout_margin(layout, 5);
layout_vmargin(layout, 0, 5);
layout_vmargin(layout, 1, 5);
panel_layout(panel, layout);
return panel;
}
/*---------------------------------------------------------------------------*/
static void i_OnClose(App* app, Event* e)
{
osapp_finish();
unref(app);
unref(e);
}
/*---------------------------------------------------------------------------*/
static App* i_create(void)
{
App* app = heap_new0(App);
Panel* panel = i_panel(app);
#ifdef CHANGE_1
app->window = window_create(ekWINDOW_STD | ekWINDOW_RESIZE);
#else // CHANGE_1
app->window = window_create(ekWINDOW_STD);
#endif // CHANGE_1
window_panel(app->window, panel);
window_title(app->window, "Hello, World!");
window_origin(app->window, v2df(500, 200));
window_OnClose(app->window, listener(app, i_OnClose, App));
window_show(app->window);
return app;
}
/*---------------------------------------------------------------------------*/
static void i_destroy(App** app)
{
window_destroy(&(*app)->window);
heap_delete(app, App);
}
/*---------------------------------------------------------------------------*/
#include <osapp/osmain.h>
osmain(i_create, i_destroy, "", App) |
0 replies
|
Thanks, it kind of works, but the result is a flickering window while resizing. So I am not sure if this is the intended method... Should the scrollbar/content-overlap bug be filed as a new issue? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I want to make a window that is resizable with scrollbars, but also has a minimal size (that is smaller
than that of the widgets). I have setup the following components:
window
panel
layout(1,2)
tabs
panel_scroll
layout(1,1)
layout(1,3)
textview
layout(7,1)
image, label, image, label, image, label, empty cell
tableview
layout_vexpand(0)
layout_vexpand(0)
layout_vexpand(1)
The window starts with the natural size and no scrollbars. When I make the window size larger,
the textview expands. When I make the window size smaller, the scrollbars appear. The testview
is also resized, but it can become so small that it almost disappears. Also the complete window can be
made as small as 100x48 pixes, which is not very usefull.
How can I set a minimal size for the textview and the scroll panel (or layout, or window) and
still have resizing and scrollbars?
Thanks for any help!
All reactions