the properties

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

the properties

Post by monte » Thu Apr 18, 2013 10:08 pm

HI Folks

I'd like to fix the properties so it actually returns all the properties. I'd also like to make a couple of tweaks to the array.

Here's the bug report http://quality.runrev.com/show_bug.cgi?id=8884

The tweaks I'd like to make are:
- unicode properties instead of ISO/MAC ones where they double up (label, tooltip, text of buttons, title of stacks)
- colors and patterns returned as individual keys rather than a list... could go multi-dimensional here but I don't think that's necessary
- the array would obviously become a multi-dimensional array because of the array properties

Any comments/complaints?

Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 1:10 am

It turns out that this is easier than I thought to implement.... I've done all the array props (get and set) ... that's enough playing for today but unicode props next I guess then colors and patterns as individual keys...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: the properties

Post by phaworth » Fri Apr 19, 2013 3:15 am

Hi Monte,

Definitely good to finally get all the property names returned.

It seems that the various color props can have different names depending on what type of object they are applied to. There's firstcolor thru seventhcolor for example which I guess have various synonyms.

I assume when you refer to array here, you're just talking about properties that are in fact arrays?

Pete

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 3:57 am

It seems that the various color props can have different names depending on what type of object they are applied to. There's firstcolor thru seventhcolor for example which I guess have various synonyms.
Yeah... just synonyms... rather than return a list of 8 lines in the colors element return foreColor,backColor... etc each in their own element of the array... simpler for anyone using the array I think. I guess there's a very small backwards compatibility concern but given the properties hasn't actually done what it says on the tin for years I doubt too many people would complain if it had a rethink...
I assume when you refer to array here, you're just talking about properties that are in fact arrays?
Yes indeed... so the fillGradient element of the properties would itself be an array... currently it returns "none" no matter what you have the fillGradient set to.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: the properties

Post by LCMark » Fri Apr 19, 2013 8:35 am

This would be cool. Monte, if it helps, I can post part of the work we've done so far in restructuring stackfile import/export - we have a collection of structures that records precisely the (underlying) persistent properties for all the object types. This may make it easier to see which properties are present and which are missing.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 8:47 am

https://github.com/runrev/livecode/pull/22

also added `the effective properties` ;-)

It would be good to crosscheck the arrays in props.cpp with what you have though...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: the properties

Post by LCMark » Fri Apr 19, 2013 8:59 am

Okay, these structs (in theory) are the base set of data that each object stores in memory (and in the stackfile) from which all the properties are derived. At the very least they should help determine if any objects are missing props from 'the properties' which would prevent them being reconstructed faithfully by just setting 'the properties'.

Code: Select all

struct MCFileFormatStringRecord
{
	bool is_unicode : 1;
	uindex_t length;
	void *bytes;
};

enum MCFileFormatObjectPaintType
{
	kMCFileFormatObjectPaintTypeNone,
	kMCFileFormatObjectPaintTypeColor,
	kMCFileFormatObjectPaintTypeNamedColor,
	kMCFileFormatObjectPaintTypePixmapId,
};

struct MCFileFormatObjectPaintRecord
{
	MCFileFormatObjectPaintType type;
	union
	{
		const char *color_name;
		MCColor color;
		uint32_t pixmap_id;
	};
};

struct MCFileFormatObjectPropSetRecord
{
	MCNameRef name;
	MCVariableValue *value;
};

struct MCFileFormatObjectRecord
{
	uint32_t obj_id;
	MCNameRef name;
	bool lock_location : 1;
	bool show_border : 1;
	bool opaque : 1;
	bool threed : 1;
	bool visible : 1;
	bool traversal_on : 1;
	bool disabled : 1;
	bool cant_select : 1;
	bool no_focus_border : 1;
	const char *script;
	union
	{
		struct
		{
			MCFileFormatObjectPaintRecord fore_paint;
			MCFileFormatObjectPaintRecord back_paint;
			MCFileFormatObjectPaintRecord hilite_paint;
			MCFileFormatObjectPaintRecord border_paint;
			MCFileFormatObjectPaintRecord top_paint;
			MCFileFormatObjectPaintRecord bottom_paint;
			MCFileFormatObjectPaintRecord shadow_paint;
			MCFileFormatObjectPaintRecord focus_paint;
		};
		MCFileFormatObjectPaintRecord paints[8];
	};

	uint8_t border_width;
	int8_t shadow_offset;
	const char *tooltip;
	uint16_t alt_id;
	uint8_t ink;
	uint8_t blend_level;
	MCRectangle rect;

	bool has_behavior;
	uint32_t behavior_id;
	MCNameRef behavior_stack;

	bool has_text_font : 1;
	MCNameRef text_font;
	bool has_text_style : 1;
	uint16_t text_style;
	bool has_text_size : 1;
	uint16_t text_size;

	uint16_t font_height;
};

struct MCFileFormatStackRecord: public MCFileFormatObjectRecord
{
	bool cant_delete : 1;
	bool always_buffer : 1;
	bool cant_abort : 1;
	bool cant_modify : 1;
	bool dynamic_paths : 1;
	bool wm_place : 1;
	bool hc_addressing : 1;
	bool resizable : 1;
	bool start_up_iconic : 1;
	bool format_for_printing : 1;
	bool destroy_stack : 1;
	bool destroy_window : 1;

	uint32_t icon_id;
	const char *title;
	uint16_t decorations; 
	uint32_t window_shape_id;
	uint16_t minwidth;
	uint16_t minheight;
	uint16_t maxwidth;
	uint16_t maxheight;
	const char *external_files;
	const MCStackfile *stack_files;
	uindex_t stack_file_count;
	MCNameRef menubar;
	const Linkatts *linkatts;
};

struct MCFileFormatCardRecord: public MCFileFormatObjectRecord
{
	bool marked : 1;
	bool cant_delete : 1;
	bool dont_search : 1;
};

struct MCFileFormatAudioClipRecord: public MCFileFormatObjectRecord
{
	bool external : 1;

	const int8_t *samples;
	uindex_t sample_count;

	uint16_t format;
	uint16_t channel_count;
	uint16_t swidth;
	uint16_t loudness;
};

struct MCFileFormatVideoClipRecord: public MCFileFormatObjectRecord
{
	bool dont_refresh : 1;

	const uint8_t *frames;
	uindex_t frame_count;
	uint16_t frame_rate;
	double scale;
};

struct MCFileFormatControlRecord: public MCFileFormatObjectRecord
{
	MCBitmapEffectsRef bitmap_effects;
	MCLayerModeHint layer_mode;
	int16_t leftmargin;
	int16_t rightmargin;
	int16_t topmargin;
	int16_t bottommargin;
};

struct MCFileFormatScrollbarRecord: public MCFileFormatControlRecord
{
	bool has_values : 1;

	double startvalue;
	double endvalue;
	double thumbpos;
	double thumbsize;
	double lineinc;
	double pageinc;

	const char *startstring;
	const char *endstring;
	uint16_t fw;
	uint16_t trailing;
	uint16_t force;
};

struct MCFileFormatGroupRecord: public MCFileFormatControlRecord
{
	bool radio_behavior : 1;
	bool tab_group_behavior : 1;
	bool cant_delete : 1;
	bool dont_search : 1;
	bool show_name : 1;
	bool group_only : 1;
	bool select_group : 1;
	bool unbounded_hscroll : 1;
	bool unbounded_vscroll : 1;
	bool shared : 1;
	MCFileFormatStringRecord label;
	bool has_bounding_rect : 1;
	MCRectangle bounding_rect;
	bool has_hscrollbar : 1;
	MCFileFormatScrollbarRecord hscrollbar;
	bool has_vscrollbar : 1;
	MCFileFormatScrollbarRecord vscrollbar;
};

struct MCFileFormatFieldRecord: public MCFileFormatControlRecord
{	
	bool auto_tab : 1;
	bool dont_search : 1;
	bool auto_hilite : 1;
	bool auto_arm : 1;
	bool dont_wrap : 1;
	bool fixed_height : 1;
	bool lock_text : 1;
	bool shared_text : 1;
	bool show_lines : 1;
	bool hgrid : 1;
	bool vgrid : 1;
	bool list_behavior : 1;
	bool multiple_hilites : 1;
	bool noncontiguous_hilites : 1;
	bool toggle_hilite : 1;
	bool threed_hilite : 1;
	int16_t indent;
	uindex_t tab_count;
	const uint16_t *tabs;
	unsigned text_align : 2;
	bool has_hscrollbar : 1;
	MCFileFormatScrollbarRecord vscrollbar;
	bool has_vscrollbar : 1;
	MCFileFormatScrollbarRecord hscrollbar;
};

struct MCFileFormatButtonRecord: public MCFileFormatControlRecord
{
	bool auto_arm : 1;
	bool auto_hilite : 1;
	bool arm_border : 1;
	bool arm_fill : 1;
	bool hilite_border : 1;
	bool hilite_fill : 1;
	bool show_hilite : 1;
	bool shared_hilite : 1;
	bool show_icon : 1;
	bool show_name : 1;
	bool list_behavior : 1;
	bool multiple_hilites : 1;
	bool noncontiguous_hilites : 1;
	bool toggle_hilite : 1;
	bool threed_hilite : 1;
	
	bool has_icons : 1;
	uint32_t armed_icon;
	uint32_t disabled_icon;
	uint32_t hilited_icon;
	uint32_t default_icon;
	uint32_t visited_icon;
	uint32_t hover_icon;

	uint8_t style;
	MCFileFormatStringRecord label;
	uint16_t label_width;
	const char *menu_name;
	MCFileFormatStringRecord menu_string;
	uint8_t menu_button;
	uint16_t family;
	uint8_t menu_mode;
	bool has_menu_history : 1;
	uint16_t menu_history;
	uint16_t menu_lines;
	MCFileFormatStringRecord accel_text;
	uint16_t accel_key;
	uint8_t accel_mods;
	uint8_t mnemonic;
};

struct MCFileFormatImageRecord: public MCFileFormatControlRecord
{
	bool true_color : 1;
	bool always_buffer : 1;
	bool dont_dither : 1;
	bool palindrome_frames : 1;
	bool constant_mask : 1;

	const char *filename;

	int16_t repeat_count;

	uindex_t data_size; // text property 
	uint8_t *data;

	uint16_t xhot;
	uint16_t yhot;
	uint16_t angle;
};

struct MCFileFormatGraphicRecord: public MCFileFormatControlRecord
{
	bool anti_aliased : 1;
	bool start_arrow : 1;
	bool end_arrow : 1;
	bool marker_drawn : 1;
	bool marker_opaque : 1;
	bool round_ends : 1;
	bool dont_resize : 1;
	bool show_name : 1;
	
	uint16_t cap_style;
	uint16_t join_style;
	uint16_t fill_rule;

	uint16_t style;
	union
	{
		struct
		{
		} rectangle;
		struct
		{
			uint16_t round_radius;
		} rounded_rectangle;
		struct
		{
			uint16_t angle;
			uint16_t side_count;
		} regular_polygon;
		struct
		{
			uint16_t start_angle;
			uint16_t arc_angle;
		} oval;
		struct
		{
			uint16_t arrow_size;
			uint16_t real_point_count;
			MCPoint *real_points;
			uint16_t marker_line_size;
			uint16_t marker_point_count;
			MCPoint *marker_points;
		} polygon;
		struct
		{
			uint16_t arrow_size;
			uint16_t real_point_count;
			MCPoint *real_points;
		} line, curve;
	};

	uint16_t line_size;
	uint8_t *dashes;
	uint16_t dash_count;
	MCFileFormatStringRecord label;
};

struct MCFileFormatPlayerRecord: public MCFileFormatControlRecord
{
	const char *filename;
	uint16_t start_time;
	uint16_t end_time;
	double rate;
	const char *callback;
};

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 9:19 am

ok... added showFocusBorder to stack, card, group for a start... I'll go through this and see what I can find. I might see if I can reduce the replication in props.cpp a but following the struct hierarchy. That should make it more maintainable.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: the properties

Post by LCMark » Fri Apr 19, 2013 9:31 am

I guess one of the reasons why they are distinct arrays for each object is because some objects 'delete' parent properties - so you can't actually set them. For example you can't set left, top, right, bottom, visible etc. of cards. [ Just a small spanner to throw in the works ;) ]

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 9:45 am

Hmm... what other cases of that are there... I've always thought setting the card properties should just set the stack properties in those cases... it's most likely what the user wants and is nicer than throwing an error. Come to think of it though it might actually be nice for cards to have their own width,height that if not set is inherited...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: the properties

Post by LCMark » Fri Apr 19, 2013 10:03 am

You can find the properties that are like this by searching for EE_OBJECT_SETNOPROP... This is the error that is thrown in the ::setprop handlers for the objects that do this... Only seems to be card and stack.

Hmm - I quite like the idea of being able to set the rect type props on a card... They could be relative to the stack - however, what would the best semantics be in this case? Should the stack rect take precedence, with the card's rect embedded in it (potentially with scroll bars)? Or should the card width / height override the stack width / height on go?

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 10:10 am

Hmm... scrollbars on a stack/card should be a separate thing I think. The card rect if set should override the stack. I'm thinking of a tabbed UI like the standalone settings where each card has a different rect. This could all be done with properties this way...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1208
Joined: Thu Apr 11, 2013 11:27 am

Re: the properties

Post by LCMark » Fri Apr 19, 2013 10:24 am

Certainly something to consider... Perhaps start discussions on a separate thread?

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 11:24 am

OK, might tidy up these other contributions first before I start working on something else
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: the properties

Post by monte » Fri Apr 19, 2013 11:27 am

hmm... should script be part of the properties?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”