/*
 * Copyright © 2012 Red Hat Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */

#pragma once

#include <glib-object.h>

G_BEGIN_DECLS

static const int core_props[] = {
  GTK_CSS_PROPERTY_COLOR,
  GTK_CSS_PROPERTY_DPI,
  GTK_CSS_PROPERTY_FONT_SIZE,
  GTK_CSS_PROPERTY_ICON_PALETTE
};

static const int background_props[] = {
  GTK_CSS_PROPERTY_BACKGROUND_COLOR,
  GTK_CSS_PROPERTY_BOX_SHADOW,
  GTK_CSS_PROPERTY_BACKGROUND_CLIP,
  GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
  GTK_CSS_PROPERTY_BACKGROUND_SIZE,
  GTK_CSS_PROPERTY_BACKGROUND_POSITION,
  GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
  GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
  GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE
};

static const int border_props[] = {
  GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
  GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
  GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
  GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
  GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
  GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH,
  GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
  GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
  GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
  GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
  GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
  GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
  GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
  GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH
};

static const int icon_props[] = {
  GTK_CSS_PROPERTY_ICON_SIZE,
  GTK_CSS_PROPERTY_ICON_SHADOW,
  GTK_CSS_PROPERTY_ICON_STYLE,
  GTK_CSS_PROPERTY_ICON_WEIGHT,
};

static const int outline_props[] = {
  GTK_CSS_PROPERTY_OUTLINE_STYLE,
  GTK_CSS_PROPERTY_OUTLINE_WIDTH,
  GTK_CSS_PROPERTY_OUTLINE_OFFSET,
  GTK_CSS_PROPERTY_OUTLINE_COLOR,
};

static const int font_props[] = {
  GTK_CSS_PROPERTY_FONT_FAMILY,
  GTK_CSS_PROPERTY_FONT_STYLE,
  GTK_CSS_PROPERTY_FONT_WEIGHT,
  GTK_CSS_PROPERTY_FONT_STRETCH,
  GTK_CSS_PROPERTY_LETTER_SPACING,
  GTK_CSS_PROPERTY_TEXT_SHADOW,
  GTK_CSS_PROPERTY_CARET_COLOR,
  GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
  GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
  GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
  GTK_CSS_PROPERTY_LINE_HEIGHT,
};

static const int text_decoration_props[] = {
  GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
  GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
  GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
};

static const int font_variant_props[] = {
  GTK_CSS_PROPERTY_TEXT_TRANSFORM,
  GTK_CSS_PROPERTY_FONT_KERNING,
  GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES,
  GTK_CSS_PROPERTY_FONT_VARIANT_POSITION,
  GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
  GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC,
  GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES,
  GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
};

static const int animation_props[] = {
  GTK_CSS_PROPERTY_ANIMATION_NAME,
  GTK_CSS_PROPERTY_ANIMATION_DURATION,
  GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
  GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
  GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
  GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
  GTK_CSS_PROPERTY_ANIMATION_DELAY,
  GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
};

static const int transition_props[] = {
  GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
  GTK_CSS_PROPERTY_TRANSITION_DURATION,
  GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
  GTK_CSS_PROPERTY_TRANSITION_DELAY,
};

static const int size_props[] = {
  GTK_CSS_PROPERTY_MARGIN_TOP,
  GTK_CSS_PROPERTY_MARGIN_LEFT,
  GTK_CSS_PROPERTY_MARGIN_BOTTOM,
  GTK_CSS_PROPERTY_MARGIN_RIGHT,
  GTK_CSS_PROPERTY_PADDING_TOP,
  GTK_CSS_PROPERTY_PADDING_LEFT,
  GTK_CSS_PROPERTY_PADDING_BOTTOM,
  GTK_CSS_PROPERTY_PADDING_RIGHT,
  GTK_CSS_PROPERTY_BORDER_SPACING,
  GTK_CSS_PROPERTY_MIN_WIDTH,
  GTK_CSS_PROPERTY_MIN_HEIGHT,
};

static const int other_props[] = {
  GTK_CSS_PROPERTY_ICON_SOURCE,
  GTK_CSS_PROPERTY_ICON_TRANSFORM,
  GTK_CSS_PROPERTY_ICON_FILTER,
  GTK_CSS_PROPERTY_TRANSFORM,
  GTK_CSS_PROPERTY_TRANSFORM_ORIGIN,
  GTK_CSS_PROPERTY_OPACITY,
  GTK_CSS_PROPERTY_BACKDROP_FILTER,
  GTK_CSS_PROPERTY_FILTER,
};

static const int used_props[] = {
  GTK_CSS_PROPERTY_COLOR,
  GTK_CSS_PROPERTY_ICON_PALETTE,
  GTK_CSS_PROPERTY_BACKGROUND_COLOR,
  GTK_CSS_PROPERTY_BOX_SHADOW,
  GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
  GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
  GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
  GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
  GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
  GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
  GTK_CSS_PROPERTY_ICON_SHADOW,
  GTK_CSS_PROPERTY_OUTLINE_COLOR,
  GTK_CSS_PROPERTY_CARET_COLOR,
  GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
  GTK_CSS_PROPERTY_TEXT_SHADOW,
  GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
  GTK_CSS_PROPERTY_ICON_SOURCE,
};

/* Maps back from css property ids to position in used_props.
 * -1 means 'not present'.
 */
static const int used_props_map[] = {
  [GTK_CSS_PROPERTY_COLOR] = 0,
  [GTK_CSS_PROPERTY_DPI] = -1,
  [GTK_CSS_PROPERTY_FONT_SIZE] = -1,
  [GTK_CSS_PROPERTY_ICON_PALETTE] = 1,
  [GTK_CSS_PROPERTY_BACKGROUND_COLOR] = 2,
  [GTK_CSS_PROPERTY_FONT_FAMILY] = -1,
  [GTK_CSS_PROPERTY_FONT_STYLE] = -1,
  [GTK_CSS_PROPERTY_FONT_WEIGHT] = -1,
  [GTK_CSS_PROPERTY_FONT_STRETCH] = -1,
  [GTK_CSS_PROPERTY_LETTER_SPACING] = -1,
  [GTK_CSS_PROPERTY_TEXT_DECORATION_LINE] = -1,
  [GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR] = 15,
  [GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE] = -1,
  [GTK_CSS_PROPERTY_TEXT_TRANSFORM] = -1,
  [GTK_CSS_PROPERTY_FONT_KERNING] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_POSITION] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_CAPS] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN] = -1,
  [GTK_CSS_PROPERTY_TEXT_SHADOW] = 14,
  [GTK_CSS_PROPERTY_BOX_SHADOW] = 3,
  [GTK_CSS_PROPERTY_MARGIN_TOP] = -1,
  [GTK_CSS_PROPERTY_MARGIN_LEFT] = -1,
  [GTK_CSS_PROPERTY_MARGIN_BOTTOM] = -1,
  [GTK_CSS_PROPERTY_MARGIN_RIGHT] = -1,
  [GTK_CSS_PROPERTY_PADDING_TOP] = -1,
  [GTK_CSS_PROPERTY_PADDING_LEFT] = -1,
  [GTK_CSS_PROPERTY_PADDING_BOTTOM] = -1,
  [GTK_CSS_PROPERTY_PADDING_RIGHT] = -1,
  [GTK_CSS_PROPERTY_BORDER_TOP_STYLE] = -1,
  [GTK_CSS_PROPERTY_BORDER_TOP_WIDTH] = -1,
  [GTK_CSS_PROPERTY_BORDER_LEFT_STYLE] = -1,
  [GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH] = -1,
  [GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE] = -1,
  [GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH] = -1,
  [GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE] = -1,
  [GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH] = -1,
  [GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS] = -1,
  [GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS] = -1,
  [GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS] = -1,
  [GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS] = -1,
  [GTK_CSS_PROPERTY_OUTLINE_STYLE] = -1,
  [GTK_CSS_PROPERTY_OUTLINE_WIDTH] = -1,
  [GTK_CSS_PROPERTY_OUTLINE_OFFSET] = -1,
  [GTK_CSS_PROPERTY_BACKGROUND_CLIP] = -1,
  [GTK_CSS_PROPERTY_BACKGROUND_ORIGIN] = -1,
  [GTK_CSS_PROPERTY_BACKGROUND_SIZE] = -1,
  [GTK_CSS_PROPERTY_BACKGROUND_POSITION] = -1,
  [GTK_CSS_PROPERTY_BORDER_TOP_COLOR] = 5,
  [GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR] = 6,
  [GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR] = 7,
  [GTK_CSS_PROPERTY_BORDER_LEFT_COLOR] = 8,
  [GTK_CSS_PROPERTY_OUTLINE_COLOR] = 11,
  [GTK_CSS_PROPERTY_BACKGROUND_REPEAT] = -1,
  [GTK_CSS_PROPERTY_BACKGROUND_IMAGE] = 4,
  [GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE] = -1,
  [GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE] = 9,
  [GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT] = -1,
  [GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE] = -1,
  [GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH] = -1,
  [GTK_CSS_PROPERTY_ICON_SOURCE] = 16,
  [GTK_CSS_PROPERTY_ICON_SIZE] = -1,
  [GTK_CSS_PROPERTY_ICON_SHADOW] = 10,
  [GTK_CSS_PROPERTY_ICON_STYLE] = -1,
  [GTK_CSS_PROPERTY_ICON_TRANSFORM] = -1,
  [GTK_CSS_PROPERTY_ICON_FILTER] = -1,
  [GTK_CSS_PROPERTY_ICON_WEIGHT] = -1,
  [GTK_CSS_PROPERTY_BORDER_SPACING] = -1,
  [GTK_CSS_PROPERTY_TRANSFORM] = -1,
  [GTK_CSS_PROPERTY_TRANSFORM_ORIGIN] = -1,
  [GTK_CSS_PROPERTY_MIN_WIDTH] = -1,
  [GTK_CSS_PROPERTY_MIN_HEIGHT] = -1,
  [GTK_CSS_PROPERTY_TRANSITION_PROPERTY] = -1,
  [GTK_CSS_PROPERTY_TRANSITION_DURATION] = -1,
  [GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION] = -1,
  [GTK_CSS_PROPERTY_TRANSITION_DELAY] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_NAME] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_DURATION] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_DIRECTION] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_DELAY] = -1,
  [GTK_CSS_PROPERTY_ANIMATION_FILL_MODE] = -1,
  [GTK_CSS_PROPERTY_OPACITY] = -1,
  [GTK_CSS_PROPERTY_BACKDROP_FILTER] = -1,
  [GTK_CSS_PROPERTY_FILTER] = -1,
  [GTK_CSS_PROPERTY_CARET_COLOR] = 12,
  [GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR] = 13,
  [GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS] = -1,
  [GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS] = -1,
  [GTK_CSS_PROPERTY_LINE_HEIGHT] = -1,
};

G_STATIC_ASSERT (G_N_ELEMENTS (used_props_map) == GTK_CSS_PROPERTY_N_PROPERTIES);

G_END_DECLS
