Example #1
0
Bool ColorBox::InputEvent(const BaseContainer &msg)
{
	if(msg.GetInt32(BFM_INPUT_DEVICE) == BFM_INPUT_MOUSE){
		if(msg.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSELEFT){
			m_mouseX = msg.GetInt32(BFM_INPUT_X);
			m_mouseY = msg.GetInt32(BFM_INPUT_Y);
			m_mouseDown = TRUE;
			Global2Local(&m_mouseX, &m_mouseY);
			MouseDragStart(BFM_INPUT_MOUSELEFT,m_mouseX, m_mouseY,MOUSEDRAGFLAGS_0);
			MouseUpdate();
		}
	}
	Float x, y;
	BaseContainer channels;
	while (MouseDrag(&x, &y, &channels) == MOUSEDRAGRESULT_CONTINUE)
	{
		m_mouseX -= x;
		m_mouseY -= y;
		//Global2Local(&m_mouseX, &m_mouseY);
		MouseUpdate();
	}
	BaseContainer res;
	if(GetInputState(BFM_INPUT_MOUSE,BFM_INPUT_MOUSELEFT,res) && res.GetInt32(BFM_INPUT_VALUE) == 0){
		if(m_mouseDown){
			MouseDragEnd();
			m_mouseDown = FALSE;
		}
	}

	return FALSE;
}
Example #2
0
Bool PickObjectTool::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg)
{
	Int32						mode = data.GetInt32(MDATA_PICKOBJECT_MODE);
	Int32						x, y, l, xr = 0, yr = 0, wr = 0, hr = 0;
	Matrix4d				m;
	ViewportPixel** pix = nullptr;
	String					str;
	char ch[200];
	Bool ret = false;
	AutoAlloc<C4DObjectList> list;
	if (!list)
		return false;

	VIEWPORT_PICK_FLAGS flags = VIEWPORT_PICK_FLAGS_ALLOW_OGL | VIEWPORT_PICK_FLAGS_USE_SEL_FILTER;
	if (data.GetBool(MDATA_PICKOBJECT_ONLY_VISIBLE))
		flags |= VIEWPORT_PICK_FLAGS_OGL_ONLY_VISIBLE;
	x = msg.GetInt32(BFM_INPUT_X);
	y = msg.GetInt32(BFM_INPUT_Y);
	Float64 timer = 0.0;
	if (mode == MDATA_PICKOBJECT_MODE_CIRCLE)
	{
		Int32 rad = data.GetInt32(MDATA_PICKOBJECT_CIRCLE_RAD);
		timer = GeGetMilliSeconds();
		ret = ViewportSelect::PickObject(bd, doc, x, y, rad, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
		timer = GeGetMilliSeconds() - timer;
	}
	else if (mode == MDATA_PICKOBJECT_MODE_RECTANGLE)
	{
		Int32 width	 = data.GetInt32(MDATA_PICKOBJECT_RECT_W);
		Int32 height = data.GetInt32(MDATA_PICKOBJECT_RECT_H);
		x -= width / 2;
		y -= height / 2;
		timer = GeGetMilliSeconds();
		ret = ViewportSelect::PickObject(bd, doc, x, y, x + width, y + height, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
		timer = GeGetMilliSeconds() - timer;
	}
	if (ret)
	{
		sprintf(ch, "Picking region from (%d, %d), size (%d, %d)|", xr, yr, wr, hr);
		str += ch;
		for (l = 0; l < list->GetCount(); l++)
		{
			sprintf(ch, ", z = %.4f|", list->GetZ(l));
			str += "Found Object " + list->GetObject(l)->GetName() + ch;
		}
	}
	else
	{
		str	= "PickObject failed";
	}
	sprintf(ch, "|Time: %.2f us", float(timer) * 1000.0f);
	str += ch;

	DeleteMem(pix);
	GeOutString(str, GEMB_OK);

	return true;
}
Example #3
0
Bool SpotColor::InputEvent(const BaseContainer &msg)
{
	if(msg.GetInt32(BFM_INPUT_DEVICE) == BFM_INPUT_MOUSE){
		if(msg.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSELEFT){
			if(m_dragable){
				Vector col = m_color.Convert(COLOR_SOURCE_DISPLAY).AsVector();
                ClampColor(col);
				if(!HandleMouseDrag(msg,DRAGTYPE_RGB,&col,0)){
                    HandleClick();
                }
			}
		}
	}
	return FALSE;
}
void DropEffector::InitPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread)
{
	BaseContainer* bc = op->GetDataInstance();
	if (!bc)
		return;

	if (!rcol)
		return;

	ed.mode = bc->GetInt32(DROPEFFECTOR_MODE);
	ed.maxdist = bc->GetFloat(DROPEFFECTOR_DISTANCE);
	ed.target	 = bc->GetObjectLink(DROPEFFECTOR_TARGET, doc);
	if (!ed.target)
		return;

	ed.targmg	 = ed.target->GetMg();
	ed.itargmg = ~ed.targmg;
	ed.genmg	= gen->GetMg();
	ed.igenmg = ~ed.genmg;

	//Add a dependency so that the effector will update if the target changes
	AddEffectorDependence(ed.target);

	//Can't init raycollider or the target isn't polygonal, then skip
	if (!rcol->Init(ed.target))
		ed.target = nullptr;
	else if (!ed.target->IsInstanceOf(Opolygon))
		ed.target = nullptr;
}
/*********************************************************************\
	Function name    : CCustomElementSettings::Command
	Description      :
	Created at       : 26.03.02, @ 13:18:45
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CCustomElementSettings::Command(Int32 lID, const BaseContainer &msg)
{
    switch (lID)
    {
    case IDC_CUSTOM_GUI_LIST:
    {
        Int32 lItemID = msg.GetInt32(LV_SIMPLE_ITEM_ID);
        AutoAlloc<BaseSelect> pSel;
        m_wndListView.GetSelection(pSel);
        if (!pSel) break;
        if (!pSel->IsSelected(lItemID)) break;

        if (m_lLastID != lItemID)
        {
            m_pElement->m_lElement = lItemID;
            m_lLastID = lItemID;

            CCustomElements* pElement = g_pCustomElements->GetItem(m_pElement->m_lElement);
            if (pElement)
            {
                m_pElement->m_strName = GeLoadString(IDS_CUSTOM_ELEMENT) + " [" + pElement->m_strName + "]";;
                m_pElement->SetDescr(m_pElement->m_strName);
                m_wndSubDlg.Refresh(m_pSettingsDialog, pElement->m_pProp, m_pElement);
            }
            m_pElement->ItemChanged();
            m_pElement->GetDocument()->UpdateAllViews(true, false);
        }
    }
    break;
    }
    return true;
}
Example #6
0
void ColorBox::DrawMsg(Int32 x1,Int32 y1,Int32 x2,Int32 y2, const BaseContainer &msg)
{
	// skip the redraw in case if focus change
	Int32 reason = msg.GetInt32(BFM_DRAW_REASON);
	if (reason==BFM_GOTFOCUS || reason==BFM_LOSTFOCUS) 
		return;
	OffScreenOn();
	DrawBitmap(m_bitmap,x1,y1,m_bitmap->GetBw(),m_bitmap->GetBh(),0,0,m_bitmap->GetBw(),m_bitmap->GetBh(),BMP_NORMAL);
}
Example #7
0
	virtual Int32 Message(const BaseContainer& msg, BaseContainer& result)
	{
		switch (msg.GetId())
		{
			case BFM_WEIGHTS_CHANGED:
				// if the weights change because of user interaction you will get notified
				if (msg.GetInt32(BFM_WEIGHTS_CHANGED) == 999)
					GroupWeightsSave(999, weights);
				break;
		}
		return SubDialog::Message(msg, result);
	}
Example #8
0
/*********************************************************************\
	Function name    : CDialogUserAreaWindow::InputEvent
	Description      :
	Created at       : 21.11.01, @ 14:26:45
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CDialogUserAreaWindow::InputEvent(const BaseContainer &msg)
{
	//Int32 chn = msg.GetInt32(BFM_INPUT_CHANNEL);
	Int32 dev = msg.GetInt32(BFM_INPUT_DEVICE);

	if (dev == BFM_INPUT_MOUSE)
	{
		// send this message to the preview sub
		m_pParent->Command(m_lID, msg);
	}

	return true;
}
Example #9
0
TOOLDRAW PickObjectTool::Draw(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, BaseDrawHelp* bh, BaseThread* bt, TOOLDRAWFLAGS flags)
{
	if ((flags & TOOLDRAWFLAGS_HIGHLIGHT) && _lastBaseDraw == bd)
	{
		Int32	 mode = data.GetInt32(MDATA_PICKOBJECT_MODE);
		Vector col(1.0);
		bd->SetMatrix_Screen();
		bd->SetPen(col);
		if (mode == MDATA_PICKOBJECT_MODE_CIRCLE)
		{
			Matrix m;
			Float	 rad = (Float)data.GetInt32(MDATA_PICKOBJECT_CIRCLE_RAD);
			m.off = Vector((Float)_mouseX, (Float)_mouseY, 0.0);
			m.v1 *= rad;
			m.v2 *= rad;
			bd->DrawCircle(m);
		}
		else if (mode == MDATA_PICKOBJECT_MODE_RECTANGLE)
		{
			Int32 width	 = data.GetInt32(MDATA_PICKOBJECT_RECT_W);
			Int32 height = data.GetInt32(MDATA_PICKOBJECT_RECT_H);
			Int32 x1 = _mouseX - width / 2;
			Int32 y1 = _mouseY - height / 2;
			Int32 x2 = x1 + width;
			Int32 y2 = y1 + height;
			bd->LineStripBegin();
			bd->LineStrip(Vector((Float)x1, (Float)y1, 0.0), col, 0);
			bd->LineStrip(Vector((Float)x2, (Float)y1, 0.0), col, 0);
			bd->LineStrip(Vector((Float)x2, (Float)y2, 0.0), col, 0);
			bd->LineStrip(Vector((Float)x1, (Float)y2, 0.0), col, 0);
			bd->LineStrip(Vector((Float)x1, (Float)y1, 0.0), col, 0);
			bd->LineStripEnd();
		}
		return TOOLDRAW_HIGHLIGHTS;
	}
	return TOOLDRAW_0;
}
Example #10
0
void PaletteSubDialog::FromContainer(const BaseContainer &bc)
{
    Int32 i=0;
    m_showLabel    = bc.GetBool(++i);
    m_rows         = bc.GetInt32(++i);
    m_layout       = bc.GetInt32(++i);
    m_searchString = bc.GetString(++i);
    m_paletteID    = bc.GetInt32(++i);
    
    if(m_rowArea != NULL){
        SetInt32(m_rowArea, m_rows);
    }
    if(m_layoutArea != NULL){
        SetInt32(m_layoutArea, m_layout);
    }
    if(m_labelCheckArea != NULL){
        SetBool(m_labelCheckArea,m_showLabel);
    }
    if(m_searchText != NULL){
        SetString(m_searchText, m_searchString);
    }
    
    m_controlsShown = !m_showControls;
}
Example #11
0
static Bool _InitRenderFn(HairVideoPost* vp, VolumeData* vd, BaseDocument* doc, BaseList2D* bl, HairObject* op, HairGuides* guides, Int32 oindex, Int32 pass)
{
	//GePrint("Init Render");

	BaseContainer*		bc	= bl->GetDataInstance();
	HairRenderingTag* hrt = (HairRenderingTag*)bl->GetNodeData();

	if (!bc || !hrt)
		return false;

	hrt->m_Shadow = bc->GetFloat(HAIR_RENDERING_SHADOW);
	hrt->m_Trans	= bc->GetFloat(HAIR_RENDERING_TRANSPARENCY);
	hrt->m_Depth	= bc->GetInt32(HAIR_RENDERING_DEPTH);

	return true;
}
Example #12
0
Bool MemStatDialog::InitValues(void)
{
	// first call the parent instance
	if (!GeDialog::InitValues())
		return false;

	BaseContainer stat;
	// since this function is slow we have to tell Cinema that we need this information by setting 1
	stat.SetInt32(C4D_MEMORY_STAT_OPENGL_TOTAL, 1);
	GeGetMemoryStat(stat);

	SetString(IDC_MEMORY_STAT_MEMORY_INUSE, String::MemoryToString(stat.GetInt64(C4D_MEMORY_STAT_MEMORY_INUSE)));
	SetString(IDC_MEMORY_STAT_MEMORY_PEAK, String::MemoryToString(stat.GetInt64(C4D_MEMORY_STAT_MEMORY_PEAK)));
	SetString(IDC_MEMORY_STAT_NO_OF_ALLOCATIONS_TOTAL, GetNoOfAllocationsString(stat.GetInt64(C4D_MEMORY_STAT_NO_OF_ALLOCATIONS_TOTAL)));
	SetString(IDC_MEMORY_STAT_NO_OF_ALLOCATIONS_CURRENT, GetNoOfAllocationsString(stat.GetInt64(C4D_MEMORY_STAT_NO_OF_ALLOCATIONS_CURRENT)));
	SetString(IDC_MEMORY_STAT_OGL_MEMORY, GetOGLMemoryString(stat.GetInt32(C4D_MEMORY_STAT_OPENGL_TOTAL)) + " / " + GetOGLMemoryString(stat.GetInt32(C4D_MEMORY_STAT_OPENGL_FREE)));
	SetString(IDC_MEMORY_STAT_EOGL_TEXBUFFER, String::MemoryToString(stat.GetInt64(C4D_MEMORY_STAT_EOGL_TEXBUFFER)) + String(" (") + String::IntToString(stat.GetInt32(C4D_MEMORY_STAT_EOGL_TEXTUREBUFFER_CNT)) + String(")"));
	SetString(IDC_MEMORY_STAT_EOGL_VERTEXBUFFER, String::MemoryToString(stat.GetInt64(C4D_MEMORY_STAT_EOGL_VERTEXBUFFER)) + String(" (") + String::IntToString(stat.GetInt32(C4D_MEMORY_STAT_EOGL_VERTEXBUFFER_CNT)) + String(")"));

	return true;
}
Example #13
0
Bool PickObjectTool::GetDDescription(BaseDocument* doc, BaseContainer& data, Description* description, DESCFLAGS_DESC& flags)
{
	Bool res = DescriptionToolData::GetDDescription(doc, data, description, flags);
	if (flags & DESCFLAGS_DESC_LOADED)
	{
		BaseContainer* bc;

		Int32 mode = data.GetInt32(MDATA_PICKOBJECT_MODE);

		bc = description->GetParameterI(DescLevel(MDATA_PICKOBJECT_CIRCLE_RAD), nullptr);
		if (bc)
			bc->SetInt32(DESC_HIDE, mode != MDATA_PICKOBJECT_MODE_CIRCLE);

		bc = description->GetParameterI(DescLevel(MDATA_PICKOBJECT_RECT_W), nullptr);
		if (bc)
			bc->SetInt32(DESC_HIDE, mode == MDATA_PICKOBJECT_MODE_CIRCLE);
		bc = description->GetParameterI(DescLevel(MDATA_PICKOBJECT_RECT_H), nullptr);
		if (bc)
			bc->SetInt32(DESC_HIDE, mode == MDATA_PICKOBJECT_MODE_CIRCLE);
	}
	return res;
}
Example #14
0
Bool PaletteSubDialog::Command(Int32 id,const BaseContainer &msg)
{
	GeDynamicArray<Palette> pals;
    Palette pal;
    Filename fn;
    switch (id)
    {
		case 3:
            switch(msg.GetInt32(BFM_ACTION_VALUE)){
                case ACTION_NEW:
                    pal.SetColor(0, Color(0.f, 0.f, 0.f).SetSource(COLOR_SOURCE_DISPLAY));
                    id = Palette::AddPalette(pal);
                    m_controlsShown = FALSE;
                    LoadPalette(id);
                    SaveSettings();
                    Palette::UpdateAll();
                    return TRUE;
                case ACTION_LOAD:
                    if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Load")){
                        String s = fn.GetString();
                        if(Palette::LoadASEFile(s, pal)){
                            id = Palette::AddPalette(pal);
                            m_controlsShown = FALSE;
                            LoadPalette(id);
                            SaveSettings();
                            Palette::UpdateAll();
                        }
                    }
                    return TRUE;
                case ACTION_SAVE:
                    if(fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_SAVE, "Save", "ase")){
                        String s = fn.GetString();
                        Palette::SaveASEFile(s, m_palette);
                    }
                    return TRUE;
                case ACTION_LABEL:
                    ShowControls(!m_showControls);
                    return TRUE;
                    
            }
            if(msg.GetInt32(BFM_ACTION_VALUE) >= ACTION_COUNT){
                m_controlsShown = FALSE;
                LoadPalette(msg.GetInt32(BFM_ACTION_VALUE)-ACTION_COUNT);
                SaveSettings();
            }
            return TRUE;
        case IDC_LAYOUT_DIRECTION:
            m_controlsShown = FALSE;
            LoadPalette(m_paletteID);
            SaveSettings();
            break;
        case IDC_ROWS:
            PaletteLayout();
            SaveSettings();
            break;
        case IDC_LABELCHECKBOX:
            GetBool(m_labelCheckArea, m_showLabel);
            LoadPalette(m_paletteID);
            SaveSettings();
            break;
        case IDC_NAME:
            if(m_nameArea != NULL){
                GetString(m_nameArea, m_palette.m_name);
                Palette::SetPaletteName(m_paletteID, m_palette.m_name);
                LoadPalette(m_paletteID);
            }
            break;
        case IDC_HIDE:
            ShowControls(FALSE);
            break;
        case IDC_SEARCHTEXT:
            PaletteLayout();
            SaveSettings();
            break;
        case IDC_CREATEMATERIAL:
            {
				Bool linkColors;
				GetBool(m_linkColor,linkColors);
                for(Int32 i=m_palette.m_colors.GetCount()-1;i>=0;--i){
                    BaseMaterial *mat = BaseMaterial::Alloc(Mmaterial);
                    String name = "PaletteMaterial";
                    if(m_palette[i].m_name != ""){
                        name = m_palette[i].m_name;
                    }
                    mat->SetName(name);
                    if(mat != nullptr){
                        BaseChannel *chan = mat->GetChannel(CHANNEL_COLOR);
                        if(chan != nullptr){
                            BaseContainer bc;
							if(linkColors){
								bc.SetInt32(BASECHANNEL_SHADERID, PALETTE_SHADER_ID);
								chan->SetData(bc);
								BaseShader *bs = chan->GetShader();
								BaseContainer* data = bs->GetDataInstance();
								data->SetInt32(PALETTESHADER_PALETTE_ID, 1+m_paletteID);
								data->SetInt32(PALETTESHADER_COLOR_ID, 1+i);
							} else {
								// Color Shader ID: 5832
								bc.SetInt32(BASECHANNEL_SHADERID, 5832);
								chan->SetData(bc);
								BaseShader *bs = chan->GetShader();
								BaseContainer* data = bs->GetDataInstance();
								
								data->SetVector(COLORSHADER_COLOR , m_palette.m_colors[i].AsVector());
							}
                            GetActiveDocument()->InsertMaterial(mat);
                            EventAdd();
                        }
                    }
                }
            }
            break;
		default:
			break;
    }
    return GeDialog::Command(id,msg);
}
/*********************************************************************\
	Function name    : CDialogCustomElement::Save
	Description      :
	Created at       : 27.03.02, @ 14:54:04
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CDialogCustomElement::Save(BaseFile* pFile, String strFill)
{
    if (g_pCustomElements && m_lElement >= 0 && m_lElement < g_pCustomElements->Entries())
    {
        CustomProperty* pProp;

        CCustomElements* pElement = g_pCustomElements->GetItem(m_lElement);
        if (!pElement) return true;
        if (!m_pbcGUI) return false;
        BaseContainer* pBC = &m_pbcGUI[m_lElement];

        pProp = pElement->m_pProp;

        WriteString(pFile, pElement->m_pChResSym);
        WriteString(pFile, " ");
        WriteString(pFile, m_strControlID);
        LineBreak(pFile, strFill);

        WriteString(pFile, "{");
        LineBreak(pFile, strFill + *g_pstrFillSave);
        SaveAlignment(pFile);
        LineBreak(pFile, strFill);

        if (pElement->m_bIsOpen)
        {
            WriteString(pFile, *g_pstrFillSave);
            WriteString(pFile, "OPEN");
            WriteString(pFile, "; ");
            LineBreak(pFile, strFill);
        }

        Int32 i;
        for (i = 0; pProp && pProp[i].type != CUSTOMTYPE_END; i++)
        {
            Bool b = false;
            if (pProp[i].type == CUSTOMTYPE_FLAG)
            {
                if (pBC->GetBool(pProp[i].id))
                {
                    WriteString(pFile, *g_pstrFillSave);
                    WriteString(pFile, pProp[i].ident);
                    WriteString(pFile, "; ");
                    b = true;
                }
            }
            else if (pProp[i].type == CUSTOMTYPE_LONG)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::IntToString(pBC->GetInt32(pProp[i].id)));

                // XXX: BITMAPBUTTON SIZE is a CUSTOMTYPE_LONG property, yet it
                // requires a tuple for the SIZE parameter. Can we find a better
                // way than hardcoding this?
                // https://github.com/nr-plugins/resedit/issues/2
                if (String(pElement->m_pChResSym) == String("BITMAPBUTTON") &&
                        String(pProp[i].ident) == String("SIZE")) {
                    WriteString(pFile, ", ");
                    WriteString(pFile, String::IntToString(pBC->GetInt32(pProp[i].id)));
                }

                WriteString(pFile, "; ");
                b = true;
            }
            else if (pProp[i].type == CUSTOMTYPE_REAL)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetFloat(pProp[i].id)));
                WriteString(pFile, "; ");
                b = true;
            }
            else if (pProp[i].type == CUSTOMTYPE_STRING)
            {
                if (pBC->GetString(pProp[i].id).Content())
                {
                    WriteString(pFile, *g_pstrFillSave);
                    WriteString(pFile, pProp[i].ident);
                    WriteString(pFile, " ");
                    WriteString(pFile, pBC->GetString(pProp[i].id));
                    WriteString(pFile, "; ");
                    b = true;
                }
            }
            else if (pProp[i].type == CUSTOMTYPE_VECTOR)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).x));
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).y));
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).z));
                WriteString(pFile, " ");
                WriteString(pFile, "; ");
                b = true;
            }

            if (b)
                LineBreak(pFile, strFill);
        }
        WriteString(pFile, "}");
    }

    return true;
}
Example #16
0
/*********************************************************************\
	Function name    : CResEditBrowser::Command
	Description      :
	Created at       : 25.09.01, @ 22:33:39
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg)
{
	switch (lID)
	{
	case IDC_BROWSE_BUTTON: {
		Filename fn = m_strPath;
		AutoAlloc <BrowseFiles> pFiles;
		pFiles->Init(Filename("\\"), false);
		if (!m_strPath.Content())
			fn = GeGetStartupPath() + String("resource");
		if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH)))
		{
			m_strPath = fn;
			FillList();
		}
		break;
	}
	case IDC_DIRECTORY_TREE: {
		TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM);
		Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE);
		if (!pSelItem) break;

		if (lType == TREEVIEW_DOUBLECLICK)
		{
			Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
			if (fn.CheckSuffix("res"))
			{
				// open the resource file
				if (!g_bWasActive)
				{ CResEditMenu m; m.Execute(nullptr); }
				if (!g_pTreeDialog) break;
				g_pTreeDialog->OpenDialog(fn);
			}
			else if (fn.CheckSuffix("str"))
			{
				CDialogDoc tempDoc;
				tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT));
				CStringtableDialog dlg(&tempDoc, true);
				if (dlg.Open())
				{
					if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES)
					{
						tempDoc.SaveGlobalStringTable();
					}
				}
			}
			else if (fn.Content())
			{
				// open the file (it may be an image)
				GeExecuteFile(fn);
			}
			return true;
		}
		else if (lType == TREEVIEW_SELCHANGE)
		{
			m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
		}

		break;
	}
	};
	return GeDialog::Command(lID, msg);
}
Example #17
0
Int32 PaletteColor::Message(const BaseContainer& msg, BaseContainer& result)
{
	if(msg.GetId() == BFM_DRAGRECEIVE){
		Int32 type = 0;
		void *object = NULL;
		GetDragObject(msg, &type, &object);
		if(type == DRAGTYPE_RGB){
			Vector *color = static_cast<Vector*>(object);
			if(msg.GetInt32(BFM_DRAG_FINISHED)){
                switch(m_hoverState){
                    case HOVER_LEFT:
                        Palette::InsertPaletteColor(m_palette, m_colorID, Color(*color).SetSource(COLOR_SOURCE_DISPLAY));
                        break;
                    case HOVER_RIGHT:
                        Palette::InsertPaletteColor(m_palette, m_colorID+1, Color(*color).SetSource(COLOR_SOURCE_DISPLAY));
                        break;
                    case HOVER_CENTER:
                        Palette::SetPaletteColor(m_palette, m_colorID, Color(*color).SetSource(COLOR_SOURCE_DISPLAY));
                        break;
                    case HOVER_DELETE:
                        Palette::RemovePaletteColor(m_palette, m_colorID);
                        break;
                }
                m_hoverState = HOVER_NONE;
			}
			else{
				if (msg.GetInt32(BFM_DRAG_LOST)){
					m_hoverState = HOVER_NONE;
					Redraw();
				}
				else{
                    BaseContainer state;
                    if(GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, state)){
                        if((*color)[0] <0.f && ((*color)[1] < 0.f && ((*color)[2] < 0.f))){
                            m_hoverState = HOVER_DELETE;
                        }else{
                            Float sideWidth = 0.2;
                            Int32 x = state.GetInt32(BFM_INPUT_X);
                            Int32 y = state.GetInt32(BFM_INPUT_Y);
                            Global2Local(&x,&y);
                            if(x < m_w*sideWidth){
                                m_hoverState = HOVER_LEFT;
                            }
                            else{
                                if(x > m_w*(1.0-sideWidth)){
                                    m_hoverState = HOVER_RIGHT;
                                }
                                else{
                                    m_hoverState = HOVER_CENTER;
                                }
                            }
                        }
                        Redraw();
                        GeUserArea::Message(msg, result);
                        return SetDragDestination(MOUSE_POINT_HAND);
                    }
				}
			}
		}
	}

	return GeUserArea::Message(msg, result);
}
Example #18
0
Bool SmplMatrixDialog::Command(Int32 id, const BaseContainer& msg)
{
	Bool update_settings = false;

	if (preview.Command(id, msg))
		return true;

	switch (id)
	{
		case	GADGET_SMPL_MATRIX_TYPE_POPUP:
		{
			Int32	type;

			preview.ChangedSettings();	// stop running threads before settings are changed
			type = msg.GetInt32(BFM_ACTION_VALUE);
			if (settings->emr)
			{
				delete_effect_matrix(settings->emr);
				settings->emr = 0;
			}

			settings->type	= type;
			update_settings = true;	// indicates changed effect settings

			break;
		}
		case	GADGET_SMPL_MATRIX_SLIDER_ANGLE:
		{
			Float32	slider_value;

			slider_value = (Float32)Deg(msg.GetFloat(BFM_ACTION_VALUE));
			if (real_time || (msg.GetInt32(BFM_ACTION_INDRAG) == false))
			{
				if (settings->angle != slider_value)
				{
					preview.ChangedSettings();	// stop running threads before settings are changed
					settings->angle = slider_value;
					update_settings = true;			// indicates changed effect settings
				}
			}
			break;
		}
		case	GADGET_SMPL_MATRIX_SLIDER_MIX:
		{
			Float32	slider_value;

			slider_value = (Float32)msg.GetFloat(BFM_ACTION_VALUE);
			if (real_time || msg.GetInt32(BFM_ACTION_INDRAG) == false)
			{
				if (settings->matrix_opacity != slider_value)
				{
					preview.ChangedSettings();	// stop running threads before settings are changed
					settings->matrix_opacity = slider_value;
					update_settings = true;			// indicates changed effect settings
				}
			}
			break;
		}
		case	GADGET_SMPL_MATRIX_TEXTURE_MODE:
		{
			preview.ChangedSettings();	// stop running threads before settings are changed
			settings->tile_flags = msg.GetInt32(BFM_ACTION_VALUE) ? TILE_REPEAT_TILING : TILE_REPEAT_BORDER;
			update_settings = true;
			break;
		}
		case	GADGET_SMPL_MATRIX_DOCUMENT_PREVIEW:
		{
			document_preview = msg.GetInt32(BFM_ACTION_VALUE);
			preview.SetDocumentPreview(document_preview);
			break;
		}
	}

	if (update_settings)
	{
		change_effect_matrix(settings, bm);
		preview.Update();
	}

	return true;
}
Example #19
0
Bool LiquidToolData::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg)
{
	Float mx = msg.GetFloat(BFM_INPUT_X);
	Float my = msg.GetFloat(BFM_INPUT_Y);
	Int32 button;

	switch (msg.GetInt32(BFM_INPUT_CHANNEL))
	{
		case BFM_INPUT_MOUSELEFT: button	= KEY_MLEFT; break;
		case BFM_INPUT_MOUSERIGHT: button = KEY_MRIGHT; break;
		default: return true;
	}

	BaseObject* cl = nullptr, *null = nullptr, *op = nullptr;
	Float				dx, dy, rad = 5.0;
	Bool				newmeta = false;

	op = BaseObject::Alloc(Osphere);
	if (!op)
		return false;

	null = BaseObject::Alloc(Ometaball);
	{
		null->GetDataInstance()->SetFloat(METABALLOBJECT_SUBEDITOR, 10.0);
		null->MakeTag(Tphong);
	}
	newmeta = true;

	if (newmeta)
	{
		doc->InsertObject(null, nullptr, nullptr);
		doc->SetActiveObject(null);

		doc->AddUndo(UNDOTYPE_NEW, null);

		DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION);
	}

	BaseContainer bc;
	BaseContainer device;
	win->MouseDragStart(button, mx, my, MOUSEDRAGFLAGS_DONTHIDEMOUSE | MOUSEDRAGFLAGS_NOMOVE);
	while (win->MouseDrag(&dx, &dy, &device) == MOUSEDRAGRESULT_CONTINUE)
	{
		bc = BaseContainer();
		win->BfGetInputEvent(BFM_INPUT_MOUSE, &bc);
		if (bc.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSEWHEEL)
		{
			rad += bc.GetFloat(BFM_INPUT_VALUE) / 120.0;
			rad	 = ClampValue(rad, (Float) 0.1, (Float) MAXRANGE);
			GePrint(String::FloatToString(rad));
		}

		if (dx == 0.0 && dy == 0.0)
			continue;

		mx += dx;
		my += dy;
		cl	= (BaseObject*)op->GetClone(COPYFLAGS_0, nullptr);
		if (!cl)
			break;

		cl->GetDataInstance()->SetFloat(PRIM_SPHERE_RAD, rad);

		cl->SetAbsPos(bd->SW(Vector(mx, my, 500.0)));
		cl->InsertUnder(null);
		DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION);
	}

	if (win->MouseDragEnd() == MOUSEDRAGRESULT_ESCAPE)
	{
		doc->DoUndo(true);
	}

	BaseObject::Free(op);

	EventAdd();
	return true;
}