preparing item grouping

This commit is contained in:
FelixKratz 2021-10-03 00:48:25 +02:00
parent fcf5db0c07
commit e0697d9879
6 changed files with 42 additions and 2 deletions

View file

@ -22,6 +22,9 @@ install: clean $(UNIVERSAL_BINS)
uninstall: clean
rm /usr/local/bin/sketchybar
profile: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -g -Ofast -fvisibility=hidden
profile: clean $(x86_BINS)
debug: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -fsanitize=address -fsanitize=undefined -g -O0 -fvisibility=hidden
debug: clean $(x86_BINS)

View file

@ -59,6 +59,7 @@ void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) {
bar_item->y_offset = 0;
bar_item->num_rects = 0;
bar_item->bounding_rects = NULL;
bar_item->group = NULL;
bar_item->has_alias = false;
bar_item->has_graph = false;

View file

@ -65,6 +65,9 @@ struct bar_item {
bool has_alias;
struct alias alias;
// Group Properties
struct group* group;
// Update Events
uint32_t update_mask;

25
src/group.c Normal file
View file

@ -0,0 +1,25 @@
#include "group.h"
#include "background.h"
#include <malloc/_malloc.h>
#include <string.h>
struct group* group_create() {
struct group* group = malloc(sizeof(struct group));
memset(group, 0, sizeof(struct group));
return group;
}
void group_init(struct group* group) {
group->name = string_copy("");
background_init(&group->background);
}
void group_set_name(struct group* group, char* _name) {
if (group->name && group->name != _name) free(group->name);
group->name = _name;
}
void group_destroy(struct group* group) {
if (group->name) free(group->name);
free(group);
}

View file

@ -1,11 +1,17 @@
#ifndef GROUP_H_
#define GROUP_H_
#include <_types/_uint32_t.h>
struct group {
char* name;
// Background
struct rgba_color background_color;
struct background background;
};
struct group* group_create();
void group_init(struct group* group);
void group_set_name(struct group* group, char* _name);
void group_destroy(struct group* group);
#endif

View file

@ -29,6 +29,7 @@
#include "text.h"
#include "graph.h"
#include "alias.h"
#include "group.h"
#include "bar_item.h"
#include "custom_events.h"
#include "bar_manager.h"
@ -44,6 +45,7 @@
#include "text.c"
#include "graph.c"
#include "alias.c"
#include "group.c"
#include "bar_item.c"
#include "custom_events.c"
#include "bar_manager.c"