Add temporary option to enable test of new treeview in bookmarks window.

This commit is contained in:
Michael Drake 2013-07-01 14:07:25 +01:00
parent b6219f6685
commit 6e5e741d53
2 changed files with 48 additions and 18 deletions

View File

@ -275,3 +275,6 @@ NSOPTION_COLOUR(sys_colour_ThreeDShadow, 0x00d5d5d5)
NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1) NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1)
NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e) NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e)
NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000) NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000)
/** Temporary option for enabling test of new treeview */
NSOPTION_BOOL(temp_treeview_test, false)

View File

@ -212,54 +212,76 @@ struct core_window_callback_table cw_t = {
.get_window_dimensions = treeview_test_get_window_dimensions .get_window_dimensions = treeview_test_get_window_dimensions
}; };
static void treeview_test_init(struct tree *tree) static bool treeview_test_init(struct tree *tree)
{ {
nserror err; nserror err;
if (nsoption_bool(temp_treeview_test) == false)
return false;
treeview_init(); treeview_init();
err = global_history_init(&cw_t, (struct core_window *)tree); err = global_history_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK) { if (err != NSERROR_OK) {
warn_user("Duffed it.", 0); warn_user("Duffed it.", 0);
} }
return true;
} }
static void treeview_test_fini(struct tree *tree) static bool treeview_test_fini(struct tree *tree)
{ {
nserror err; nserror err;
if (nsoption_bool(temp_treeview_test) == false)
return false;
err = global_history_fini(); err = global_history_fini();
treeview_fini(); treeview_fini();
if (err != NSERROR_OK) { if (err != NSERROR_OK) {
warn_user("Duffed it.", 0); warn_user("Duffed it.", 0);
} }
return true;
} }
static void treeview_test_redraw(struct tree *tree, int x, int y, static bool treeview_test_redraw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height, int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx) const struct redraw_context *ctx)
{ {
struct rect clip; struct rect clip;
if (nsoption_bool(temp_treeview_test) == false)
return false;
clip.x0 = clip_x; clip.x0 = clip_x;
clip.y0 = clip_y; clip.y0 = clip_y;
clip.x1 = clip_x + clip_width; clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height; clip.y1 = clip_y + clip_height;
global_history_redraw(x, y, &clip, ctx); global_history_redraw(x, y, &clip, ctx);
return true;
} }
static void treeview_test_mouse_action(struct tree *tree, static bool treeview_test_mouse_action(struct tree *tree,
browser_mouse_state mouse, int x, int y) browser_mouse_state mouse, int x, int y)
{ {
if (nsoption_bool(temp_treeview_test) == false)
return false;
global_history_mouse_action(mouse, x, y); global_history_mouse_action(mouse, x, y);
return true;
} }
static void treeview_test_keypress(struct tree *tree, uint32_t key) static bool treeview_test_keypress(struct tree *tree, uint32_t key)
{ {
if (nsoption_bool(temp_treeview_test) == false)
return false;
global_history_keypress(key); global_history_keypress(key);
return true;
} }
@ -2156,10 +2178,11 @@ void tree_draw(struct tree *tree, int x, int y,
assert(tree->root != NULL); assert(tree->root != NULL);
if (tree->flags == TREE_MOVABLE) { if (tree->flags == TREE_MOVABLE) {
treeview_test_redraw(tree, x, y, clip_x, clip_y, if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
clip_width, clip_height, ctx); clip_width, clip_height, ctx)) {
return; return;
} }
}
/* Start knockout rendering if it's available for this plotter */ /* Start knockout rendering if it's available for this plotter */
if (ctx->plot->option_knockout) if (ctx->plot->option_knockout)
@ -2526,9 +2549,10 @@ bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
assert(tree->root != NULL); assert(tree->root != NULL);
if (tree->flags == TREE_MOVABLE) { if (tree->flags == TREE_MOVABLE) {
treeview_test_mouse_action(tree, mouse, x, y); if (treeview_test_mouse_action(tree, mouse, x, y)) {
return true; return true;
} }
}
if (tree->root->child == NULL) if (tree->root->child == NULL)
return true; return true;
@ -2937,9 +2961,11 @@ void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
int x, y; int x, y;
if (tree->flags & TREE_MOVABLE) { if (tree->flags & TREE_MOVABLE) {
treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1); if (treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER,
x1, y1)) {
return; return;
} }
}
switch (tree->drag) { switch (tree->drag) {
case TREE_NO_DRAG: case TREE_NO_DRAG:
@ -2982,9 +3008,10 @@ void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
bool tree_keypress(struct tree *tree, uint32_t key) bool tree_keypress(struct tree *tree, uint32_t key)
{ {
if (tree->flags == TREE_MOVABLE) { if (tree->flags == TREE_MOVABLE) {
treeview_test_keypress(tree, key); if (treeview_test_keypress(tree, key)) {
return true; return true;
} }
}
if (tree->editing != NULL) if (tree->editing != NULL)
switch (key) { switch (key) {