Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2f106b0 in mainline


Ignore:
Timestamp:
2022-11-12T20:48:05Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
a5c7b865
Parents:
c48192e
Message:

Do not show window buttons that do not fit

Location:
uspace/app/taskbar
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar/taskbar.c

    rc48192e r2f106b0  
    192192        }
    193193
     194        if (ui_is_textmode(taskbar->ui)) {
     195                rect.p0.x = params.rect.p0.x + 9;
     196                rect.p0.y = 0;
     197                rect.p1.x = params.rect.p1.x - 10;
     198                rect.p1.y = 1;
     199        } else {
     200                rect.p0.x = params.rect.p0.x + 90;
     201                rect.p0.y = 4;
     202                rect.p1.x = params.rect.p1.x - 84;
     203                rect.p1.y = 32 - 4;
     204        }
     205        wndlist_set_rect(taskbar->wndlist, &rect);
     206
    194207        rc = wndlist_open_wm(taskbar->wndlist, wndmgt_svc);
    195208        if (rc != EOK) {
     
    249262void taskbar_destroy(taskbar_t *taskbar)
    250263{
    251         ui_fixed_remove(taskbar->fixed,  taskbar_clock_ctl(taskbar->clock));
     264        ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock));
    252265        taskbar_clock_destroy(taskbar->clock);
    253266        ui_window_destroy(taskbar->window);
  • uspace/app/taskbar/test/wndlist.c

    rc48192e r2f106b0  
    8686}
    8787
     88/* Test setting window list rectangle */
     89PCUT_TEST(set_rect)
     90{
     91        errno_t rc;
     92        ui_t *ui = NULL;
     93        ui_wnd_params_t params;
     94        ui_window_t *window = NULL;
     95        ui_fixed_t *fixed = NULL;
     96        gfx_rect_t rect;
     97        wndlist_t *wndlist;
     98
     99        rc = ui_create_disp(NULL, &ui);
     100        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     101
     102        ui_wnd_params_init(&params);
     103        params.caption = "Hello";
     104
     105        rc = ui_window_create(ui, &params, &window);
     106        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     107        PCUT_ASSERT_NOT_NULL(window);
     108
     109        rc = ui_fixed_create(&fixed);
     110        ui_window_add(window, ui_fixed_ctl(fixed));
     111
     112        rc = wndlist_create(window, fixed, &wndlist);
     113        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     114
     115        rect.p0.x = 1;
     116        rect.p0.y = 2;
     117        rect.p1.x = 3;
     118        rect.p1.y = 4;
     119        wndlist_set_rect(wndlist, &rect);
     120        PCUT_ASSERT_INT_EQUALS(1, wndlist->rect.p0.x);
     121        PCUT_ASSERT_INT_EQUALS(2, wndlist->rect.p0.y);
     122        PCUT_ASSERT_INT_EQUALS(3, wndlist->rect.p1.x);
     123        PCUT_ASSERT_INT_EQUALS(4, wndlist->rect.p1.y);
     124
     125        wndlist_destroy(wndlist);
     126
     127        ui_window_destroy(window);
     128        ui_destroy(ui);
     129}
     130
    88131/** Test opening WM service */
    89132PCUT_TEST(open_wm)
  • uspace/app/taskbar/wndlist.c

    rc48192e r2f106b0  
    6464};
    6565
     66enum {
     67        /** X distance between left edges of two consecutive buttons */
     68        wndlist_button_pitch = 145,
     69        /** X distance between left edges of two consecutive buttons (text) */
     70        wndlist_button_pitch_text = 17,
     71        /** Padding between buttons */
     72        wndlist_button_pad = 5,
     73        /** Padding between buttons (text) */
     74        wndlist_button_pad_text = 1
     75};
     76
    6677/** Create task bar window list.
    6778 *
     
    91102error:
    92103        return rc;
     104}
     105
     106/** Set window list rectangle.
     107 *
     108 * @param wndlist Window list
     109 * @param rect Rectangle
     110 */
     111void wndlist_set_rect(wndlist_t *wndlist, gfx_rect_t *rect)
     112{
     113        wndlist->rect = *rect;
    93114}
    94115
     
    287308        gfx_rect_t rect;
    288309        ui_resource_t *res;
     310        gfx_coord_t pitch;
     311        gfx_coord_t pad;
    289312        size_t idx;
    290313
     
    301324
    302325        if (ui_resource_is_textmode(res)) {
    303                 rect.p0.x = 17 * idx + 9;
     326                pitch = wndlist_button_pitch_text;
     327                pad = wndlist_button_pad_text;
     328        } else {
     329                pitch = wndlist_button_pitch;
     330                pad = wndlist_button_pad;
     331        }
     332
     333        rect.p0.x = wndlist->rect.p0.x + pitch * idx;
     334        rect.p0.y = wndlist->rect.p0.y;
     335        rect.p1.x = wndlist->rect.p0.x + pitch * (idx + 1) - pad;
     336        rect.p1.y = wndlist->rect.p1.y;
     337
     338        /* Entry does not fit? */
     339        if (rect.p1.x > wndlist->rect.p1.x) {
     340                /* Make entry invisible */
     341                rect.p0.x = 0;
    304342                rect.p0.y = 0;
    305                 rect.p1.x = 17 * idx + 25;
    306                 rect.p1.y = 1;
    307         } else {
    308                 rect.p0.x = 145 * idx + 90;
    309                 rect.p0.y = 4;
    310                 rect.p1.x = 145 * idx + 230;
    311                 rect.p1.y = 28;
     343                rect.p1.x = 0;
     344                rect.p1.y = 0;
    312345        }
    313346
  • uspace/app/taskbar/wndlist.h

    rc48192e r2f106b0  
    3838
    3939#include <errno.h>
     40#include <gfx/coord.h>
    4041#include <stdbool.h>
    4142#include <ui/fixed.h>
     
    4546
    4647extern errno_t wndlist_create(ui_window_t *, ui_fixed_t *, wndlist_t **);
     48extern void wndlist_set_rect(wndlist_t *, gfx_rect_t *);
    4749extern errno_t wndlist_open_wm(wndlist_t *, const char *);
    4850extern void wndlist_destroy(wndlist_t *);
Note: See TracChangeset for help on using the changeset viewer.